| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.biometrics; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import java.util.ArrayList; |
| 25 |
import java.util.List; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class PromptInfo implements Parcelable { |
| 32 |
|
| 33 |
@NonNull private CharSequence mTitle; |
| 34 |
private boolean mUseDefaultTitle; |
| 35 |
@Nullable private CharSequence mSubtitle; |
| 36 |
@Nullable private CharSequence mDescription; |
| 37 |
@Nullable private CharSequence mDeviceCredentialTitle; |
| 38 |
@Nullable private CharSequence mDeviceCredentialSubtitle; |
| 39 |
@Nullable private CharSequence mDeviceCredentialDescription; |
| 40 |
@Nullable private CharSequence mNegativeButtonText; |
| 41 |
private boolean mConfirmationRequested = true; |
| 42 |
private boolean mDeviceCredentialAllowed; |
| 43 |
private @BiometricManager.Authenticators.Types int mAuthenticators; |
| 44 |
private boolean mDisallowBiometricsIfPolicyExists; |
| 45 |
private boolean mReceiveSystemEvents; |
| 46 |
@NonNull private List<Integer> mAllowedSensorIds = new ArrayList<>(); |
| 47 |
private boolean mAllowBackgroundAuthentication; |
| 48 |
private boolean mIgnoreEnrollmentState; |
| 49 |
private boolean mIsForLegacyFingerprintManager = false; |
| 50 |
|
| 51 |
public PromptInfo() { |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
PromptInfo(Parcel in) { |
| 56 |
mTitle = in.readCharSequence(); |
| 57 |
mUseDefaultTitle = in.readBoolean(); |
| 58 |
mSubtitle = in.readCharSequence(); |
| 59 |
mDescription = in.readCharSequence(); |
| 60 |
mDeviceCredentialTitle = in.readCharSequence(); |
| 61 |
mDeviceCredentialSubtitle = in.readCharSequence(); |
| 62 |
mDeviceCredentialDescription = in.readCharSequence(); |
| 63 |
mNegativeButtonText = in.readCharSequence(); |
| 64 |
mConfirmationRequested = in.readBoolean(); |
| 65 |
mDeviceCredentialAllowed = in.readBoolean(); |
| 66 |
mAuthenticators = in.readInt(); |
| 67 |
mDisallowBiometricsIfPolicyExists = in.readBoolean(); |
| 68 |
mReceiveSystemEvents = in.readBoolean(); |
| 69 |
mAllowedSensorIds = in.readArrayList(Integer.class.getClassLoader(), java.lang.Integer.class); |
| 70 |
mAllowBackgroundAuthentication = in.readBoolean(); |
| 71 |
mIgnoreEnrollmentState = in.readBoolean(); |
| 72 |
mIsForLegacyFingerprintManager = in.readBoolean(); |
| 73 |
} |
| 74 |
|
| 75 |
public static final Creator<PromptInfo> CREATOR = new Creator<PromptInfo>() { |
| 76 |
@Override |
| 77 |
public PromptInfo createFromParcel(Parcel in) { |
| 78 |
return new PromptInfo(in); |
| 79 |
} |
| 80 |
|
| 81 |
@Override |
| 82 |
public PromptInfo[] newArray(int size) { |
| 83 |
return new PromptInfo[size]; |
| 84 |
} |
| 85 |
}; |
| 86 |
|
| 87 |
@Override |
| 88 |
public int describeContents() { |
| 89 |
return 0; |
| 90 |
} |
| 91 |
|
| 92 |
@Override |
| 93 |
public void writeToParcel(Parcel dest, int flags) { |
| 94 |
dest.writeCharSequence(mTitle); |
| 95 |
dest.writeBoolean(mUseDefaultTitle); |
| 96 |
dest.writeCharSequence(mSubtitle); |
| 97 |
dest.writeCharSequence(mDescription); |
| 98 |
dest.writeCharSequence(mDeviceCredentialTitle); |
| 99 |
dest.writeCharSequence(mDeviceCredentialSubtitle); |
| 100 |
dest.writeCharSequence(mDeviceCredentialDescription); |
| 101 |
dest.writeCharSequence(mNegativeButtonText); |
| 102 |
dest.writeBoolean(mConfirmationRequested); |
| 103 |
dest.writeBoolean(mDeviceCredentialAllowed); |
| 104 |
dest.writeInt(mAuthenticators); |
| 105 |
dest.writeBoolean(mDisallowBiometricsIfPolicyExists); |
| 106 |
dest.writeBoolean(mReceiveSystemEvents); |
| 107 |
dest.writeList(mAllowedSensorIds); |
| 108 |
dest.writeBoolean(mAllowBackgroundAuthentication); |
| 109 |
dest.writeBoolean(mIgnoreEnrollmentState); |
| 110 |
dest.writeBoolean(mIsForLegacyFingerprintManager); |
| 111 |
} |
| 112 |
|
| 113 |
public boolean containsTestConfigurations() { |
| 114 |
if (mIsForLegacyFingerprintManager |
| 115 |
&& mAllowedSensorIds.size() == 1 |
| 116 |
&& !mAllowBackgroundAuthentication) { |
| 117 |
return false; |
| 118 |
} else if (!mAllowedSensorIds.isEmpty()) { |
| 119 |
return true; |
| 120 |
} else if (mAllowBackgroundAuthentication) { |
| 121 |
return true; |
| 122 |
} |
| 123 |
return false; |
| 124 |
} |
| 125 |
|
| 126 |
public boolean containsPrivateApiConfigurations() { |
| 127 |
if (mDisallowBiometricsIfPolicyExists) { |
| 128 |
return true; |
| 129 |
} else if (mUseDefaultTitle) { |
| 130 |
return true; |
| 131 |
} else if (mDeviceCredentialTitle != null) { |
| 132 |
return true; |
| 133 |
} else if (mDeviceCredentialSubtitle != null) { |
| 134 |
return true; |
| 135 |
} else if (mDeviceCredentialDescription != null) { |
| 136 |
return true; |
| 137 |
} else if (mReceiveSystemEvents) { |
| 138 |
return true; |
| 139 |
} |
| 140 |
return false; |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
public void setTitle(CharSequence title) { |
| 146 |
mTitle = title; |
| 147 |
} |
| 148 |
|
| 149 |
public void setUseDefaultTitle(boolean useDefaultTitle) { |
| 150 |
mUseDefaultTitle = useDefaultTitle; |
| 151 |
} |
| 152 |
|
| 153 |
public void setSubtitle(CharSequence subtitle) { |
| 154 |
mSubtitle = subtitle; |
| 155 |
} |
| 156 |
|
| 157 |
public void setDescription(CharSequence description) { |
| 158 |
mDescription = description; |
| 159 |
} |
| 160 |
|
| 161 |
public void setDeviceCredentialTitle(CharSequence deviceCredentialTitle) { |
| 162 |
mDeviceCredentialTitle = deviceCredentialTitle; |
| 163 |
} |
| 164 |
|
| 165 |
public void setDeviceCredentialSubtitle(CharSequence deviceCredentialSubtitle) { |
| 166 |
mDeviceCredentialSubtitle = deviceCredentialSubtitle; |
| 167 |
} |
| 168 |
|
| 169 |
public void setDeviceCredentialDescription(CharSequence deviceCredentialDescription) { |
| 170 |
mDeviceCredentialDescription = deviceCredentialDescription; |
| 171 |
} |
| 172 |
|
| 173 |
public void setNegativeButtonText(CharSequence negativeButtonText) { |
| 174 |
mNegativeButtonText = negativeButtonText; |
| 175 |
} |
| 176 |
|
| 177 |
public void setConfirmationRequested(boolean confirmationRequested) { |
| 178 |
mConfirmationRequested = confirmationRequested; |
| 179 |
} |
| 180 |
|
| 181 |
public void setDeviceCredentialAllowed(boolean deviceCredentialAllowed) { |
| 182 |
mDeviceCredentialAllowed = deviceCredentialAllowed; |
| 183 |
} |
| 184 |
|
| 185 |
public void setAuthenticators(int authenticators) { |
| 186 |
mAuthenticators = authenticators; |
| 187 |
} |
| 188 |
|
| 189 |
public void setDisallowBiometricsIfPolicyExists(boolean disallowBiometricsIfPolicyExists) { |
| 190 |
mDisallowBiometricsIfPolicyExists = disallowBiometricsIfPolicyExists; |
| 191 |
} |
| 192 |
|
| 193 |
public void setReceiveSystemEvents(boolean receiveSystemEvents) { |
| 194 |
mReceiveSystemEvents = receiveSystemEvents; |
| 195 |
} |
| 196 |
|
| 197 |
public void setAllowedSensorIds(@NonNull List<Integer> sensorIds) { |
| 198 |
mAllowedSensorIds.clear(); |
| 199 |
mAllowedSensorIds.addAll(sensorIds); |
| 200 |
} |
| 201 |
|
| 202 |
public void setAllowBackgroundAuthentication(boolean allow) { |
| 203 |
mAllowBackgroundAuthentication = allow; |
| 204 |
} |
| 205 |
|
| 206 |
public void setIgnoreEnrollmentState(boolean ignoreEnrollmentState) { |
| 207 |
mIgnoreEnrollmentState = ignoreEnrollmentState; |
| 208 |
} |
| 209 |
|
| 210 |
public void setIsForLegacyFingerprintManager(int sensorId) { |
| 211 |
mIsForLegacyFingerprintManager = true; |
| 212 |
mAllowedSensorIds.clear(); |
| 213 |
mAllowedSensorIds.add(sensorId); |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
public CharSequence getTitle() { |
| 219 |
return mTitle; |
| 220 |
} |
| 221 |
|
| 222 |
public boolean isUseDefaultTitle() { |
| 223 |
return mUseDefaultTitle; |
| 224 |
} |
| 225 |
|
| 226 |
public CharSequence getSubtitle() { |
| 227 |
return mSubtitle; |
| 228 |
} |
| 229 |
|
| 230 |
public CharSequence getDescription() { |
| 231 |
return mDescription; |
| 232 |
} |
| 233 |
|
| 234 |
public CharSequence getDeviceCredentialTitle() { |
| 235 |
return mDeviceCredentialTitle; |
| 236 |
} |
| 237 |
|
| 238 |
public CharSequence getDeviceCredentialSubtitle() { |
| 239 |
return mDeviceCredentialSubtitle; |
| 240 |
} |
| 241 |
|
| 242 |
public CharSequence getDeviceCredentialDescription() { |
| 243 |
return mDeviceCredentialDescription; |
| 244 |
} |
| 245 |
|
| 246 |
public CharSequence getNegativeButtonText() { |
| 247 |
return mNegativeButtonText; |
| 248 |
} |
| 249 |
|
| 250 |
public boolean isConfirmationRequested() { |
| 251 |
return mConfirmationRequested; |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
@Deprecated |
| 261 |
public boolean isDeviceCredentialAllowed() { |
| 262 |
return mDeviceCredentialAllowed; |
| 263 |
} |
| 264 |
|
| 265 |
public int getAuthenticators() { |
| 266 |
return mAuthenticators; |
| 267 |
} |
| 268 |
|
| 269 |
public boolean isDisallowBiometricsIfPolicyExists() { |
| 270 |
return mDisallowBiometricsIfPolicyExists; |
| 271 |
} |
| 272 |
|
| 273 |
public boolean isReceiveSystemEvents() { |
| 274 |
return mReceiveSystemEvents; |
| 275 |
} |
| 276 |
|
| 277 |
@NonNull |
| 278 |
public List<Integer> getAllowedSensorIds() { |
| 279 |
return mAllowedSensorIds; |
| 280 |
} |
| 281 |
|
| 282 |
public boolean isAllowBackgroundAuthentication() { |
| 283 |
return mAllowBackgroundAuthentication; |
| 284 |
} |
| 285 |
|
| 286 |
public boolean isIgnoreEnrollmentState() { |
| 287 |
return mIgnoreEnrollmentState; |
| 288 |
} |
| 289 |
|
| 290 |
public boolean isForLegacyFingerprintManager() { |
| 291 |
return mIsForLegacyFingerprintManager; |
| 292 |
} |
| 293 |
} |