Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
package androidx.biometric;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.biometric.BiometricPrompt;
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
/* loaded from: classes.dex */
class AuthenticationCallbackProvider {
@Nullable
private android.hardware.biometrics.BiometricPrompt$AuthenticationCallback mBiometricCallback;
@Nullable
private FingerprintManagerCompat.AuthenticationCallback mFingerprintCallback;
@NonNull
final Listener mListener;
public static class Listener {
public void onError(int i, @Nullable CharSequence charSequence) {
}
public void onFailure() {
}
public void onHelp(@Nullable CharSequence charSequence) {
}
public void onSuccess(@NonNull BiometricPrompt.AuthenticationResult authenticationResult) {
}
}
public AuthenticationCallbackProvider(@NonNull Listener listener) {
this.mListener = listener;
}
@NonNull
@RequiresApi(28)
public android.hardware.biometrics.BiometricPrompt$AuthenticationCallback getBiometricCallback() {
if (this.mBiometricCallback == null) {
this.mBiometricCallback = Api28Impl.createCallback(this.mListener);
}
return this.mBiometricCallback;
}
@NonNull
public FingerprintManagerCompat.AuthenticationCallback getFingerprintCallback() {
if (this.mFingerprintCallback == null) {
this.mFingerprintCallback = new FingerprintManagerCompat.AuthenticationCallback() { // from class: androidx.biometric.AuthenticationCallbackProvider.1
@Override // androidx.core.hardware.fingerprint.FingerprintManagerCompat.AuthenticationCallback
public void onAuthenticationError(int i, CharSequence charSequence) {
AuthenticationCallbackProvider.this.mListener.onError(i, charSequence);
}
@Override // androidx.core.hardware.fingerprint.FingerprintManagerCompat.AuthenticationCallback
public void onAuthenticationHelp(int i, CharSequence charSequence) {
AuthenticationCallbackProvider.this.mListener.onHelp(charSequence);
}
@Override // androidx.core.hardware.fingerprint.FingerprintManagerCompat.AuthenticationCallback
public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult authenticationResult) {
AuthenticationCallbackProvider.this.mListener.onSuccess(new BiometricPrompt.AuthenticationResult(authenticationResult != null ? CryptoObjectUtils.unwrapFromFingerprintManager(authenticationResult.getCryptoObject()) : null, 2));
}
@Override // androidx.core.hardware.fingerprint.FingerprintManagerCompat.AuthenticationCallback
public void onAuthenticationFailed() {
AuthenticationCallbackProvider.this.mListener.onFailure();
}
};
}
return this.mFingerprintCallback;
}
@RequiresApi(30)
public static class Api30Impl {
private Api30Impl() {
}
public static int getAuthenticationType(@NonNull BiometricPrompt.AuthenticationResult authenticationResult) {
return authenticationResult.getAuthenticationType();
}
}
@RequiresApi(28)
public static class Api28Impl {
private Api28Impl() {
}
@NonNull
public static android.hardware.biometrics.BiometricPrompt$AuthenticationCallback createCallback(@NonNull final Listener listener) {
return new android.hardware.biometrics.BiometricPrompt$AuthenticationCallback() { // from class: androidx.biometric.AuthenticationCallbackProvider.Api28Impl.1
public void onAuthenticationHelp(int i, CharSequence charSequence) {
}
public void onAuthenticationError(int i, CharSequence charSequence) {
Listener.this.onError(i, charSequence);
}
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult authenticationResult) {
BiometricPrompt.CryptoObject unwrapFromBiometricPrompt = authenticationResult != null ? CryptoObjectUtils.unwrapFromBiometricPrompt(authenticationResult.getCryptoObject()) : null;
int i = Build.VERSION.SDK_INT;
int i2 = -1;
if (i >= 30) {
if (authenticationResult != null) {
i2 = Api30Impl.getAuthenticationType(authenticationResult);
}
} else if (i != 29) {
i2 = 2;
}
Listener.this.onSuccess(new BiometricPrompt.AuthenticationResult(unwrapFromBiometricPrompt, i2));
}
public void onAuthenticationFailed() {
Listener.this.onFailure();
}
};
}
}
}

View File

@@ -0,0 +1,52 @@
package androidx.biometric;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.biometric.BiometricPrompt;
/* loaded from: classes.dex */
class AuthenticatorUtils {
private static final int BIOMETRIC_CLASS_MASK = 32767;
public static boolean isDeviceCredentialAllowed(int i) {
return (i & 32768) != 0;
}
public static boolean isSomeBiometricAllowed(int i) {
return (i & BIOMETRIC_CLASS_MASK) != 0;
}
public static boolean isSupportedCombination(int i) {
if (i == 15 || i == 255) {
return true;
}
if (i == 32768) {
return Build.VERSION.SDK_INT >= 30;
}
if (i != 32783) {
return i == 33023 || i == 0;
}
int i2 = Build.VERSION.SDK_INT;
return i2 < 28 || i2 > 29;
}
public static boolean isWeakBiometricAllowed(int i) {
return (i & 255) == 255;
}
private AuthenticatorUtils() {
}
public static String convertToString(int i) {
return i != 15 ? i != 255 ? i != 32768 ? i != 32783 ? i != 33023 ? String.valueOf(i) : "BIOMETRIC_WEAK | DEVICE_CREDENTIAL" : "BIOMETRIC_STRONG | DEVICE_CREDENTIAL" : "DEVICE_CREDENTIAL" : "BIOMETRIC_WEAK" : "BIOMETRIC_STRONG";
}
public static int getConsolidatedAuthenticators(@NonNull BiometricPrompt.PromptInfo promptInfo, @Nullable BiometricPrompt.CryptoObject cryptoObject) {
if (promptInfo.getAllowedAuthenticators() != 0) {
return promptInfo.getAllowedAuthenticators();
}
int i = cryptoObject != null ? 15 : 255;
return promptInfo.isDeviceCredentialAllowed() ? 32768 | i : i;
}
}

View File

@@ -0,0 +1,52 @@
package androidx.biometric;
import androidx.annotation.Nullable;
import java.util.Arrays;
/* loaded from: classes.dex */
class BiometricErrorData {
private final int mErrorCode;
@Nullable
private final CharSequence mErrorMessage;
public int getErrorCode() {
return this.mErrorCode;
}
@Nullable
public CharSequence getErrorMessage() {
return this.mErrorMessage;
}
public BiometricErrorData(int i, @Nullable CharSequence charSequence) {
this.mErrorCode = i;
this.mErrorMessage = charSequence;
}
public int hashCode() {
return Arrays.hashCode(new Object[]{Integer.valueOf(this.mErrorCode), convertToString(this.mErrorMessage)});
}
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof BiometricErrorData)) {
return false;
}
BiometricErrorData biometricErrorData = (BiometricErrorData) obj;
return this.mErrorCode == biometricErrorData.mErrorCode && isErrorMessageEqualTo(biometricErrorData.mErrorMessage);
}
private boolean isErrorMessageEqualTo(@Nullable CharSequence charSequence) {
String convertToString = convertToString(this.mErrorMessage);
String convertToString2 = convertToString(charSequence);
return (convertToString == null && convertToString2 == null) || (convertToString != null && convertToString.equals(convertToString2));
}
@Nullable
private static String convertToString(@Nullable CharSequence charSequence) {
if (charSequence != null) {
return charSequence.toString();
}
return null;
}
}

View File

