| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.permission; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.SystemApi; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import com.android.internal.util.Preconditions; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
@SystemApi |
| 36 |
public final class RuntimePermissionPresentationInfo implements Parcelable { |
| 37 |
private static final int FLAG_GRANTED = 1 << 0; |
| 38 |
private static final int FLAG_STANDARD = 1 << 1; |
| 39 |
|
| 40 |
private final @NonNull CharSequence mLabel; |
| 41 |
private final int mFlags; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public RuntimePermissionPresentationInfo(@NonNull CharSequence label, |
| 51 |
boolean granted, boolean standard) { |
| 52 |
Preconditions.checkNotNull(label); |
| 53 |
|
| 54 |
mLabel = label; |
| 55 |
int flags = 0; |
| 56 |
if (granted) { |
| 57 |
flags |= FLAG_GRANTED; |
| 58 |
} |
| 59 |
if (standard) { |
| 60 |
flags |= FLAG_STANDARD; |
| 61 |
} |
| 62 |
mFlags = flags; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public boolean isGranted() { |
| 69 |
return (mFlags & FLAG_GRANTED) != 0; |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public boolean isStandard() { |
| 76 |
return (mFlags & FLAG_STANDARD) != 0; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
public @NonNull CharSequence getLabel() { |
| 85 |
return mLabel; |
| 86 |
} |
| 87 |
|
| 88 |
@Override |
| 89 |
public int describeContents() { |
| 90 |
return 0; |
| 91 |
} |
| 92 |
|
| 93 |
@Override |
| 94 |
public void writeToParcel(Parcel parcel, int flags) { |
| 95 |
parcel.writeCharSequence(mLabel); |
| 96 |
parcel.writeInt(mFlags); |
| 97 |
} |
| 98 |
|
| 99 |
public static final @NonNull Creator<RuntimePermissionPresentationInfo> CREATOR = |
| 100 |
new Creator<RuntimePermissionPresentationInfo>() { |
| 101 |
public RuntimePermissionPresentationInfo createFromParcel(Parcel source) { |
| 102 |
CharSequence label = source.readCharSequence(); |
| 103 |
int flags = source.readInt(); |
| 104 |
|
| 105 |
return new RuntimePermissionPresentationInfo(label, (flags & FLAG_GRANTED) != 0, |
| 106 |
(flags & FLAG_STANDARD) != 0); |
| 107 |
} |
| 108 |
|
| 109 |
public RuntimePermissionPresentationInfo[] newArray(int size) { |
| 110 |
return new RuntimePermissionPresentationInfo[size]; |
| 111 |
} |
| 112 |
}; |
| 113 |
} |