| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.accounts; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.compat.annotation.UnsupportedAppUsage; |
| 21 |
import android.os.Build; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public class AuthenticatorDescription implements Parcelable { |
| 29 |
|
| 30 |
final public String type; |
| 31 |
|
| 32 |
|
| 33 |
final public int labelId; |
| 34 |
|
| 35 |
|
| 36 |
final public int iconId; |
| 37 |
|
| 38 |
|
| 39 |
final public int smallIconId; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
final public int accountPreferencesId; |
| 46 |
|
| 47 |
|
| 48 |
final public String packageName; |
| 49 |
|
| 50 |
|
| 51 |
final public boolean customTokens; |
| 52 |
|
| 53 |
|
| 54 |
public AuthenticatorDescription(String type, String packageName, int labelId, int iconId, |
| 55 |
int smallIconId, int prefId, boolean customTokens) { |
| 56 |
if (type == null) throw new IllegalArgumentException("type cannot be null"); |
| 57 |
if (packageName == null) throw new IllegalArgumentException("packageName cannot be null"); |
| 58 |
this.type = type; |
| 59 |
this.packageName = packageName; |
| 60 |
this.labelId = labelId; |
| 61 |
this.iconId = iconId; |
| 62 |
this.smallIconId = smallIconId; |
| 63 |
this.accountPreferencesId = prefId; |
| 64 |
this.customTokens = customTokens; |
| 65 |
} |
| 66 |
|
| 67 |
public AuthenticatorDescription(String type, String packageName, int labelId, int iconId, |
| 68 |
int smallIconId, int prefId) { |
| 69 |
this(type, packageName, labelId, iconId, smallIconId, prefId, false); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
public static AuthenticatorDescription newKey(String type) { |
| 78 |
if (type == null) throw new IllegalArgumentException("type cannot be null"); |
| 79 |
return new AuthenticatorDescription(type); |
| 80 |
} |
| 81 |
|
| 82 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 83 |
private AuthenticatorDescription(String type) { |
| 84 |
this.type = type; |
| 85 |
this.packageName = null; |
| 86 |
this.labelId = 0; |
| 87 |
this.iconId = 0; |
| 88 |
this.smallIconId = 0; |
| 89 |
this.accountPreferencesId = 0; |
| 90 |
this.customTokens = false; |
| 91 |
} |
| 92 |
|
| 93 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 94 |
private AuthenticatorDescription(Parcel source) { |
| 95 |
this.type = source.readString(); |
| 96 |
this.packageName = source.readString(); |
| 97 |
this.labelId = source.readInt(); |
| 98 |
this.iconId = source.readInt(); |
| 99 |
this.smallIconId = source.readInt(); |
| 100 |
this.accountPreferencesId = source.readInt(); |
| 101 |
this.customTokens = source.readByte() == 1; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
public int describeContents() { |
| 106 |
return 0; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
public int hashCode() { |
| 111 |
return type.hashCode(); |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
public boolean equals(@Nullable Object o) { |
| 116 |
if (o == this) return true; |
| 117 |
if (!(o instanceof AuthenticatorDescription)) return false; |
| 118 |
final AuthenticatorDescription other = (AuthenticatorDescription) o; |
| 119 |
return type.equals(other.type); |
| 120 |
} |
| 121 |
|
| 122 |
public String toString() { |
| 123 |
return "AuthenticatorDescription {type=" + type + "}"; |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
public void writeToParcel(Parcel dest, int flags) { |
| 128 |
dest.writeString(type); |
| 129 |
dest.writeString(packageName); |
| 130 |
dest.writeInt(labelId); |
| 131 |
dest.writeInt(iconId); |
| 132 |
dest.writeInt(smallIconId); |
| 133 |
dest.writeInt(accountPreferencesId); |
| 134 |
dest.writeByte((byte) (customTokens ? 1 : 0)); |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
public static final @android.annotation.NonNull Creator<AuthenticatorDescription> CREATOR = |
| 139 |
new Creator<AuthenticatorDescription>() { |
| 140 |
|
| 141 |
public AuthenticatorDescription createFromParcel(Parcel source) { |
| 142 |
return new AuthenticatorDescription(source); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
public AuthenticatorDescription[] newArray(int size) { |
| 147 |
return new AuthenticatorDescription[size]; |
| 148 |
} |
| 149 |
}; |
| 150 |
} |