@@ -0,0 +1,667 @@
package androidx.biometric;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.biometric.BiometricPrompt;
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import java.lang.ref.WeakReference;
import java.util.concurrent.Executor;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public class BiometricFragment extends Fragment {
static final int CANCELED_FROM_CLIENT = 3;
static final int CANCELED_FROM_INTERNAL = 0;
static final int CANCELED_FROM_NEGATIVE_BUTTON = 2;
static final int CANCELED_FROM_USER = 1;
private static final int DISMISS_INSTANTLY_DELAY_MS = 500;
private static final String FINGERPRINT_DIALOG_FRAGMENT_TAG = "androidx.biometric.FingerprintDialogFragment";
private static final int HIDE_DIALOG_DELAY_MS = 2000;
private static final int REQUEST_CONFIRM_CREDENTIAL = 1;
private static final int SHOW_PROMPT_DELAY_MS = 600;
private static final String TAG = "BiometricFragment";
@VisibleForTesting
Handler mHandler = new Handler(Looper.getMainLooper());
@VisibleForTesting
BiometricViewModel mViewModel;
public static class PromptExecutor implements Executor {
private final Handler mPromptHandler = new Handler(Looper.getMainLooper());
@Override // java.util.concurrent.Executor
public void execute(@NonNull Runnable runnable) {
this.mPromptHandler.post(runnable);
}
}
public static class ShowPromptForAuthenticationRunnable implements Runnable {
@NonNull
private final WeakReference<BiometricFragment> mFragmentRef;
public ShowPromptForAuthenticationRunnable(@Nullable BiometricFragment biometricFragment) {
this.mFragmentRef = new WeakReference<>(biometricFragment);
}
@Override // java.lang.Runnable
public void run() {
if (this.mFragmentRef.get() != null) {
this.mFragmentRef.get().showPromptForAuthentication();
}
}
}
public static class StopDelayingPromptRunnable implements Runnable {
@NonNull
private final WeakReference<BiometricViewModel> mViewModelRef;
public StopDelayingPromptRunnable(@Nullable BiometricViewModel biometricViewModel) {
this.mViewModelRef = new WeakReference<>(biometricViewModel);
}
@Override // java.lang.Runnable
public void run() {
if (this.mViewModelRef.get() != null) {
this.mViewModelRef.get().setDelayingPrompt(false);
}
}
}
public static class StopIgnoringCancelRunnable implements Runnable {
@NonNull
private final WeakReference<BiometricViewModel> mViewModelRef;
public StopIgnoringCancelRunnable(@Nullable BiometricViewModel biometricViewModel) {
this.mViewModelRef = new WeakReference<>(biometricViewModel);
}
@Override // java.lang.Runnable
public void run() {
if (this.mViewModelRef.get() != null) {
this.mViewModelRef.get().setIgnoringCancel(false);
}
}
}
public static BiometricFragment newInstance() {
return new BiometricFragment();
}
@Override // androidx.fragment.app.Fragment
public void onCreate(@Nullable Bundle bundle) {
super.onCreate(bundle);
connectViewModel();
}
@Override // androidx.fragment.app.Fragment
public void onStart() {
super.onStart();
if (Build.VERSION.SDK_INT == 29 && AuthenticatorUtils.isDeviceCredentialAllowed(this.mViewModel.getAllowedAuthenticators())) {
this.mViewModel.setIgnoringCancel(true);
this.mHandler.postDelayed(new StopIgnoringCancelRunnable(this.mViewModel), 250L);
}
}
@Override // androidx.fragment.app.Fragment
public void onStop() {
super.onStop();
if (Build.VERSION.SDK_INT >= 29 || this.mViewModel.isConfirmingDeviceCredential() || isChangingConfigurations()) {
return;
}
cancelAuthentication(0);
}
@Override // androidx.fragment.app.Fragment
public void onActivityResult(int i, int i2, @Nullable Intent intent) {
super.onActivityResult(i, i2, intent);
if (i == 1) {
this.mViewModel.setConfirmingDeviceCredential(false);
handleConfirmCredentialResult(i2);
}
}
private void connectViewModel() {
if (getActivity() == null) {
return;
}
BiometricViewModel biometricViewModel = (BiometricViewModel) new ViewModelProvider(getActivity()).get(BiometricViewModel.class);
this.mViewModel = biometricViewModel;
biometricViewModel.getAuthenticationResult().observe(this, new Observer<BiometricPrompt.AuthenticationResult>() { // from class: androidx.biometric.BiometricFragment.1
@Override // androidx.lifecycle.Observer
public void onChanged(BiometricPrompt.AuthenticationResult authenticationResult) {
if (authenticationResult != null) {
BiometricFragment.this.onAuthenticationSucceeded(authenticationResult);
BiometricFragment.this.mViewModel.setAuthenticationResult(null);
}
}
});
this.mViewModel.getAuthenticationError().observe(this, new Observer<BiometricErrorData>() { // from class: androidx.biometric.BiometricFragment.2
@Override // androidx.lifecycle.Observer
public void onChanged(BiometricErrorData biometricErrorData) {
if (biometricErrorData != null) {
BiometricFragment.this.onAuthenticationError(biometricErrorData.getErrorCode(), biometricErrorData.getErrorMessage());
BiometricFragment.this.mViewModel.setAuthenticationError(null);
}
}
});
this.mViewModel.getAuthenticationHelpMessage().observe(this, new Observer<CharSequence>() { // from class: androidx.biometric.BiometricFragment.3
@Override // androidx.lifecycle.Observer
public void onChanged(CharSequence charSequence) {
if (charSequence != null) {
BiometricFragment.this.onAuthenticationHelp(charSequence);
BiometricFragment.this.mViewModel.setAuthenticationError(null);
}
}
});
this.mViewModel.isAuthenticationFailurePending().observe(this, new Observer<Boolean>() { // from class: androidx.biometric.BiometricFragment.4
@Override // androidx.lifecycle.Observer
public void onChanged(Boolean bool) {
if (bool.booleanValue()) {
BiometricFragment.this.onAuthenticationFailed();
BiometricFragment.this.mViewModel.setAuthenticationFailurePending(false);
}
}
});
this.mViewModel.isNegativeButtonPressPending().observe(this, new Observer<Boolean>() { // from class: androidx.biometric.BiometricFragment.5
@Override // androidx.lifecycle.Observer
public void onChanged(Boolean bool) {
if (bool.booleanValue()) {
if (BiometricFragment.this.isManagingDeviceCredentialButton()) {
BiometricFragment.this.onDeviceCredentialButtonPressed();
} else {
BiometricFragment.this.onCancelButtonPressed();
}
BiometricFragment.this.mViewModel.setNegativeButtonPressPending(false);
}
}
});
this.mViewModel.isFingerprintDialogCancelPending().observe(this, new Observer<Boolean>() { // from class: androidx.biometric.BiometricFragment.6
@Override // androidx.lifecycle.Observer
public void onChanged(Boolean bool) {
if (bool.booleanValue()) {
BiometricFragment.this.cancelAuthentication(1);
BiometricFragment.this.dismiss();
BiometricFragment.this.mViewModel.setFingerprintDialogCancelPending(false);
}
}
});
}
public void authenticate(@NonNull BiometricPrompt.PromptInfo promptInfo, @Nullable BiometricPrompt.CryptoObject cryptoObject) {
FragmentActivity activity = getActivity();
if (activity == null) {
Log.e(TAG, "Not launching prompt. Client activity was null.");
return;
}
this.mViewModel.setPromptInfo(promptInfo);
int consolidatedAuthenticators = AuthenticatorUtils.getConsolidatedAuthenticators(promptInfo, cryptoObject);
if (Build.VERSION.SDK_INT < 30 && consolidatedAuthenticators == 15 && cryptoObject == null) {
this.mViewModel.setCryptoObject(CryptoObjectUtils.createFakeCryptoObject());
} else {
this.mViewModel.setCryptoObject(cryptoObject);
}
if (isManagingDeviceCredentialButton()) {
this.mViewModel.setNegativeButtonTextOverride(getString(R.string.confirm_device_credential_password));
} else {
this.mViewModel.setNegativeButtonTextOverride(null);
}
if (isManagingDeviceCredentialButton() && BiometricManager.from(activity).canAuthenticate(255) != 0) {
this.mViewModel.setAwaitingResult(true);
launchConfirmCredentialActivity();
} else if (this.mViewModel.isDelayingPrompt()) {
this.mHandler.postDelayed(new ShowPromptForAuthenticationRunnable(this), 600L);
} else {
showPromptForAuthentication();
}
}
public void showPromptForAuthentication() {
if (this.mViewModel.isPromptShowing()) {
return;
}
if (getContext() == null) {
Log.w(TAG, "Not showing biometric prompt. Context is null.");
return;
}
this.mViewModel.setPromptShowing(true);
this.mViewModel.setAwaitingResult(true);
if (isUsingFingerprintDialog()) {
showFingerprintDialogForAuthentication();
} else {
showBiometricPromptForAuthentication();
}
}
private void showFingerprintDialogForAuthentication() {
Context applicationContext = requireContext().getApplicationContext();
FingerprintManagerCompat from = FingerprintManagerCompat.from(applicationContext);
int checkForFingerprintPreAuthenticationErrors = checkForFingerprintPreAuthenticationErrors(from);
if (checkForFingerprintPreAuthenticationErrors != 0) {
sendErrorAndDismiss(checkForFingerprintPreAuthenticationErrors, ErrorUtils.getFingerprintErrorString(applicationContext, checkForFingerprintPreAuthenticationErrors));
return;
}
if (isAdded()) {
this.mViewModel.setFingerprintDialogDismissedInstantly(true);
if (!DeviceUtils.shouldHideFingerprintDialog(applicationContext, Build.MODEL)) {
this.mHandler.postDelayed(new Runnable() { // from class: androidx.biometric.BiometricFragment.7
@Override // java.lang.Runnable
public void run() {
BiometricFragment.this.mViewModel.setFingerprintDialogDismissedInstantly(false);
}
}, 500L);
FingerprintDialogFragment.newInstance().show(getParentFragmentManager(), FINGERPRINT_DIALOG_FRAGMENT_TAG);
}
this.mViewModel.setCanceledFrom(0);
authenticateWithFingerprint(from, applicationContext);
}
}
@RequiresApi(28)
private void showBiometricPromptForAuthentication() {
BiometricPrompt.Builder createPromptBuilder = Api28Impl.createPromptBuilder(requireContext().getApplicationContext());
CharSequence title = this.mViewModel.getTitle();
CharSequence subtitle = this.mViewModel.getSubtitle();
CharSequence description = this.mViewModel.getDescription();
if (title != null) {
Api28Impl.setTitle(createPromptBuilder, title);
}
if (subtitle != null) {
Api28Impl.setSubtitle(createPromptBuilder, subtitle);
}
if (description != null) {
Api28Impl.setDescription(createPromptBuilder, description);
}
CharSequence negativeButtonText = this.mViewModel.getNegativeButtonText();
if (!TextUtils.isEmpty(negativeButtonText)) {
Api28Impl.setNegativeButton(createPromptBuilder, negativeButtonText, this.mViewModel.getClientExecutor(), this.mViewModel.getNegativeButtonListener());
}
int i = Build.VERSION.SDK_INT;
if (i >= 29) {
Api29Impl.setConfirmationRequired(createPromptBuilder, this.mViewModel.isConfirmationRequired());
}
int allowedAuthenticators = this.mViewModel.getAllowedAuthenticators();
if (i >= 30) {
Api30Impl.setAllowedAuthenticators(createPromptBuilder, allowedAuthenticators);
} else if (i >= 29) {
Api29Impl.setDeviceCredentialAllowed(createPromptBuilder, AuthenticatorUtils.isDeviceCredentialAllowed(allowedAuthenticators));
}
authenticateWithBiometricPrompt(Api28Impl.buildPrompt(createPromptBuilder), getContext());
}
@VisibleForTesting
public void authenticateWithFingerprint(@NonNull FingerprintManagerCompat fingerprintManagerCompat, @NonNull Context context) {
try {
fingerprintManagerCompat.authenticate(CryptoObjectUtils.wrapForFingerprintManager(this.mViewModel.getCryptoObject()), 0, this.mViewModel.getCancellationSignalProvider().getFingerprintCancellationSignal(), this.mViewModel.getAuthenticationCallbackProvider().getFingerprintCallback(), (Handler) null);
} catch (NullPointerException e) {
Log.e(TAG, "Got NPE while authenticating with fingerprint.", e);
sendErrorAndDismiss(1, ErrorUtils.getFingerprintErrorString(context, 1));
}
}
@RequiresApi(28)
@VisibleForTesting
public void authenticateWithBiometricPrompt(@NonNull android.hardware.biometrics.BiometricPrompt biometricPrompt, @Nullable Context context) {
BiometricPrompt.CryptoObject wrapForBiometricPrompt = CryptoObjectUtils.wrapForBiometricPrompt(this.mViewModel.getCryptoObject());
CancellationSignal biometricCancellationSignal = this.mViewModel.getCancellationSignalProvider().getBiometricCancellationSignal();
PromptExecutor promptExecutor = new PromptExecutor();
android.hardware.biometrics.BiometricPrompt$AuthenticationCallback biometricCallback = this.mViewModel.getAuthenticationCallbackProvider().getBiometricCallback();
try {
if (wrapForBiometricPrompt == null) {
Api28Impl.authenticate(biometricPrompt, biometricCancellationSignal, promptExecutor, biometricCallback);
} else {
Api28Impl.authenticate(biometricPrompt, wrapForBiometricPrompt, biometricCancellationSignal, promptExecutor, biometricCallback);
}
} catch (NullPointerException e) {
Log.e(TAG, "Got NPE while authenticating with biometric prompt.", e);
sendErrorAndDismiss(1, context != null ? context.getString(R.string.default_error_msg) : "");
}
}
public void cancelAuthentication(int i) {
if (i == 3 || !this.mViewModel.isIgnoringCancel()) {
if (isUsingFingerprintDialog()) {
this.mViewModel.setCanceledFrom(i);
if (i == 1) {
sendErrorToClient(10, ErrorUtils.getFingerprintErrorString(getContext(), 10));
}
}
this.mViewModel.getCancellationSignalProvider().cancel();
}
}
public void dismiss() {
this.mViewModel.setPromptShowing(false);
dismissFingerprintDialog();
if (!this.mViewModel.isConfirmingDeviceCredential() && isAdded()) {
getParentFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}
Context context = getContext();
if (context == null || !DeviceUtils.shouldDelayShowingPrompt(context, Build.MODEL)) {
return;
}
this.mViewModel.setDelayingPrompt(true);
this.mHandler.postDelayed(new StopDelayingPromptRunnable(this.mViewModel), 600L);
}
private void dismissFingerprintDialog() {
this.mViewModel.setPromptShowing(false);
if (isAdded()) {
FragmentManager parentFragmentManager = getParentFragmentManager();
FingerprintDialogFragment fingerprintDialogFragment = (FingerprintDialogFragment) parentFragmentManager.findFragmentByTag(FINGERPRINT_DIALOG_FRAGMENT_TAG);
if (fingerprintDialogFragment != null) {
if (fingerprintDialogFragment.isAdded()) {
fingerprintDialogFragment.dismissAllowingStateLoss();
} else {
parentFragmentManager.beginTransaction().remove(fingerprintDialogFragment).commitAllowingStateLoss();
}
}
}
}
@VisibleForTesting
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult authenticationResult) {
sendSuccessAndDismiss(authenticationResult);
}
@VisibleForTesting
public void onAuthenticationError(final int i, @Nullable final CharSequence charSequence) {
if (!ErrorUtils.isKnownError(i)) {
i = 8;
}
Context context = getContext();
if (Build.VERSION.SDK_INT < 29 && ErrorUtils.isLockoutError(i) && context != null && KeyguardUtils.isDeviceSecuredWithCredential(context) && AuthenticatorUtils.isDeviceCredentialAllowed(this.mViewModel.getAllowedAuthenticators())) {
launchConfirmCredentialActivity();
return;
}
if (!isUsingFingerprintDialog()) {
if (charSequence == null) {
charSequence = getString(R.string.default_error_msg) + " " + i;
}
sendErrorAndDismiss(i, charSequence);
return;
}
if (charSequence == null) {
charSequence = ErrorUtils.getFingerprintErrorString(getContext(), i);
}
if (i == 5) {
int canceledFrom = this.mViewModel.getCanceledFrom();
if (canceledFrom == 0 || canceledFrom == 3) {
sendErrorToClient(i, charSequence);
}
dismiss();
return;
}
if (this.mViewModel.isFingerprintDialogDismissedInstantly()) {
sendErrorAndDismiss(i, charSequence);
} else {
showFingerprintErrorMessage(charSequence);
this.mHandler.postDelayed(new Runnable() { // from class: androidx.biometric.BiometricFragment.8
@Override // java.lang.Runnable
public void run() {
BiometricFragment.this.sendErrorAndDismiss(i, charSequence);
}
}, getDismissDialogDelay());
}
this.mViewModel.setFingerprintDialogDismissedInstantly(true);
}
public void onAuthenticationHelp(@NonNull CharSequence charSequence) {
if (isUsingFingerprintDialog()) {
showFingerprintErrorMessage(charSequence);
}
}
public void onAuthenticationFailed() {
if (isUsingFingerprintDialog()) {
showFingerprintErrorMessage(getString(R.string.fingerprint_not_recognized));
}
sendFailureToClient();
}
public void onDeviceCredentialButtonPressed() {
launchConfirmCredentialActivity();
}
public void onCancelButtonPressed() {
CharSequence negativeButtonText = this.mViewModel.getNegativeButtonText();
if (negativeButtonText == null) {
negativeButtonText = getString(R.string.default_error_msg);
}
sendErrorAndDismiss(13, negativeButtonText);
cancelAuthentication(2);
}
@RequiresApi(21)
private void launchConfirmCredentialActivity() {
FragmentActivity activity = getActivity();
if (activity == null) {
Log.e(TAG, "Failed to check device credential. Client FragmentActivity not found.");
return;
}
KeyguardManager keyguardManager = KeyguardUtils.getKeyguardManager(activity);
if (keyguardManager == null) {
sendErrorAndDismiss(12, getString(R.string.generic_error_no_keyguard));
return;
}
CharSequence title = this.mViewModel.getTitle();
CharSequence subtitle = this.mViewModel.getSubtitle();
CharSequence description = this.mViewModel.getDescription();
if (subtitle == null) {
subtitle = description;
}
Intent createConfirmDeviceCredentialIntent = Api21Impl.createConfirmDeviceCredentialIntent(keyguardManager, title, subtitle);
if (createConfirmDeviceCredentialIntent == null) {
sendErrorAndDismiss(14, getString(R.string.generic_error_no_device_credential));
return;
}
this.mViewModel.setConfirmingDeviceCredential(true);
if (isUsingFingerprintDialog()) {
dismissFingerprintDialog();
}
createConfirmDeviceCredentialIntent.setFlags(134742016);
startActivityForResult(createConfirmDeviceCredentialIntent, 1);
}
private void handleConfirmCredentialResult(int i) {
if (i == -1) {
sendSuccessAndDismiss(new BiometricPrompt.AuthenticationResult(null, 1));
} else {
sendErrorAndDismiss(10, getString(R.string.generic_error_user_canceled));
}
}
private void showFingerprintErrorMessage(@Nullable CharSequence charSequence) {
if (charSequence == null) {
charSequence = getString(R.string.default_error_msg);
}
this.mViewModel.setFingerprintDialogState(2);
this.mViewModel.setFingerprintDialogHelpMessage(charSequence);
}
private void sendSuccessAndDismiss(@NonNull BiometricPrompt.AuthenticationResult authenticationResult) {
sendSuccessToClient(authenticationResult);
dismiss();
}
public void sendErrorAndDismiss(int i, @NonNull CharSequence charSequence) {
sendErrorToClient(i, charSequence);
dismiss();
}
private void sendSuccessToClient(@NonNull final BiometricPrompt.AuthenticationResult authenticationResult) {
if (!this.mViewModel.isAwaitingResult()) {
Log.w(TAG, "Success not sent to client. Client is not awaiting a result.");
} else {
this.mViewModel.setAwaitingResult(false);
this.mViewModel.getClientExecutor().execute(new Runnable() { // from class: androidx.biometric.BiometricFragment.9
@Override // java.lang.Runnable
public void run() {
BiometricFragment.this.mViewModel.getClientCallback().onAuthenticationSucceeded(authenticationResult);
}
});
}
}
private void sendErrorToClient(final int i, @NonNull final CharSequence charSequence) {
if (this.mViewModel.isConfirmingDeviceCredential()) {
return;
}
if (!this.mViewModel.isAwaitingResult()) {
Log.w(TAG, "Error not sent to client. Client is not awaiting a result.");
} else {
this.mViewModel.setAwaitingResult(false);
this.mViewModel.getClientExecutor().execute(new Runnable() { // from class: androidx.biometric.BiometricFragment.10
@Override // java.lang.Runnable
public void run() {
BiometricFragment.this.mViewModel.getClientCallback().onAuthenticationError(i, charSequence);
}
});
}
}
private void sendFailureToClient() {
if (!this.mViewModel.isAwaitingResult()) {
Log.w(TAG, "Failure not sent to client. Client is not awaiting a result.");
} else {
this.mViewModel.getClientExecutor().execute(new Runnable() { // from class: androidx.biometric.BiometricFragment.11
@Override // java.lang.Runnable
public void run() {
BiometricFragment.this.mViewModel.getClientCallback().onAuthenticationFailed();
}
});
}
}
private static int checkForFingerprintPreAuthenticationErrors(FingerprintManagerCompat fingerprintManagerCompat) {
if (fingerprintManagerCompat.isHardwareDetected()) {
return !fingerprintManagerCompat.hasEnrolledFingerprints() ? 11 : 0;
}
return 12;
}
public boolean isManagingDeviceCredentialButton() {
return Build.VERSION.SDK_INT <= 28 && AuthenticatorUtils.isDeviceCredentialAllowed(this.mViewModel.getAllowedAuthenticators());
}
private boolean isUsingFingerprintDialog() {
return Build.VERSION.SDK_INT < 28 || isFingerprintDialogNeededForCrypto() || isFingerprintDialogNeededForErrorHandling();
}
private boolean isFingerprintDialogNeededForCrypto() {
FragmentActivity activity = getActivity();
return (activity == null || this.mViewModel.getCryptoObject() == null || !DeviceUtils.shouldUseFingerprintForCrypto(activity, Build.MANUFACTURER, Build.MODEL)) ? false : true;
}
private boolean isFingerprintDialogNeededForErrorHandling() {
return Build.VERSION.SDK_INT == 28 && !PackageUtils.hasSystemFeatureFingerprint(getContext());
}
private boolean isChangingConfigurations() {
FragmentActivity activity = getActivity();
return activity != null && activity.isChangingConfigurations();
}
private int getDismissDialogDelay() {
Context context = getContext();
return (context == null || !DeviceUtils.shouldHideFingerprintDialog(context, Build.MODEL)) ? 2000 : 0;
}
@RequiresApi(30)
public static class Api30Impl {
private Api30Impl() {
}
public static void setAllowedAuthenticators(@NonNull BiometricPrompt.Builder builder, int i) {
builder.setAllowedAuthenticators(i);
}
}
@RequiresApi(29)
public static class Api29Impl {
private Api29Impl() {
}
public static void setConfirmationRequired(@NonNull BiometricPrompt.Builder builder, boolean z) {
builder.setConfirmationRequired(z);
}
public static void setDeviceCredentialAllowed(@NonNull BiometricPrompt.Builder builder, boolean z) {
builder.setDeviceCredentialAllowed(z);
}
}
@RequiresApi(28)
public static class Api28Impl {
private Api28Impl() {
}
@NonNull
public static BiometricPrompt.Builder createPromptBuilder(@NonNull Context context) {
return new BiometricPrompt.Builder(context);
}
public static void setTitle(@NonNull BiometricPrompt.Builder builder, @NonNull CharSequence charSequence) {
builder.setTitle(charSequence);
}
public static void setSubtitle(@NonNull BiometricPrompt.Builder builder, @NonNull CharSequence charSequence) {
builder.setSubtitle(charSequence);
}
public static void setDescription(@NonNull BiometricPrompt.Builder builder, @NonNull CharSequence charSequence) {
builder.setDescription(charSequence);
}
public static void setNegativeButton(@NonNull BiometricPrompt.Builder builder, @NonNull CharSequence charSequence, @NonNull Executor executor, @NonNull DialogInterface.OnClickListener onClickListener) {
builder.setNegativeButton(charSequence, executor, onClickListener);
}
@NonNull
public static android.hardware.biometrics.BiometricPrompt buildPrompt(@NonNull BiometricPrompt.Builder builder) {
return builder.build();
}
public static void authenticate(@NonNull android.hardware.biometrics.BiometricPrompt biometricPrompt, @NonNull CancellationSignal cancellationSignal, @NonNull Executor executor, @NonNull android.hardware.biometrics.BiometricPrompt$AuthenticationCallback biometricPrompt$AuthenticationCallback) {
biometricPrompt.authenticate(cancellationSignal, executor, biometricPrompt$AuthenticationCallback);
}
public static void authenticate(@NonNull android.hardware.biometrics.BiometricPrompt biometricPrompt, @NonNull BiometricPrompt.CryptoObject cryptoObject, @NonNull CancellationSignal cancellationSignal, @NonNull Executor executor, @NonNull android.hardware.biometrics.BiometricPrompt$AuthenticationCallback biometricPrompt$AuthenticationCallback) {
biometricPrompt.authenticate(cryptoObject, cancellationSignal, executor, biometricPrompt$AuthenticationCallback);
}
}
@RequiresApi(21)
public static class Api21Impl {
private Api21Impl() {
}
@Nullable
public static Intent createConfirmDeviceCredentialIntent(@NonNull KeyguardManager keyguardManager, @Nullable CharSequence charSequence, @Nullable CharSequence charSequence2) {
return keyguardManager.createConfirmDeviceCredentialIntent(charSequence, charSequence2);
}
}
}

