| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.security.attestationverification; |
| 18 |
|
| 19 |
import static android.security.attestationverification.AttestationVerificationManager.PROFILE_APP_DEFINED; |
| 20 |
import static android.security.attestationverification.AttestationVerificationManager.PROFILE_UNKNOWN; |
| 21 |
|
| 22 |
import android.annotation.NonNull; |
| 23 |
import android.annotation.Nullable; |
| 24 |
import android.os.Parcelable; |
| 25 |
import android.security.attestationverification.AttestationVerificationManager.AttestationProfileId; |
| 26 |
import android.util.Log; |
| 27 |
|
| 28 |
import com.android.internal.util.DataClass; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
@DataClass( |
| 43 |
genConstructor = false, |
| 44 |
genEqualsHashCode = true |
| 45 |
) |
| 46 |
public final class AttestationProfile implements Parcelable { |
| 47 |
|
| 48 |
private static final String TAG = "AVF"; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
@AttestationProfileId |
| 58 |
private final int mAttestationProfileId; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
@Nullable |
| 67 |
private final String mPackageName; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
@Nullable |
| 77 |
private final String mProfileName; |
| 78 |
|
| 79 |
private AttestationProfile( |
| 80 |
@AttestationProfileId int attestationProfileId, |
| 81 |
@Nullable String packageName, |
| 82 |
@Nullable String profileName) { |
| 83 |
mAttestationProfileId = attestationProfileId; |
| 84 |
mPackageName = packageName; |
| 85 |
mProfileName = profileName; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
public AttestationProfile(@AttestationProfileId int attestationProfileId) { |
| 101 |
this(attestationProfileId, null, null); |
| 102 |
if (attestationProfileId == PROFILE_APP_DEFINED) { |
| 103 |
throw new IllegalArgumentException("App-defined profiles must be specified with the " |
| 104 |
+ "constructor AttestationProfile#constructor(String, String)"); |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public AttestationProfile(@NonNull String packageName, @NonNull String profileName) { |
| 125 |
this(PROFILE_APP_DEFINED, packageName, profileName); |
| 126 |
if (packageName == null || profileName == null) { |
| 127 |
throw new IllegalArgumentException("Both packageName and profileName must be non-null"); |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
@Override |
| 132 |
public String toString() { |
| 133 |
if (mAttestationProfileId == PROFILE_APP_DEFINED) { |
| 134 |
return "AttestationProfile(package=" + mPackageName + ", name=" + mProfileName + ")"; |
| 135 |
} else { |
| 136 |
String humanReadableProfileId; |
| 137 |
switch (mAttestationProfileId) { |
| 138 |
case PROFILE_UNKNOWN: |
| 139 |
humanReadableProfileId = "PROFILE_UNKNOWN"; |
| 140 |
break; |
| 141 |
default: |
| 142 |
Log.e(TAG, "ERROR: Missing case in AttestationProfile#toString"); |
| 143 |
humanReadableProfileId = "ERROR"; |
| 144 |
} |
| 145 |
return "AttestationProfile(" + humanReadableProfileId + "/" + mAttestationProfileId |
| 146 |
+ ")"; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
@DataClass.Generated.Member |
| 173 |
public @AttestationProfileId int getAttestationProfileId() { |
| 174 |
return mAttestationProfileId; |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
@DataClass.Generated.Member |
| 184 |
public @Nullable String getPackageName() { |
| 185 |
return mPackageName; |
| 186 |
} |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
@DataClass.Generated.Member |
| 195 |
public @Nullable String getProfileName() { |
| 196 |
return mProfileName; |
| 197 |
} |
| 198 |
|
| 199 |
@Override |
| 200 |
@DataClass.Generated.Member |
| 201 |
public boolean equals(@Nullable Object o) { |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
if (this == o) return true; |
| 207 |
if (o == null || getClass() != o.getClass()) return false; |
| 208 |
@SuppressWarnings("unchecked") |
| 209 |
AttestationProfile that = (AttestationProfile) o; |
| 210 |
|
| 211 |
return true |
| 212 |
&& mAttestationProfileId == that.mAttestationProfileId |
| 213 |
&& java.util.Objects.equals(mPackageName, that.mPackageName) |
| 214 |
&& java.util.Objects.equals(mProfileName, that.mProfileName); |
| 215 |
} |
| 216 |
|
| 217 |
@Override |
| 218 |
@DataClass.Generated.Member |
| 219 |
public int hashCode() { |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
int _hash = 1; |
| 224 |
_hash = 31 * _hash + mAttestationProfileId; |
| 225 |
_hash = 31 * _hash + java.util.Objects.hashCode(mPackageName); |
| 226 |
_hash = 31 * _hash + java.util.Objects.hashCode(mProfileName); |
| 227 |
return _hash; |
| 228 |
} |
| 229 |
|
| 230 |
@Override |
| 231 |
@DataClass.Generated.Member |
| 232 |
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
byte flg = 0; |
| 237 |
if (mPackageName != null) flg |= 0x2; |
| 238 |
if (mProfileName != null) flg |= 0x4; |
| 239 |
dest.writeByte(flg); |
| 240 |
dest.writeInt(mAttestationProfileId); |
| 241 |
if (mPackageName != null) dest.writeString(mPackageName); |
| 242 |
if (mProfileName != null) dest.writeString(mProfileName); |
| 243 |
} |
| 244 |
|
| 245 |
@Override |
| 246 |
@DataClass.Generated.Member |
| 247 |
public int describeContents() { return 0; } |
| 248 |
|
| 249 |
|
| 250 |
@SuppressWarnings({"unchecked", "RedundantCast"}) |
| 251 |
@DataClass.Generated.Member |
| 252 |
AttestationProfile(@NonNull android.os.Parcel in) { |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
byte flg = in.readByte(); |
| 257 |
int attestationProfileId = in.readInt(); |
| 258 |
String packageName = (flg & 0x2) == 0 ? null : in.readString(); |
| 259 |
String profileName = (flg & 0x4) == 0 ? null : in.readString(); |
| 260 |
|
| 261 |
this.mAttestationProfileId = attestationProfileId; |
| 262 |
com.android.internal.util.AnnotationValidations.validate( |
| 263 |
AttestationProfileId.class, null, mAttestationProfileId); |
| 264 |
this.mPackageName = packageName; |
| 265 |
this.mProfileName = profileName; |
| 266 |
|
| 267 |
|
| 268 |
} |
| 269 |
|
| 270 |
@DataClass.Generated.Member |
| 271 |
public static final @NonNull Parcelable.Creator<AttestationProfile> CREATOR |
| 272 |
= new Parcelable.Creator<AttestationProfile>() { |
| 273 |
@Override |
| 274 |
public AttestationProfile[] newArray(int size) { |
| 275 |
return new AttestationProfile[size]; |
| 276 |
} |
| 277 |
|
| 278 |
@Override |
| 279 |
public AttestationProfile createFromParcel(@NonNull android.os.Parcel in) { |
| 280 |
return new AttestationProfile(in); |
| 281 |
} |
| 282 |
}; |
| 283 |
|
| 284 |
@DataClass.Generated( |
| 285 |
time = 1633629498403L, |
| 286 |
codegenVersion = "1.0.23", |
| 287 |
sourceFile = "frameworks/base/core/java/android/security/attestationverification/AttestationProfile.java", |
| 288 |
inputSignatures = "private static final java.lang.String TAG\nprivate final @android.security.attestationverification.AttestationVerificationManager.AttestationProfileId int mAttestationProfileId\nprivate final @android.annotation.Nullable java.lang.String mPackageName\nprivate final @android.annotation.Nullable java.lang.String mProfileName\npublic @java.lang.Override java.lang.String toString()\nclass AttestationProfile extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genEqualsHashCode=true)") |
| 289 |
@Deprecated |
| 290 |
private void __metadata() {} |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
} |