1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.hardware.biometrics.events; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.hardware.biometrics.BiometricRequestConstants; 22 import android.hardware.biometrics.BiometricSourceType; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 26 import com.android.internal.util.DataClass; 27 28 /** 29 * Information about a successful biometric authentication. 30 * @hide 31 */ 32 @DataClass( 33 genParcelable = true, 34 genAidl = true, 35 genBuilder = true, 36 genSetters = true, 37 genEqualsHashCode = true 38 ) 39 public final class AuthenticationSucceededInfo implements Parcelable { 40 /** Identifies {@link BiometricSourceType} of authentication. */ 41 @NonNull 42 private final BiometricSourceType mBiometricSourceType; 43 44 /** Indicates reason from {@link BiometricRequestConstants.RequestReason} for 45 * requesting authentication. */ 46 @BiometricRequestConstants.RequestReason 47 private final int mRequestReason; 48 49 /** 50 * Indicates whether auth was from strong biometric. 51 */ 52 private final boolean mIsStrongBiometric; 53 54 /** 55 * The user id for the requested authentication 56 */ 57 private final int mUserId; 58 59 60 61 // Code below generated by codegen v1.0.23. 62 // 63 // DO NOT MODIFY! 64 // CHECKSTYLE:OFF Generated code 65 // 66 // To regenerate run: 67 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/hardware/biometrics/events/AuthenticationSucceededInfo.java 68 // 69 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 70 // Settings > Editor > Code Style > Formatter Control 71 //@formatter:off 72 73 74 @DataClass.Generated.Member AuthenticationSucceededInfo( @onNull BiometricSourceType biometricSourceType, @BiometricRequestConstants.RequestReason int requestReason, boolean isStrongBiometric, int userId)75 /* package-private */ AuthenticationSucceededInfo( 76 @NonNull BiometricSourceType biometricSourceType, 77 @BiometricRequestConstants.RequestReason int requestReason, 78 boolean isStrongBiometric, 79 int userId) { 80 this.mBiometricSourceType = biometricSourceType; 81 com.android.internal.util.AnnotationValidations.validate( 82 NonNull.class, null, mBiometricSourceType); 83 this.mRequestReason = requestReason; 84 com.android.internal.util.AnnotationValidations.validate( 85 BiometricRequestConstants.RequestReason.class, null, mRequestReason); 86 this.mIsStrongBiometric = isStrongBiometric; 87 this.mUserId = userId; 88 89 // onConstructed(); // You can define this method to get a callback 90 } 91 92 /** 93 * Identifies {@link BiometricSourceType} of authentication. 94 */ 95 @DataClass.Generated.Member getBiometricSourceType()96 public @NonNull BiometricSourceType getBiometricSourceType() { 97 return mBiometricSourceType; 98 } 99 100 /** 101 * Indicates reason from {@link BiometricRequestConstants.RequestReason} for 102 * requesting authentication. 103 */ 104 @DataClass.Generated.Member getRequestReason()105 public @BiometricRequestConstants.RequestReason int getRequestReason() { 106 return mRequestReason; 107 } 108 109 /** 110 * Indicates whether auth was from strong biometric. 111 */ 112 @DataClass.Generated.Member isIsStrongBiometric()113 public boolean isIsStrongBiometric() { 114 return mIsStrongBiometric; 115 } 116 117 /** 118 * The user id for the requested authentication 119 */ 120 @DataClass.Generated.Member getUserId()121 public int getUserId() { 122 return mUserId; 123 } 124 125 @Override 126 @DataClass.Generated.Member equals(@ullable Object o)127 public boolean equals(@Nullable Object o) { 128 // You can override field equality logic by defining either of the methods like: 129 // boolean fieldNameEquals(AuthenticationSucceededInfo other) { ... } 130 // boolean fieldNameEquals(FieldType otherValue) { ... } 131 132 if (this == o) return true; 133 if (o == null || getClass() != o.getClass()) return false; 134 @SuppressWarnings("unchecked") 135 AuthenticationSucceededInfo that = (AuthenticationSucceededInfo) o; 136 //noinspection PointlessBooleanExpression 137 return true 138 && java.util.Objects.equals(mBiometricSourceType, that.mBiometricSourceType) 139 && mRequestReason == that.mRequestReason 140 && mIsStrongBiometric == that.mIsStrongBiometric 141 && mUserId == that.mUserId; 142 } 143 144 @Override 145 @DataClass.Generated.Member hashCode()146 public int hashCode() { 147 // You can override field hashCode logic by defining methods like: 148 // int fieldNameHashCode() { ... } 149 150 int _hash = 1; 151 _hash = 31 * _hash + java.util.Objects.hashCode(mBiometricSourceType); 152 _hash = 31 * _hash + mRequestReason; 153 _hash = 31 * _hash + Boolean.hashCode(mIsStrongBiometric); 154 _hash = 31 * _hash + mUserId; 155 return _hash; 156 } 157 158 @Override 159 @DataClass.Generated.Member writeToParcel(@onNull Parcel dest, int flags)160 public void writeToParcel(@NonNull Parcel dest, int flags) { 161 // You can override field parcelling by defining methods like: 162 // void parcelFieldName(Parcel dest, int flags) { ... } 163 164 byte flg = 0; 165 if (mIsStrongBiometric) flg |= 0x4; 166 dest.writeByte(flg); 167 dest.writeTypedObject(mBiometricSourceType, flags); 168 dest.writeInt(mRequestReason); 169 dest.writeInt(mUserId); 170 } 171 172 @Override 173 @DataClass.Generated.Member describeContents()174 public int describeContents() { return 0; } 175 176 /** @hide */ 177 @SuppressWarnings({"unchecked", "RedundantCast"}) 178 @DataClass.Generated.Member AuthenticationSucceededInfo(@onNull Parcel in)179 /* package-private */ AuthenticationSucceededInfo(@NonNull Parcel in) { 180 // You can override field unparcelling by defining methods like: 181 // static FieldType unparcelFieldName(Parcel in) { ... } 182 183 byte flg = in.readByte(); 184 boolean isStrongBiometric = (flg & 0x4) != 0; 185 BiometricSourceType biometricSourceType = (BiometricSourceType) in.readTypedObject(BiometricSourceType.CREATOR); 186 int requestReason = in.readInt(); 187 int userId = in.readInt(); 188 189 this.mBiometricSourceType = biometricSourceType; 190 com.android.internal.util.AnnotationValidations.validate( 191 NonNull.class, null, mBiometricSourceType); 192 this.mRequestReason = requestReason; 193 com.android.internal.util.AnnotationValidations.validate( 194 BiometricRequestConstants.RequestReason.class, null, mRequestReason); 195 this.mIsStrongBiometric = isStrongBiometric; 196 this.mUserId = userId; 197 198 // onConstructed(); // You can define this method to get a callback 199 } 200 201 @DataClass.Generated.Member 202 public static final @NonNull Parcelable.Creator<AuthenticationSucceededInfo> CREATOR 203 = new Parcelable.Creator<AuthenticationSucceededInfo>() { 204 @Override 205 public AuthenticationSucceededInfo[] newArray(int size) { 206 return new AuthenticationSucceededInfo[size]; 207 } 208 209 @Override 210 public AuthenticationSucceededInfo createFromParcel(@NonNull Parcel in) { 211 return new AuthenticationSucceededInfo(in); 212 } 213 }; 214 215 /** 216 * A builder for {@link AuthenticationSucceededInfo} 217 */ 218 @SuppressWarnings("WeakerAccess") 219 @DataClass.Generated.Member 220 public static final class Builder { 221 222 private @NonNull BiometricSourceType mBiometricSourceType; 223 private @BiometricRequestConstants.RequestReason int mRequestReason; 224 private boolean mIsStrongBiometric; 225 private int mUserId; 226 227 private long mBuilderFieldsSet = 0L; 228 229 /** 230 * Creates a new Builder. 231 * 232 * @param biometricSourceType 233 * Identifies {@link BiometricSourceType} of authentication. 234 * @param requestReason 235 * Indicates reason from {@link BiometricRequestConstants.RequestReason} for 236 * requesting authentication. 237 * @param isStrongBiometric 238 * Indicates whether auth was from strong biometric. 239 * @param userId 240 * The user id for the requested authentication 241 */ Builder( @onNull BiometricSourceType biometricSourceType, @BiometricRequestConstants.RequestReason int requestReason, boolean isStrongBiometric, int userId)242 public Builder( 243 @NonNull BiometricSourceType biometricSourceType, 244 @BiometricRequestConstants.RequestReason int requestReason, 245 boolean isStrongBiometric, 246 int userId) { 247 mBiometricSourceType = biometricSourceType; 248 com.android.internal.util.AnnotationValidations.validate( 249 NonNull.class, null, mBiometricSourceType); 250 mRequestReason = requestReason; 251 com.android.internal.util.AnnotationValidations.validate( 252 BiometricRequestConstants.RequestReason.class, null, mRequestReason); 253 mIsStrongBiometric = isStrongBiometric; 254 mUserId = userId; 255 } 256 257 /** 258 * Identifies {@link BiometricSourceType} of authentication. 259 */ 260 @DataClass.Generated.Member setBiometricSourceType(@onNull BiometricSourceType value)261 public @NonNull Builder setBiometricSourceType(@NonNull BiometricSourceType value) { 262 checkNotUsed(); 263 mBuilderFieldsSet |= 0x1; 264 mBiometricSourceType = value; 265 return this; 266 } 267 268 /** 269 * Indicates reason from {@link BiometricRequestConstants.RequestReason} for 270 * requesting authentication. 271 */ 272 @DataClass.Generated.Member setRequestReason(@iometricRequestConstants.RequestReason int value)273 public @NonNull Builder setRequestReason(@BiometricRequestConstants.RequestReason int value) { 274 checkNotUsed(); 275 mBuilderFieldsSet |= 0x2; 276 mRequestReason = value; 277 return this; 278 } 279 280 /** 281 * Indicates whether auth was from strong biometric. 282 */ 283 @DataClass.Generated.Member setIsStrongBiometric(boolean value)284 public @NonNull Builder setIsStrongBiometric(boolean value) { 285 checkNotUsed(); 286 mBuilderFieldsSet |= 0x4; 287 mIsStrongBiometric = value; 288 return this; 289 } 290 291 /** 292 * The user id for the requested authentication 293 */ 294 @DataClass.Generated.Member setUserId(int value)295 public @NonNull Builder setUserId(int value) { 296 checkNotUsed(); 297 mBuilderFieldsSet |= 0x8; 298 mUserId = value; 299 return this; 300 } 301 302 /** Builds the instance. This builder should not be touched after calling this! */ build()303 public @NonNull AuthenticationSucceededInfo build() { 304 checkNotUsed(); 305 mBuilderFieldsSet |= 0x10; // Mark builder used 306 307 AuthenticationSucceededInfo o = new AuthenticationSucceededInfo( 308 mBiometricSourceType, 309 mRequestReason, 310 mIsStrongBiometric, 311 mUserId); 312 return o; 313 } 314 checkNotUsed()315 private void checkNotUsed() { 316 if ((mBuilderFieldsSet & 0x10) != 0) { 317 throw new IllegalStateException( 318 "This Builder should not be reused. Use a new Builder instance instead"); 319 } 320 } 321 } 322 323 @DataClass.Generated( 324 time = 1713305509212L, 325 codegenVersion = "1.0.23", 326 sourceFile = "frameworks/base/core/java/android/hardware/biometrics/events/AuthenticationSucceededInfo.java", 327 inputSignatures = "private final @android.annotation.NonNull android.hardware.biometrics.BiometricSourceType mBiometricSourceType\nprivate final @android.hardware.biometrics.BiometricRequestConstants.RequestReason int mRequestReason\nprivate final boolean mIsStrongBiometric\nprivate final int mUserId\nclass AuthenticationSucceededInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genParcelable=true, genAidl=true, genBuilder=true, genSetters=true, genEqualsHashCode=true)") 328 @Deprecated __metadata()329 private void __metadata() {} 330 331 332 //@formatter:on 333 // End of generated code 334 335 } 336