View File

@@ -0,0 +1,274 @@
package androidx.biometric;
import android.content.Context;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Build;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
public class BiometricManager {
public static final int BIOMETRIC_ERROR_HW_UNAVAILABLE = 1;
public static final int BIOMETRIC_ERROR_NONE_ENROLLED = 11;
public static final int BIOMETRIC_ERROR_NO_HARDWARE = 12;
public static final int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED = 15;
public static final int BIOMETRIC_ERROR_UNSUPPORTED = -2;
public static final int BIOMETRIC_STATUS_UNKNOWN = -1;
public static final int BIOMETRIC_SUCCESS = 0;
private static final String TAG = "BiometricManager";
@Nullable
private final android.hardware.biometrics.BiometricManager mBiometricManager;
@Nullable
private final FingerprintManagerCompat mFingerprintManager;
@NonNull
private final Injector mInjector;
public interface Authenticators {
public static final int BIOMETRIC_STRONG = 15;
public static final int BIOMETRIC_WEAK = 255;
public static final int DEVICE_CREDENTIAL = 32768;
}
@VisibleForTesting
public interface Injector {
@Nullable
@RequiresApi(29)
android.hardware.biometrics.BiometricManager getBiometricManager();
@Nullable
FingerprintManagerCompat getFingerprintManager();
boolean isDeviceSecurable();
boolean isDeviceSecuredWithCredential();
boolean isFingerprintHardwarePresent();
boolean isStrongBiometricGuaranteed();
}
public static class DefaultInjector implements Injector {
@NonNull
private final Context mContext;
public DefaultInjector(@NonNull Context context) {
this.mContext = context.getApplicationContext();
}
@Override // androidx.biometric.BiometricManager.Injector
@Nullable
@RequiresApi(29)
public android.hardware.biometrics.BiometricManager getBiometricManager() {
return Api29Impl.create(this.mContext);
}
@Override // androidx.biometric.BiometricManager.Injector
@Nullable
public FingerprintManagerCompat getFingerprintManager() {
return FingerprintManagerCompat.from(this.mContext);
}
@Override // androidx.biometric.BiometricManager.Injector
public boolean isDeviceSecurable() {
return KeyguardUtils.getKeyguardManager(this.mContext) != null;
}
@Override // androidx.biometric.BiometricManager.Injector
public boolean isDeviceSecuredWithCredential() {
return KeyguardUtils.isDeviceSecuredWithCredential(this.mContext);
}
@Override // androidx.biometric.BiometricManager.Injector
public boolean isFingerprintHardwarePresent() {
return PackageUtils.hasSystemFeatureFingerprint(this.mContext);
}
@Override // androidx.biometric.BiometricManager.Injector
public boolean isStrongBiometricGuaranteed() {
return DeviceUtils.canAssumeStrongBiometrics(this.mContext, Build.MODEL);
}
}
@NonNull
public static BiometricManager from(@NonNull Context context) {
return new BiometricManager(new DefaultInjector(context));
}
@VisibleForTesting
public BiometricManager(@NonNull Injector injector) {
this.mInjector = injector;
int i = Build.VERSION.SDK_INT;
this.mBiometricManager = i >= 29 ? injector.getBiometricManager() : null;
this.mFingerprintManager = i <= 29 ? injector.getFingerprintManager() : null;
}
@Deprecated
public int canAuthenticate() {
return canAuthenticate(255);
}
public int canAuthenticate(int i) {
if (Build.VERSION.SDK_INT < 30) {
return canAuthenticateCompat(i);
}
android.hardware.biometrics.BiometricManager biometricManager = this.mBiometricManager;
if (biometricManager == null) {
Log.e(TAG, "Failure in canAuthenticate(). BiometricManager was null.");
return 1;
}
return Api30Impl.canAuthenticate(biometricManager, i);
}
private int canAuthenticateCompat(int i) {
if (!AuthenticatorUtils.isSupportedCombination(i)) {
return -2;
}
if (i == 0 || !this.mInjector.isDeviceSecurable()) {
return 12;
}
if (AuthenticatorUtils.isDeviceCredentialAllowed(i)) {
return this.mInjector.isDeviceSecuredWithCredential() ? 0 : 11;
}
int i2 = Build.VERSION.SDK_INT;
if (i2 == 29) {
if (AuthenticatorUtils.isWeakBiometricAllowed(i)) {
return canAuthenticateWithWeakBiometricOnApi29();
}
return canAuthenticateWithStrongBiometricOnApi29();
}
if (i2 == 28) {
if (this.mInjector.isFingerprintHardwarePresent()) {
return canAuthenticateWithFingerprintOrUnknownBiometric();
}
return 12;
}
return canAuthenticateWithFingerprint();
}
/* JADX WARN: Removed duplicated region for block: B:21:0x0044 A[ADDED_TO_REGION] */
/* JADX WARN: Removed duplicated region for block: B:25:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
@androidx.annotation.RequiresApi(29)
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private int canAuthenticateWithStrongBiometricOnApi29() {
/*
r4 = this;
java.lang.String r0 = "BiometricManager"
java.lang.reflect.Method r1 = androidx.biometric.BiometricManager.Api29Impl.getCanAuthenticateWithCryptoMethod()
if (r1 == 0) goto L38
androidx.biometric.BiometricPrompt$CryptoObject r2 = androidx.biometric.CryptoObjectUtils.createFakeCryptoObject()
android.hardware.biometrics.BiometricPrompt$CryptoObject r2 = androidx.biometric.CryptoObjectUtils.wrapForBiometricPrompt(r2)
if (r2 == 0) goto L38
android.hardware.biometrics.BiometricManager r3 = r4.mBiometricManager // Catch: java.lang.reflect.InvocationTargetException -> L27 java.lang.IllegalArgumentException -> L29 java.lang.IllegalAccessException -> L2b
java.lang.Object[] r2 = new java.lang.Object[]{r2} // Catch: java.lang.reflect.InvocationTargetException -> L27 java.lang.IllegalArgumentException -> L29 java.lang.IllegalAccessException -> L2b
java.lang.Object r1 = r1.invoke(r3, r2) // Catch: java.lang.reflect.InvocationTargetException -> L27 java.lang.IllegalArgumentException -> L29 java.lang.IllegalAccessException -> L2b
boolean r2 = r1 instanceof java.lang.Integer // Catch: java.lang.reflect.InvocationTargetException -> L27 java.lang.IllegalArgumentException -> L29 java.lang.IllegalAccessException -> L2b
if (r2 == 0) goto L2d
java.lang.Integer r1 = (java.lang.Integer) r1 // Catch: java.lang.reflect.InvocationTargetException -> L27 java.lang.IllegalArgumentException -> L29 java.lang.IllegalAccessException -> L2b
int r0 = r1.intValue() // Catch: java.lang.reflect.InvocationTargetException -> L27 java.lang.IllegalArgumentException -> L29 java.lang.IllegalAccessException -> L2b
return r0
L27:
r1 = move-exception
goto L33
L29:
r1 = move-exception
goto L33
L2b:
r1 = move-exception
goto L33
L2d:
java.lang.String r1 = "Invalid return type for canAuthenticate(CryptoObject)."
android.util.Log.w(r0, r1) // Catch: java.lang.reflect.InvocationTargetException -> L27 java.lang.IllegalArgumentException -> L29 java.lang.IllegalAccessException -> L2b
goto L38
L33:
java.lang.String r2 = "Failed to invoke canAuthenticate(CryptoObject)."
android.util.Log.w(r0, r2, r1)
L38:
int r0 = r4.canAuthenticateWithWeakBiometricOnApi29()
androidx.biometric.BiometricManager$Injector r1 = r4.mInjector
boolean r1 = r1.isStrongBiometricGuaranteed()
if (r1 != 0) goto L4b
if (r0 == 0) goto L47
goto L4b
L47:
int r0 = r4.canAuthenticateWithFingerprintOrUnknownBiometric()
L4b:
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.biometric.BiometricManager.canAuthenticateWithStrongBiometricOnApi29():int");
}
@RequiresApi(29)
private int canAuthenticateWithWeakBiometricOnApi29() {
android.hardware.biometrics.BiometricManager biometricManager = this.mBiometricManager;
if (biometricManager == null) {
Log.e(TAG, "Failure in canAuthenticate(). BiometricManager was null.");
return 1;
}
return Api29Impl.canAuthenticate(biometricManager);
}
private int canAuthenticateWithFingerprintOrUnknownBiometric() {
if (this.mInjector.isDeviceSecuredWithCredential()) {
return canAuthenticateWithFingerprint() == 0 ? 0 : -1;
}
return canAuthenticateWithFingerprint();
}
private int canAuthenticateWithFingerprint() {
FingerprintManagerCompat fingerprintManagerCompat = this.mFingerprintManager;
if (fingerprintManagerCompat == null) {
Log.e(TAG, "Failure in canAuthenticate(). FingerprintManager was null.");
return 1;
}
if (fingerprintManagerCompat.isHardwareDetected()) {
return !this.mFingerprintManager.hasEnrolledFingerprints() ? 11 : 0;
}
return 12;
}
@RequiresApi(30)
public static class Api30Impl {
private Api30Impl() {
}
public static int canAuthenticate(@NonNull android.hardware.biometrics.BiometricManager biometricManager, int i) {
return biometricManager.canAuthenticate(i);
}
}
@RequiresApi(29)
public static class Api29Impl {
private Api29Impl() {
}
@Nullable
public static android.hardware.biometrics.BiometricManager create(@NonNull Context context) {
return (android.hardware.biometrics.BiometricManager) context.getSystemService(android.hardware.biometrics.BiometricManager.class);
}
public static int canAuthenticate(@NonNull android.hardware.biometrics.BiometricManager biometricManager) {
return biometricManager.canAuthenticate();
}
@Nullable
public static Method getCanAuthenticateWithCryptoMethod() {
try {
return android.hardware.biometrics.BiometricManager.class.getMethod("canAuthenticate", BiometricPrompt.CryptoObject.class);
} catch (NoSuchMethodException unused) {
return null;
}
}
}
}

View File

@@ -0,0 +1,449 @@
package androidx.biometric;
import android.annotation.SuppressLint;
import android.os.Build;
import android.security.identity.IdentityCredential;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.lifecycle.ViewModelProvider;
import java.lang.ref.WeakReference;
import java.security.Signature;
import java.util.concurrent.Executor;
import javax.crypto.Cipher;
import javax.crypto.Mac;
/* loaded from: classes.dex */
public class BiometricPrompt {
public static final int AUTHENTICATION_RESULT_TYPE_BIOMETRIC = 2;
public static final int AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL = 1;
public static final int AUTHENTICATION_RESULT_TYPE_UNKNOWN = -1;
private static final String BIOMETRIC_FRAGMENT_TAG = "androidx.biometric.BiometricFragment";
static final int BIOMETRIC_SUCCESS = 0;
public static final int ERROR_CANCELED = 5;
public static final int ERROR_HW_NOT_PRESENT = 12;
public static final int ERROR_HW_UNAVAILABLE = 1;
public static final int ERROR_LOCKOUT = 7;
public static final int ERROR_LOCKOUT_PERMANENT = 9;
public static final int ERROR_NEGATIVE_BUTTON = 13;
public static final int ERROR_NO_BIOMETRICS = 11;
public static final int ERROR_NO_DEVICE_CREDENTIAL = 14;
public static final int ERROR_NO_SPACE = 4;
public static final int ERROR_SECURITY_UPDATE_REQUIRED = 15;
public static final int ERROR_TIMEOUT = 3;
public static final int ERROR_UNABLE_TO_PROCESS = 2;
public static final int ERROR_USER_CANCELED = 10;
public static final int ERROR_VENDOR = 8;
private static final String TAG = "BiometricPromptCompat";
@Nullable
private FragmentManager mClientFragmentManager;
public static abstract class AuthenticationCallback {
public void onAuthenticationError(int i, @NonNull CharSequence charSequence) {
}
public void onAuthenticationFailed() {
}
public void onAuthenticationSucceeded(@NonNull AuthenticationResult authenticationResult) {
}
}
public static class CryptoObject {
@Nullable
private final Cipher mCipher;
@Nullable
private final IdentityCredential mIdentityCredential;
@Nullable
private final Mac mMac;
@Nullable
private final Signature mSignature;
@Nullable
public Cipher getCipher() {
return this.mCipher;
}
@Nullable
@RequiresApi(30)
public IdentityCredential getIdentityCredential() {
return this.mIdentityCredential;
}
@Nullable
public Mac getMac() {
return this.mMac;
}
@Nullable
public Signature getSignature() {
return this.mSignature;
}
public CryptoObject(@NonNull Signature signature) {
this.mSignature = signature;
this.mCipher = null;
this.mMac = null;
this.mIdentityCredential = null;
}
public CryptoObject(@NonNull Cipher cipher) {
this.mSignature = null;
this.mCipher = cipher;
this.mMac = null;
this.mIdentityCredential = null;
}
public CryptoObject(@NonNull Mac mac) {
this.mSignature = null;
this.mCipher = null;
this.mMac = mac;
this.mIdentityCredential = null;
}
@RequiresApi(30)
public CryptoObject(@NonNull IdentityCredential identityCredential) {
this.mSignature = null;
this.mCipher = null;
this.mMac = null;
this.mIdentityCredential = identityCredential;
}
}
public static class AuthenticationResult {
private final int mAuthenticationType;
private final CryptoObject mCryptoObject;
public int getAuthenticationType() {
return this.mAuthenticationType;
}
@Nullable
public CryptoObject getCryptoObject() {
return this.mCryptoObject;
}
public AuthenticationResult(CryptoObject cryptoObject, int i) {
this.mCryptoObject = cryptoObject;
this.mAuthenticationType = i;
}
}
public static class PromptInfo {
private final int mAllowedAuthenticators;
@Nullable
private final CharSequence mDescription;
private final boolean mIsConfirmationRequired;
private final boolean mIsDeviceCredentialAllowed;
@Nullable
private final CharSequence mNegativeButtonText;
@Nullable
private final CharSequence mSubtitle;
@NonNull
private final CharSequence mTitle;
public int getAllowedAuthenticators() {
return this.mAllowedAuthenticators;
}
@Nullable
public CharSequence getDescription() {
return this.mDescription;
}
@NonNull
public CharSequence getNegativeButtonText() {
CharSequence charSequence = this.mNegativeButtonText;
return charSequence != null ? charSequence : "";
}
@Nullable
public CharSequence getSubtitle() {
return this.mSubtitle;
}
@NonNull
public CharSequence getTitle() {
return this.mTitle;
}
public boolean isConfirmationRequired() {
return this.mIsConfirmationRequired;
}
@Deprecated
public boolean isDeviceCredentialAllowed() {
return this.mIsDeviceCredentialAllowed;
}
public static class Builder {
@Nullable
private CharSequence mTitle = null;
@Nullable
private CharSequence mSubtitle = null;
@Nullable
private CharSequence mDescription = null;
@Nullable
private CharSequence mNegativeButtonText = null;
private boolean mIsConfirmationRequired = true;
private boolean mIsDeviceCredentialAllowed = false;
private int mAllowedAuthenticators = 0;
@NonNull
public Builder setAllowedAuthenticators(int i) {
this.mAllowedAuthenticators = i;
return this;
}
@NonNull
public Builder setConfirmationRequired(boolean z) {
this.mIsConfirmationRequired = z;
return this;
}
@NonNull
public Builder setDescription(@Nullable CharSequence charSequence) {
this.mDescription = charSequence;
return this;
}
@NonNull
@Deprecated
public Builder setDeviceCredentialAllowed(boolean z) {
this.mIsDeviceCredentialAllowed = z;
return this;
}
@NonNull
public Builder setNegativeButtonText(@NonNull CharSequence charSequence) {
this.mNegativeButtonText = charSequence;
return this;
}
@NonNull
public Builder setSubtitle(@Nullable CharSequence charSequence) {
this.mSubtitle = charSequence;
return this;
}
@NonNull
public Builder setTitle(@NonNull CharSequence charSequence) {
this.mTitle = charSequence;
return this;
}
@NonNull
public PromptInfo build() {
if (TextUtils.isEmpty(this.mTitle)) {
throw new IllegalArgumentException("Title must be set and non-empty.");
}
if (!AuthenticatorUtils.isSupportedCombination(this.mAllowedAuthenticators)) {
throw new IllegalArgumentException("Authenticator combination is unsupported on API " + Build.VERSION.SDK_INT + ": " + AuthenticatorUtils.convertToString(this.mAllowedAuthenticators));
}
int i = this.mAllowedAuthenticators;
boolean isDeviceCredentialAllowed = i != 0 ? AuthenticatorUtils.isDeviceCredentialAllowed(i) : this.mIsDeviceCredentialAllowed;
if (TextUtils.isEmpty(this.mNegativeButtonText) && !isDeviceCredentialAllowed) {
throw new IllegalArgumentException("Negative text must be set and non-empty.");
}
if (!TextUtils.isEmpty(this.mNegativeButtonText) && isDeviceCredentialAllowed) {
throw new IllegalArgumentException("Negative text must not be set if device credential authentication is allowed.");
}
return new PromptInfo(this.mTitle, this.mSubtitle, this.mDescription, this.mNegativeButtonText, this.mIsConfirmationRequired, this.mIsDeviceCredentialAllowed, this.mAllowedAuthenticators);
}
}
public PromptInfo(@NonNull CharSequence charSequence, @Nullable CharSequence charSequence2, @Nullable CharSequence charSequence3, @Nullable CharSequence charSequence4, boolean z, boolean z2, int i) {
this.mTitle = charSequence;
this.mSubtitle = charSequence2;
this.mDescription = charSequence3;
this.mNegativeButtonText = charSequence4;
this.mIsConfirmationRequired = z;
this.mIsDeviceCredentialAllowed = z2;
this.mAllowedAuthenticators = i;
}
}
public static class ResetCallbackObserver implements LifecycleObserver {
@NonNull
private final WeakReference<BiometricViewModel> mViewModelRef;
public ResetCallbackObserver(@NonNull BiometricViewModel biometricViewModel) {
this.mViewModelRef = new WeakReference<>(biometricViewModel);
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void resetCallback() {
if (this.mViewModelRef.get() != null) {
this.mViewModelRef.get().resetClientCallback();
}
}
}
public BiometricPrompt(@NonNull FragmentActivity fragmentActivity, @NonNull AuthenticationCallback authenticationCallback) {
if (fragmentActivity == null) {
throw new IllegalArgumentException("FragmentActivity must not be null.");
}
if (authenticationCallback == null) {
throw new IllegalArgumentException("AuthenticationCallback must not be null.");
}
init(fragmentActivity.getSupportFragmentManager(), getViewModel(fragmentActivity), null, authenticationCallback);
}
public BiometricPrompt(@NonNull Fragment fragment, @NonNull AuthenticationCallback authenticationCallback) {
if (fragment == null) {
throw new IllegalArgumentException("Fragment must not be null.");
}
if (authenticationCallback == null) {
throw new IllegalArgumentException("AuthenticationCallback must not be null.");
}
FragmentActivity activity = fragment.getActivity();
FragmentManager childFragmentManager = fragment.getChildFragmentManager();
BiometricViewModel viewModel = getViewModel(activity);
addObservers(fragment, viewModel);
init(childFragmentManager, viewModel, null, authenticationCallback);
}
@SuppressLint({"LambdaLast"})
public BiometricPrompt(@NonNull FragmentActivity fragmentActivity, @NonNull Executor executor, @NonNull AuthenticationCallback authenticationCallback) {
if (fragmentActivity == null) {
throw new IllegalArgumentException("FragmentActivity must not be null.");
}
if (executor == null) {
throw new IllegalArgumentException("Executor must not be null.");
}
if (authenticationCallback == null) {
throw new IllegalArgumentException("AuthenticationCallback must not be null.");
}
init(fragmentActivity.getSupportFragmentManager(), getViewModel(fragmentActivity), executor, authenticationCallback);
}
@SuppressLint({"LambdaLast"})
public BiometricPrompt(@NonNull Fragment fragment, @NonNull Executor executor, @NonNull AuthenticationCallback authenticationCallback) {
if (fragment == null) {
throw new IllegalArgumentException("Fragment must not be null.");
}
if (executor == null) {
throw new IllegalArgumentException("Executor must not be null.");
}
if (authenticationCallback == null) {
throw new IllegalArgumentException("AuthenticationCallback must not be null.");
}
FragmentActivity activity = fragment.getActivity();
FragmentManager childFragmentManager = fragment.getChildFragmentManager();
BiometricViewModel viewModel = getViewModel(activity);
addObservers(fragment, viewModel);
init(childFragmentManager, viewModel, executor, authenticationCallback);
}
private void init(@Nullable FragmentManager fragmentManager, @Nullable BiometricViewModel biometricViewModel, @Nullable Executor executor, @NonNull AuthenticationCallback authenticationCallback) {
this.mClientFragmentManager = fragmentManager;
if (biometricViewModel != null) {
if (executor != null) {
biometricViewModel.setClientExecutor(executor);
}
biometricViewModel.setClientCallback(authenticationCallback);
}
}
public void authenticate(@NonNull PromptInfo promptInfo, @NonNull CryptoObject cryptoObject) {
if (promptInfo == null) {
throw new IllegalArgumentException("PromptInfo cannot be null.");
}
if (cryptoObject == null) {
throw new IllegalArgumentException("CryptoObject cannot be null.");
}
int consolidatedAuthenticators = AuthenticatorUtils.getConsolidatedAuthenticators(promptInfo, cryptoObject);
if (AuthenticatorUtils.isWeakBiometricAllowed(consolidatedAuthenticators)) {
throw new IllegalArgumentException("Crypto-based authentication is not supported for Class 2 (Weak) biometrics.");
}
if (Build.VERSION.SDK_INT < 30 && AuthenticatorUtils.isDeviceCredentialAllowed(consolidatedAuthenticators)) {
throw new IllegalArgumentException("Crypto-based authentication is not supported for device credential prior to API 30.");
}
authenticateInternal(promptInfo, cryptoObject);
}
public void authenticate(@NonNull PromptInfo promptInfo) {
if (promptInfo == null) {
throw new IllegalArgumentException("PromptInfo cannot be null.");
}
authenticateInternal(promptInfo, null);
}
private void authenticateInternal(@NonNull PromptInfo promptInfo, @Nullable CryptoObject cryptoObject) {
FragmentManager fragmentManager = this.mClientFragmentManager;
if (fragmentManager == null) {
Log.e(TAG, "Unable to start authentication. Client fragment manager was null.");
} else if (fragmentManager.isStateSaved()) {
Log.e(TAG, "Unable to start authentication. Called after onSaveInstanceState().");
} else {
findOrAddBiometricFragment(this.mClientFragmentManager).authenticate(promptInfo, cryptoObject);
}
}
public void cancelAuthentication() {
FragmentManager fragmentManager = this.mClientFragmentManager;
if (fragmentManager == null) {
Log.e(TAG, "Unable to start authentication. Client fragment manager was null.");
return;
}
BiometricFragment findBiometricFragment = findBiometricFragment(fragmentManager);
if (findBiometricFragment == null) {
Log.e(TAG, "Unable to cancel authentication. BiometricFragment not found.");
} else {
findBiometricFragment.cancelAuthentication(3);
}
}
@Nullable
private static BiometricViewModel getViewModel(@Nullable FragmentActivity fragmentActivity) {
if (fragmentActivity != null) {
return (BiometricViewModel) new ViewModelProvider(fragmentActivity).get(BiometricViewModel.class);
}
return null;
}
private static void addObservers(@NonNull Fragment fragment, @Nullable BiometricViewModel biometricViewModel) {
if (biometricViewModel != null) {
fragment.getLifecycle().addObserver(new ResetCallbackObserver(biometricViewModel));
}
}
@Nullable
private static BiometricFragment findBiometricFragment(@NonNull FragmentManager fragmentManager) {
return (BiometricFragment) fragmentManager.findFragmentByTag(BIOMETRIC_FRAGMENT_TAG);
}
@NonNull
private static BiometricFragment findOrAddBiometricFragment(@NonNull FragmentManager fragmentManager) {
BiometricFragment findBiometricFragment = findBiometricFragment(fragmentManager);
if (findBiometricFragment != null) {
return findBiometricFragment;
}
BiometricFragment newInstance = BiometricFragment.newInstance();
fragmentManager.beginTransaction().add(newInstance, BIOMETRIC_FRAGMENT_TAG).commitAllowingStateLoss();
fragmentManager.executePendingTransactions();
return newInstance;
}
}

View File

@@ -0,0 +1,464 @@
package androidx.biometric;
import android.content.DialogInterface;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.biometric.AuthenticationCallbackProvider;
import androidx.biometric.BiometricPrompt;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import java.lang.ref.WeakReference;
import java.util.concurrent.Executor;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public class BiometricViewModel extends ViewModel {
@Nullable
private AuthenticationCallbackProvider mAuthenticationCallbackProvider;
@Nullable
private MutableLiveData<BiometricErrorData> mAuthenticationError;
@Nullable
private MutableLiveData<CharSequence> mAuthenticationHelpMessage;
@Nullable
private MutableLiveData<BiometricPrompt.AuthenticationResult> mAuthenticationResult;
@Nullable
private CancellationSignalProvider mCancellationSignalProvider;
@Nullable
private BiometricPrompt.AuthenticationCallback mClientCallback;
@Nullable
private Executor mClientExecutor;
@Nullable
private BiometricPrompt.CryptoObject mCryptoObject;
@Nullable
private MutableLiveData<CharSequence> mFingerprintDialogHelpMessage;
@Nullable
private MutableLiveData<Integer> mFingerprintDialogState;
@Nullable
private MutableLiveData<Boolean> mIsAuthenticationFailurePending;
private boolean mIsAwaitingResult;
private boolean mIsConfirmingDeviceCredential;
private boolean mIsDelayingPrompt;
@Nullable
private MutableLiveData<Boolean> mIsFingerprintDialogCancelPending;
private boolean mIsIgnoringCancel;
@Nullable
private MutableLiveData<Boolean> mIsNegativeButtonPressPending;
private boolean mIsPromptShowing;
@Nullable
private DialogInterface.OnClickListener mNegativeButtonListener;
@Nullable
private CharSequence mNegativeButtonTextOverride;
@Nullable
private BiometricPrompt.PromptInfo mPromptInfo;
private int mCanceledFrom = 0;
private boolean mIsFingerprintDialogDismissedInstantly = true;
private int mFingerprintDialogPreviousState = 0;
public int getCanceledFrom() {
return this.mCanceledFrom;
}
@Nullable
public BiometricPrompt.CryptoObject getCryptoObject() {
return this.mCryptoObject;
}
public int getFingerprintDialogPreviousState() {
return this.mFingerprintDialogPreviousState;
}
public boolean isAwaitingResult() {
return this.mIsAwaitingResult;
}
public boolean isConfirmingDeviceCredential() {
return this.mIsConfirmingDeviceCredential;
}
public boolean isDelayingPrompt() {
return this.mIsDelayingPrompt;
}
public boolean isFingerprintDialogDismissedInstantly() {
return this.mIsFingerprintDialogDismissedInstantly;
}
public boolean isIgnoringCancel() {
return this.mIsIgnoringCancel;
}
public boolean isPromptShowing() {
return this.mIsPromptShowing;
}
public void resetClientCallback() {
this.mClientCallback = null;
}
public void setAwaitingResult(boolean z) {
this.mIsAwaitingResult = z;
}
public void setCanceledFrom(int i) {
this.mCanceledFrom = i;
}
public void setClientCallback(@NonNull BiometricPrompt.AuthenticationCallback authenticationCallback) {
this.mClientCallback = authenticationCallback;
}
public void setClientExecutor(@NonNull Executor executor) {
this.mClientExecutor = executor;
}
public void setConfirmingDeviceCredential(boolean z) {
this.mIsConfirmingDeviceCredential = z;
}
public void setCryptoObject(@Nullable BiometricPrompt.CryptoObject cryptoObject) {
this.mCryptoObject = cryptoObject;
}
public void setDelayingPrompt(boolean z) {
this.mIsDelayingPrompt = z;
}
public void setFingerprintDialogDismissedInstantly(boolean z) {
this.mIsFingerprintDialogDismissedInstantly = z;
}
public void setFingerprintDialogPreviousState(int i) {
this.mFingerprintDialogPreviousState = i;
}
public void setIgnoringCancel(boolean z) {
this.mIsIgnoringCancel = z;
}
public void setNegativeButtonTextOverride(@Nullable CharSequence charSequence) {
this.mNegativeButtonTextOverride = charSequence;
}
public void setPromptInfo(@Nullable BiometricPrompt.PromptInfo promptInfo) {
this.mPromptInfo = promptInfo;
}
public void setPromptShowing(boolean z) {
this.mIsPromptShowing = z;
}
public static class DefaultExecutor implements Executor {
private final Handler mHandler = new Handler(Looper.getMainLooper());
@Override // java.util.concurrent.Executor
public void execute(Runnable runnable) {
this.mHandler.post(runnable);
}
}
public static final class CallbackListener extends AuthenticationCallbackProvider.Listener {
@NonNull
private final WeakReference<BiometricViewModel> mViewModelRef;
public CallbackListener(@Nullable BiometricViewModel biometricViewModel) {
this.mViewModelRef = new WeakReference<>(biometricViewModel);
}
@Override // androidx.biometric.AuthenticationCallbackProvider.Listener
public void onSuccess(@NonNull BiometricPrompt.AuthenticationResult authenticationResult) {
if (this.mViewModelRef.get() == null || !this.mViewModelRef.get().isAwaitingResult()) {
return;
}
if (authenticationResult.getAuthenticationType() == -1) {
authenticationResult = new BiometricPrompt.AuthenticationResult(authenticationResult.getCryptoObject(), this.mViewModelRef.get().getInferredAuthenticationResultType());
}
this.mViewModelRef.get().setAuthenticationResult(authenticationResult);
}
@Override // androidx.biometric.AuthenticationCallbackProvider.Listener
public void onError(int i, @Nullable CharSequence charSequence) {
if (this.mViewModelRef.get() == null || this.mViewModelRef.get().isConfirmingDeviceCredential() || !this.mViewModelRef.get().isAwaitingResult()) {
return;
}
this.mViewModelRef.get().setAuthenticationError(new BiometricErrorData(i, charSequence));
}
@Override // androidx.biometric.AuthenticationCallbackProvider.Listener
public void onHelp(@Nullable CharSequence charSequence) {
if (this.mViewModelRef.get() != null) {
this.mViewModelRef.get().setAuthenticationHelpMessage(charSequence);
}
}
@Override // androidx.biometric.AuthenticationCallbackProvider.Listener
public void onFailure() {
if (this.mViewModelRef.get() == null || !this.mViewModelRef.get().isAwaitingResult()) {
return;
}
this.mViewModelRef.get().setAuthenticationFailurePending(true);
}
}
public static class NegativeButtonListener implements DialogInterface.OnClickListener {
@NonNull
private final WeakReference<BiometricViewModel> mViewModelRef;
public NegativeButtonListener(@Nullable BiometricViewModel biometricViewModel) {
this.mViewModelRef = new WeakReference<>(biometricViewModel);
}
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
if (this.mViewModelRef.get() != null) {
this.mViewModelRef.get().setNegativeButtonPressPending(true);
}
}
}
@NonNull
public Executor getClientExecutor() {
Executor executor = this.mClientExecutor;
return executor != null ? executor : new DefaultExecutor();
}
@NonNull
public BiometricPrompt.AuthenticationCallback getClientCallback() {
if (this.mClientCallback == null) {
this.mClientCallback = new BiometricPrompt.AuthenticationCallback() { // from class: androidx.biometric.BiometricViewModel.1
};
}
return this.mClientCallback;
}
@Nullable
public CharSequence getTitle() {
BiometricPrompt.PromptInfo promptInfo = this.mPromptInfo;
if (promptInfo != null) {
return promptInfo.getTitle();
}
return null;
}
@Nullable
public CharSequence getSubtitle() {
BiometricPrompt.PromptInfo promptInfo = this.mPromptInfo;
if (promptInfo != null) {
return promptInfo.getSubtitle();
}
return null;
}
@Nullable
public CharSequence getDescription() {
BiometricPrompt.PromptInfo promptInfo = this.mPromptInfo;
if (promptInfo != null) {
return promptInfo.getDescription();
}
return null;
}
@Nullable
public CharSequence getNegativeButtonText() {
CharSequence charSequence = this.mNegativeButtonTextOverride;
if (charSequence != null) {
return charSequence;
}
BiometricPrompt.PromptInfo promptInfo = this.mPromptInfo;
if (promptInfo != null) {
return promptInfo.getNegativeButtonText();
}
return null;
}
public boolean isConfirmationRequired() {
BiometricPrompt.PromptInfo promptInfo = this.mPromptInfo;
return promptInfo == null || promptInfo.isConfirmationRequired();
}
public int getAllowedAuthenticators() {
BiometricPrompt.PromptInfo promptInfo = this.mPromptInfo;
if (promptInfo != null) {
return AuthenticatorUtils.getConsolidatedAuthenticators(promptInfo, this.mCryptoObject);
}
return 0;
}
@NonNull
public AuthenticationCallbackProvider getAuthenticationCallbackProvider() {
if (this.mAuthenticationCallbackProvider == null) {
this.mAuthenticationCallbackProvider = new AuthenticationCallbackProvider(new CallbackListener(this));
}
return this.mAuthenticationCallbackProvider;
}
@NonNull
public CancellationSignalProvider getCancellationSignalProvider() {
if (this.mCancellationSignalProvider == null) {
this.mCancellationSignalProvider = new CancellationSignalProvider();
}
return this.mCancellationSignalProvider;
}
@NonNull
public DialogInterface.OnClickListener getNegativeButtonListener() {
if (this.mNegativeButtonListener == null) {
this.mNegativeButtonListener = new NegativeButtonListener(this);
}
return this.mNegativeButtonListener;
}
@NonNull
public LiveData<BiometricPrompt.AuthenticationResult> getAuthenticationResult() {
if (this.mAuthenticationResult == null) {
this.mAuthenticationResult = new MutableLiveData<>();
}
return this.mAuthenticationResult;
}
public void setAuthenticationResult(@Nullable BiometricPrompt.AuthenticationResult authenticationResult) {
if (this.mAuthenticationResult == null) {
this.mAuthenticationResult = new MutableLiveData<>();
}
updateValue(this.mAuthenticationResult, authenticationResult);
}
@NonNull
public MutableLiveData<BiometricErrorData> getAuthenticationError() {
if (this.mAuthenticationError == null) {
this.mAuthenticationError = new MutableLiveData<>();
}
return this.mAuthenticationError;
}
public void setAuthenticationError(@Nullable BiometricErrorData biometricErrorData) {
if (this.mAuthenticationError == null) {
this.mAuthenticationError = new MutableLiveData<>();
}
updateValue(this.mAuthenticationError, biometricErrorData);
}
@NonNull
public LiveData<CharSequence> getAuthenticationHelpMessage() {
if (this.mAuthenticationHelpMessage == null) {
this.mAuthenticationHelpMessage = new MutableLiveData<>();
}
return this.mAuthenticationHelpMessage;
}
public void setAuthenticationHelpMessage(@Nullable CharSequence charSequence) {
if (this.mAuthenticationHelpMessage == null) {
this.mAuthenticationHelpMessage = new MutableLiveData<>();
}
updateValue(this.mAuthenticationHelpMessage, charSequence);
}
@NonNull
public LiveData<Boolean> isAuthenticationFailurePending() {
if (this.mIsAuthenticationFailurePending == null) {
this.mIsAuthenticationFailurePending = new MutableLiveData<>();
}
return this.mIsAuthenticationFailurePending;
}
public void setAuthenticationFailurePending(boolean z) {
if (this.mIsAuthenticationFailurePending == null) {
this.mIsAuthenticationFailurePending = new MutableLiveData<>();
}
updateValue(this.mIsAuthenticationFailurePending, Boolean.valueOf(z));
}
@NonNull
public LiveData<Boolean> isNegativeButtonPressPending() {
if (this.mIsNegativeButtonPressPending == null) {
this.mIsNegativeButtonPressPending = new MutableLiveData<>();
}
return this.mIsNegativeButtonPressPending;
}
public void setNegativeButtonPressPending(boolean z) {
if (this.mIsNegativeButtonPressPending == null) {
this.mIsNegativeButtonPressPending = new MutableLiveData<>();
}
updateValue(this.mIsNegativeButtonPressPending, Boolean.valueOf(z));
}
@NonNull
public LiveData<Boolean> isFingerprintDialogCancelPending() {
if (this.mIsFingerprintDialogCancelPending == null) {
this.mIsFingerprintDialogCancelPending = new MutableLiveData<>();
}
return this.mIsFingerprintDialogCancelPending;
}
public void setFingerprintDialogCancelPending(boolean z) {
if (this.mIsFingerprintDialogCancelPending == null) {
this.mIsFingerprintDialogCancelPending = new MutableLiveData<>();
}
updateValue(this.mIsFingerprintDialogCancelPending, Boolean.valueOf(z));
}
@NonNull
public LiveData<Integer> getFingerprintDialogState() {
if (this.mFingerprintDialogState == null) {
this.mFingerprintDialogState = new MutableLiveData<>();
}
return this.mFingerprintDialogState;
}
public void setFingerprintDialogState(int i) {
if (this.mFingerprintDialogState == null) {
this.mFingerprintDialogState = new MutableLiveData<>();
}
updateValue(this.mFingerprintDialogState, Integer.valueOf(i));
}
@NonNull
public LiveData<CharSequence> getFingerprintDialogHelpMessage() {
if (this.mFingerprintDialogHelpMessage == null) {
this.mFingerprintDialogHelpMessage = new MutableLiveData<>();
}
return this.mFingerprintDialogHelpMessage;
}
public void setFingerprintDialogHelpMessage(@NonNull CharSequence charSequence) {
if (this.mFingerprintDialogHelpMessage == null) {
this.mFingerprintDialogHelpMessage = new MutableLiveData<>();
}
updateValue(this.mFingerprintDialogHelpMessage, charSequence);
}
public int getInferredAuthenticationResultType() {
int allowedAuthenticators = getAllowedAuthenticators();
return (!AuthenticatorUtils.isSomeBiometricAllowed(allowedAuthenticators) || AuthenticatorUtils.isDeviceCredentialAllowed(allowedAuthenticators)) ? -1 : 2;
}
private static <T> void updateValue(MutableLiveData<T> mutableLiveData, T t) {
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
mutableLiveData.setValue(t);
} else {
mutableLiveData.postValue(t);
}
}
}

View File

@@ -0,0 +1,104 @@
package androidx.biometric;
import android.os.CancellationSignal;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
/* loaded from: classes.dex */
class CancellationSignalProvider {
private static final String TAG = "CancelSignalProvider";
@Nullable
private CancellationSignal mBiometricCancellationSignal;
@Nullable
private androidx.core.os.CancellationSignal mFingerprintCancellationSignal;
private final Injector mInjector;
@VisibleForTesting
public interface Injector {
@NonNull
@RequiresApi(16)
CancellationSignal getBiometricCancellationSignal();
@NonNull
androidx.core.os.CancellationSignal getFingerprintCancellationSignal();
}
public CancellationSignalProvider() {
this.mInjector = new Injector() { // from class: androidx.biometric.CancellationSignalProvider.1
@Override // androidx.biometric.CancellationSignalProvider.Injector
@NonNull
@RequiresApi(16)
public CancellationSignal getBiometricCancellationSignal() {
return Api16Impl.create();
}
@Override // androidx.biometric.CancellationSignalProvider.Injector
@NonNull
public androidx.core.os.CancellationSignal getFingerprintCancellationSignal() {
return new androidx.core.os.CancellationSignal();
}
};
}
@VisibleForTesting
public CancellationSignalProvider(Injector injector) {
this.mInjector = injector;
}
@NonNull
@RequiresApi(16)
public CancellationSignal getBiometricCancellationSignal() {
if (this.mBiometricCancellationSignal == null) {
this.mBiometricCancellationSignal = this.mInjector.getBiometricCancellationSignal();
}
return this.mBiometricCancellationSignal;
}
@NonNull
public androidx.core.os.CancellationSignal getFingerprintCancellationSignal() {
if (this.mFingerprintCancellationSignal == null) {
this.mFingerprintCancellationSignal = this.mInjector.getFingerprintCancellationSignal();
}
return this.mFingerprintCancellationSignal;
}
public void cancel() {
CancellationSignal cancellationSignal = this.mBiometricCancellationSignal;
if (cancellationSignal != null) {
try {
Api16Impl.cancel(cancellationSignal);
} catch (NullPointerException e) {
Log.e(TAG, "Got NPE while canceling biometric authentication.", e);
}
this.mBiometricCancellationSignal = null;
}
androidx.core.os.CancellationSignal cancellationSignal2 = this.mFingerprintCancellationSignal;
if (cancellationSignal2 != null) {
try {
cancellationSignal2.cancel();
} catch (NullPointerException e2) {
Log.e(TAG, "Got NPE while canceling fingerprint authentication.", e2);
}
this.mFingerprintCancellationSignal = null;
}
}
@RequiresApi(16)
public static class Api16Impl {
private Api16Impl() {
}
public static CancellationSignal create() {
return new CancellationSignal();
}
public static void cancel(CancellationSignal cancellationSignal) {
cancellationSignal.cancel();
}
}
}

View File

@@ -0,0 +1,232 @@
package androidx.biometric;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Build;
import android.security.identity.IdentityCredential;
import android.security.keystore.KeyGenParameterSpec;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.biometric.BiometricPrompt;
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Signature;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
/* loaded from: classes.dex */
class CryptoObjectUtils {
private static final String FAKE_KEY_NAME = "androidxBiometric";
private static final String KEYSTORE_INSTANCE = "AndroidKeyStore";
private static final String TAG = "CryptoObjectUtils";
private CryptoObjectUtils() {
}
@Nullable
@RequiresApi(28)
public static BiometricPrompt.CryptoObject unwrapFromBiometricPrompt(@Nullable BiometricPrompt.CryptoObject cryptoObject) {
IdentityCredential identityCredential;
if (cryptoObject == null) {
return null;
}
Cipher cipher = Api28Impl.getCipher(cryptoObject);
if (cipher != null) {
return new BiometricPrompt.CryptoObject(cipher);
}
Signature signature = Api28Impl.getSignature(cryptoObject);
if (signature != null) {
return new BiometricPrompt.CryptoObject(signature);
}
Mac mac = Api28Impl.getMac(cryptoObject);
if (mac != null) {
return new BiometricPrompt.CryptoObject(mac);
}
if (Build.VERSION.SDK_INT < 30 || (identityCredential = Api30Impl.getIdentityCredential(cryptoObject)) == null) {
return null;
}
return new BiometricPrompt.CryptoObject(identityCredential);
}
@Nullable
@RequiresApi(28)
public static BiometricPrompt.CryptoObject wrapForBiometricPrompt(@Nullable BiometricPrompt.CryptoObject cryptoObject) {
IdentityCredential identityCredential;
if (cryptoObject == null) {
return null;
}
Cipher cipher = cryptoObject.getCipher();
if (cipher != null) {
return Api28Impl.create(cipher);
}
Signature signature = cryptoObject.getSignature();
if (signature != null) {
return Api28Impl.create(signature);
}
Mac mac = cryptoObject.getMac();
if (mac != null) {
return Api28Impl.create(mac);
}
if (Build.VERSION.SDK_INT < 30 || (identityCredential = cryptoObject.getIdentityCredential()) == null) {
return null;
}
return Api30Impl.create(identityCredential);
}
@Nullable
public static BiometricPrompt.CryptoObject unwrapFromFingerprintManager(@Nullable FingerprintManagerCompat.CryptoObject cryptoObject) {
if (cryptoObject == null) {
return null;
}
Cipher cipher = cryptoObject.getCipher();
if (cipher != null) {
return new BiometricPrompt.CryptoObject(cipher);
}
Signature signature = cryptoObject.getSignature();
if (signature != null) {
return new BiometricPrompt.CryptoObject(signature);
}
Mac mac = cryptoObject.getMac();
if (mac != null) {
return new BiometricPrompt.CryptoObject(mac);
}
return null;
}
@Nullable
public static FingerprintManagerCompat.CryptoObject wrapForFingerprintManager(@Nullable BiometricPrompt.CryptoObject cryptoObject) {
if (cryptoObject == null) {
return null;
}
Cipher cipher = cryptoObject.getCipher();
if (cipher != null) {
return new FingerprintManagerCompat.CryptoObject(cipher);
}
Signature signature = cryptoObject.getSignature();
if (signature != null) {
return new FingerprintManagerCompat.CryptoObject(signature);
}
Mac mac = cryptoObject.getMac();
if (mac != null) {
return new FingerprintManagerCompat.CryptoObject(mac);
}
if (Build.VERSION.SDK_INT >= 30 && cryptoObject.getIdentityCredential() != null) {
Log.e(TAG, "Identity credential is not supported by FingerprintManager.");
}
return null;
}
@Nullable
@RequiresApi(23)
public static BiometricPrompt.CryptoObject createFakeCryptoObject() {
try {
KeyStore keyStore = KeyStore.getInstance(KEYSTORE_INSTANCE);
keyStore.load(null);
KeyGenParameterSpec.Builder createKeyGenParameterSpecBuilder = Api23Impl.createKeyGenParameterSpecBuilder(FAKE_KEY_NAME, 3);
Api23Impl.setBlockModeCBC(createKeyGenParameterSpecBuilder);
Api23Impl.setEncryptionPaddingPKCS7(createKeyGenParameterSpecBuilder);
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES", KEYSTORE_INSTANCE);
Api23Impl.initKeyGenerator(keyGenerator, Api23Impl.buildKeyGenParameterSpec(createKeyGenParameterSpecBuilder));
keyGenerator.generateKey();
SecretKey secretKey = (SecretKey) keyStore.getKey(FAKE_KEY_NAME, null);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
cipher.init(1, secretKey);
return new BiometricPrompt.CryptoObject(cipher);
} catch (IOException | InvalidAlgorithmParameterException | InvalidKeyException | KeyStoreException | NoSuchAlgorithmException | NoSuchProviderException | UnrecoverableKeyException | CertificateException | NoSuchPaddingException e) {
Log.w(TAG, "Failed to create fake crypto object.", e);
return null;
}
}
@RequiresApi(30)
public static class Api30Impl {
private Api30Impl() {
}
@NonNull
public static BiometricPrompt.CryptoObject create(@NonNull IdentityCredential identityCredential) {
return new BiometricPrompt.CryptoObject(identityCredential);
}
@Nullable
public static IdentityCredential getIdentityCredential(@NonNull BiometricPrompt.CryptoObject cryptoObject) {
return cryptoObject.getIdentityCredential();
}
}
@RequiresApi(28)
public static class Api28Impl {
private Api28Impl() {
}
@NonNull
public static BiometricPrompt.CryptoObject create(@NonNull Cipher cipher) {
return new BiometricPrompt.CryptoObject(cipher);
}
@NonNull
public static BiometricPrompt.CryptoObject create(@NonNull Signature signature) {
return new BiometricPrompt.CryptoObject(signature);
}
@NonNull
public static BiometricPrompt.CryptoObject create(@NonNull Mac mac) {
return new BiometricPrompt.CryptoObject(mac);
}
@Nullable
public static Cipher getCipher(@NonNull BiometricPrompt.CryptoObject cryptoObject) {
return cryptoObject.getCipher();
}
@Nullable
public static Signature getSignature(@NonNull BiometricPrompt.CryptoObject cryptoObject) {
return cryptoObject.getSignature();
}
@Nullable
public static Mac getMac(@NonNull BiometricPrompt.CryptoObject cryptoObject) {
return cryptoObject.getMac();
}
}
@RequiresApi(23)
public static class Api23Impl {
private Api23Impl() {
}
@NonNull
public static KeyGenParameterSpec.Builder createKeyGenParameterSpecBuilder(@NonNull String str, int i) {
return new KeyGenParameterSpec.Builder(str, i);
}
public static void setBlockModeCBC(@NonNull KeyGenParameterSpec.Builder builder) {
builder.setBlockModes("CBC");
}
public static void setEncryptionPaddingPKCS7(@NonNull KeyGenParameterSpec.Builder builder) {
builder.setEncryptionPaddings("PKCS7Padding");
}
@NonNull
public static KeyGenParameterSpec buildKeyGenParameterSpec(@NonNull KeyGenParameterSpec.Builder builder) {
return builder.build();
}
public static void initKeyGenerator(@NonNull KeyGenerator keyGenerator, @NonNull KeyGenParameterSpec keyGenParameterSpec) throws InvalidAlgorithmParameterException {
keyGenerator.init(keyGenParameterSpec);
}
}
}

View File

@@ -0,0 +1,75 @@
package androidx.biometric;
import android.content.Context;
import android.os.Build;
import androidx.annotation.NonNull;
/* loaded from: classes.dex */
class DeviceUtils {
private DeviceUtils() {
}
public static boolean shouldUseFingerprintForCrypto(@NonNull Context context, String str, String str2) {
if (Build.VERSION.SDK_INT != 28) {
return false;
}
return isVendorInList(context, str, R.array.crypto_fingerprint_fallback_vendors) || isModelInPrefixList(context, str2, R.array.crypto_fingerprint_fallback_prefixes);
}
public static boolean shouldHideFingerprintDialog(@NonNull Context context, String str) {
if (Build.VERSION.SDK_INT != 28) {
return false;
}
return isModelInPrefixList(context, str, R.array.hide_fingerprint_instantly_prefixes);
}
public static boolean shouldDelayShowingPrompt(@NonNull Context context, String str) {
if (Build.VERSION.SDK_INT != 29) {
return false;
}
return isModelInList(context, str, R.array.delay_showing_prompt_models);
}
public static boolean canAssumeStrongBiometrics(@NonNull Context context, String str) {
if (Build.VERSION.SDK_INT >= 30) {
return false;
}
return isModelInList(context, str, R.array.assume_strong_biometrics_models);
}
private static boolean isVendorInList(@NonNull Context context, String str, int i) {
if (str == null) {
return false;
}
for (String str2 : context.getResources().getStringArray(i)) {
if (str.equalsIgnoreCase(str2)) {
return true;
}
}
return false;
}
private static boolean isModelInPrefixList(@NonNull Context context, String str, int i) {
if (str == null) {
return false;
}
for (String str2 : context.getResources().getStringArray(i)) {
if (str.startsWith(str2)) {
return true;
}
}
return false;
}
private static boolean isModelInList(@NonNull Context context, String str, int i) {
if (str == null) {
return false;
}
for (String str2 : context.getResources().getStringArray(i)) {
if (str.equals(str2)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,65 @@
package androidx.biometric;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/* loaded from: classes.dex */
class ErrorUtils {
public static boolean isKnownError(int i) {
switch (i) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
return true;
case 6:
default:
return false;
}
}
public static boolean isLockoutError(int i) {
return i == 7 || i == 9;
}
private ErrorUtils() {
}
@NonNull
public static String getFingerprintErrorString(@Nullable Context context, int i) {
if (context == null) {
return "";
}
if (i == 1) {
return context.getString(R.string.fingerprint_error_hw_not_available);
}
if (i != 7) {
switch (i) {
case 9:
break;
case 10:
return context.getString(R.string.fingerprint_error_user_canceled);
case 11:
return context.getString(R.string.fingerprint_error_no_fingerprints);
case 12:
return context.getString(R.string.fingerprint_error_hw_not_present);
default:
Log.e("BiometricUtils", "Unknown error code: " + i);
return context.getString(R.string.default_error_msg);
}
}
return context.getString(R.string.fingerprint_error_lockout);
}
}

View File

@@ -0,0 +1,271 @@
package androidx.biometric;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public class FingerprintDialogFragment extends DialogFragment {
private static final int MESSAGE_DISPLAY_TIME_MS = 2000;
static final int STATE_FINGERPRINT = 1;
static final int STATE_FINGERPRINT_AUTHENTICATED = 3;
static final int STATE_FINGERPRINT_ERROR = 2;
static final int STATE_NONE = 0;
private static final String TAG = "FingerprintFragment";
private int mErrorTextColor;
@Nullable
private ImageView mFingerprintIcon;
@Nullable
TextView mHelpMessageView;
private int mNormalTextColor;
BiometricViewModel mViewModel;
final Handler mHandler = new Handler(Looper.getMainLooper());
final Runnable mResetDialogRunnable = new Runnable() { // from class: androidx.biometric.FingerprintDialogFragment.1
@Override // java.lang.Runnable
public void run() {
FingerprintDialogFragment.this.resetDialog();
}
};
private boolean shouldAnimateForTransition(int i, int i2) {
if (i == 0 && i2 == 1) {
return false;
}
if (i == 1 && i2 == 2) {
return true;
}
return i == 2 && i2 == 1;
}
@NonNull
public static FingerprintDialogFragment newInstance() {
return new FingerprintDialogFragment();
}
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onCreate(@Nullable Bundle bundle) {
super.onCreate(bundle);
connectViewModel();
this.mErrorTextColor = getThemedColorFor(Api26Impl.getColorErrorAttr());
this.mNormalTextColor = getThemedColorFor(android.R.attr.textColorSecondary);
}
@Override // androidx.fragment.app.DialogFragment
@NonNull
public Dialog onCreateDialog(@Nullable Bundle bundle) {
CharSequence negativeButtonText;
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
builder.setTitle(this.mViewModel.getTitle());
View inflate = LayoutInflater.from(builder.getContext()).inflate(R.layout.fingerprint_dialog_layout, (ViewGroup) null);
TextView textView = (TextView) inflate.findViewById(R.id.fingerprint_subtitle);
if (textView != null) {
CharSequence subtitle = this.mViewModel.getSubtitle();
if (TextUtils.isEmpty(subtitle)) {
textView.setVisibility(8);
} else {
textView.setVisibility(0);
textView.setText(subtitle);
}
}
TextView textView2 = (TextView) inflate.findViewById(R.id.fingerprint_description);
if (textView2 != null) {
CharSequence description = this.mViewModel.getDescription();
if (TextUtils.isEmpty(description)) {
textView2.setVisibility(8);
} else {
textView2.setVisibility(0);
textView2.setText(description);
}
}
this.mFingerprintIcon = (ImageView) inflate.findViewById(R.id.fingerprint_icon);
this.mHelpMessageView = (TextView) inflate.findViewById(R.id.fingerprint_error);
if (AuthenticatorUtils.isDeviceCredentialAllowed(this.mViewModel.getAllowedAuthenticators())) {
negativeButtonText = getString(R.string.confirm_device_credential_password);
} else {
negativeButtonText = this.mViewModel.getNegativeButtonText();
}
builder.setNegativeButton(negativeButtonText, new DialogInterface.OnClickListener() { // from class: androidx.biometric.FingerprintDialogFragment.2
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
FingerprintDialogFragment.this.mViewModel.setNegativeButtonPressPending(true);
}
});
builder.setView(inflate);
AlertDialog create = builder.create();
create.setCanceledOnTouchOutside(false);
return create;
}
@Override // androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
this.mViewModel.setFingerprintDialogPreviousState(0);
this.mViewModel.setFingerprintDialogState(1);
this.mViewModel.setFingerprintDialogHelpMessage(getString(R.string.fingerprint_dialog_touch_sensor));
}
@Override // androidx.fragment.app.Fragment
public void onPause() {
super.onPause();
this.mHandler.removeCallbacksAndMessages(null);
}
@Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnCancelListener
public void onCancel(@NonNull DialogInterface dialogInterface) {
super.onCancel(dialogInterface);
this.mViewModel.setFingerprintDialogCancelPending(true);
}
private void connectViewModel() {
FragmentActivity activity = getActivity();
if (activity == null) {
return;
}
BiometricViewModel biometricViewModel = (BiometricViewModel) new ViewModelProvider(activity).get(BiometricViewModel.class);
this.mViewModel = biometricViewModel;
biometricViewModel.getFingerprintDialogState().observe(this, new Observer<Integer>() { // from class: androidx.biometric.FingerprintDialogFragment.3
@Override // androidx.lifecycle.Observer
public void onChanged(Integer num) {
FingerprintDialogFragment fingerprintDialogFragment = FingerprintDialogFragment.this;
fingerprintDialogFragment.mHandler.removeCallbacks(fingerprintDialogFragment.mResetDialogRunnable);
FingerprintDialogFragment.this.updateFingerprintIcon(num.intValue());
FingerprintDialogFragment.this.updateHelpMessageColor(num.intValue());
FingerprintDialogFragment fingerprintDialogFragment2 = FingerprintDialogFragment.this;
fingerprintDialogFragment2.mHandler.postDelayed(fingerprintDialogFragment2.mResetDialogRunnable, 2000L);
}
});
this.mViewModel.getFingerprintDialogHelpMessage().observe(this, new Observer<CharSequence>() { // from class: androidx.biometric.FingerprintDialogFragment.4
@Override // androidx.lifecycle.Observer
public void onChanged(CharSequence charSequence) {
FingerprintDialogFragment fingerprintDialogFragment = FingerprintDialogFragment.this;
fingerprintDialogFragment.mHandler.removeCallbacks(fingerprintDialogFragment.mResetDialogRunnable);
FingerprintDialogFragment.this.updateHelpMessageText(charSequence);
FingerprintDialogFragment fingerprintDialogFragment2 = FingerprintDialogFragment.this;
fingerprintDialogFragment2.mHandler.postDelayed(fingerprintDialogFragment2.mResetDialogRunnable, 2000L);
}
});
}
public void updateFingerprintIcon(int i) {
int fingerprintDialogPreviousState;
Drawable assetForTransition;
if (this.mFingerprintIcon == null || (assetForTransition = getAssetForTransition((fingerprintDialogPreviousState = this.mViewModel.getFingerprintDialogPreviousState()), i)) == null) {
return;
}
this.mFingerprintIcon.setImageDrawable(assetForTransition);
if (shouldAnimateForTransition(fingerprintDialogPreviousState, i)) {
Api21Impl.startAnimation(assetForTransition);
}
this.mViewModel.setFingerprintDialogPreviousState(i);
}
public void updateHelpMessageColor(int i) {
TextView textView = this.mHelpMessageView;
if (textView != null) {
textView.setTextColor(i == 2 ? this.mErrorTextColor : this.mNormalTextColor);
}
}
public void updateHelpMessageText(@Nullable CharSequence charSequence) {
TextView textView = this.mHelpMessageView;
if (textView != null) {
textView.setText(charSequence);
}
}
public void resetDialog() {
Context context = getContext();
if (context == null) {
Log.w(TAG, "Not resetting the dialog. Context is null.");
} else {
this.mViewModel.setFingerprintDialogState(1);
this.mViewModel.setFingerprintDialogHelpMessage(context.getString(R.string.fingerprint_dialog_touch_sensor));
}
}
private int getThemedColorFor(int i) {
Context context = getContext();
FragmentActivity activity = getActivity();
if (context == null || activity == null) {
Log.w(TAG, "Unable to get themed color. Context or activity is null.");
return 0;
}
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(i, typedValue, true);
TypedArray obtainStyledAttributes = activity.obtainStyledAttributes(typedValue.data, new int[]{i});
int color = obtainStyledAttributes.getColor(0, 0);
obtainStyledAttributes.recycle();
return color;
}
private Drawable getAssetForTransition(int i, int i2) {
int i3;
Context context = getContext();
if (context == null) {
Log.w(TAG, "Unable to get asset. Context is null.");
return null;
}
if (i == 0 && i2 == 1) {
i3 = R.drawable.fingerprint_dialog_fp_icon;
} else if (i == 1 && i2 == 2) {
i3 = R.drawable.fingerprint_dialog_error;
} else if (i == 2 && i2 == 1) {
i3 = R.drawable.fingerprint_dialog_fp_icon;
} else {
if (i != 1 || i2 != 3) {
return null;
}
i3 = R.drawable.fingerprint_dialog_fp_icon;
}
return ContextCompat.getDrawable(context, i3);
}
@RequiresApi(26)
public static class Api26Impl {
public static int getColorErrorAttr() {
return R.attr.colorError;
}
private Api26Impl() {
}
}
@RequiresApi(21)
public static class Api21Impl {
private Api21Impl() {
}
public static void startAnimation(@NonNull Drawable drawable) {
if (drawable instanceof AnimatedVectorDrawable) {
((AnimatedVectorDrawable) drawable).start();
}
}
}
}

View File

@@ -0,0 +1,51 @@
package androidx.biometric;
import android.app.KeyguardManager;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
/* loaded from: classes.dex */
class KeyguardUtils {
private KeyguardUtils() {
}
@Nullable
public static KeyguardManager getKeyguardManager(@NonNull Context context) {
return Api23Impl.getKeyguardManager(context);
}
public static boolean isDeviceSecuredWithCredential(@NonNull Context context) {
KeyguardManager keyguardManager = getKeyguardManager(context);
if (keyguardManager == null) {
return false;
}
return Api23Impl.isDeviceSecure(keyguardManager);
}
@RequiresApi(23)
public static class Api23Impl {
private Api23Impl() {
}
@Nullable
public static KeyguardManager getKeyguardManager(@NonNull Context context) {
return (KeyguardManager) context.getSystemService(KeyguardManager.class);
}
public static boolean isDeviceSecure(@NonNull KeyguardManager keyguardManager) {
return keyguardManager.isDeviceSecure();
}
}
@RequiresApi(16)
public static class Api16Impl {
private Api16Impl() {
}
public static boolean isKeyguardSecure(@NonNull KeyguardManager keyguardManager) {
return keyguardManager.isKeyguardSecure();
}
}
}

View File

@@ -0,0 +1,27 @@
package androidx.biometric;
import android.content.Context;
import android.content.pm.PackageManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
/* loaded from: classes.dex */
class PackageUtils {
private PackageUtils() {
}
public static boolean hasSystemFeatureFingerprint(@Nullable Context context) {
return (context == null || context.getPackageManager() == null || !Api23Impl.hasSystemFeatureFingerprint(context.getPackageManager())) ? false : true;
}
@RequiresApi(23)
public static class Api23Impl {
private Api23Impl() {
}
public static boolean hasSystemFeatureFingerprint(@NonNull PackageManager packageManager) {
return packageManager.hasSystemFeature("android.hardware.fingerprint");
}
}
}

File diff suppressed because one or more lines are too long