1

There is a method for creating intent for asking user to authenticate. It was prompting to authenticate with biometrics (if exists) or with PIN/Pattern/Password if no biometrics enrolled. Now it is deprecated and suggests to build biometric prompt manually. But in the source code I see almost the same public method that returns same intent, but requesting another parameter - userId

/**
 * Get an intent to prompt the user to confirm credentials (pin, pattern or password)
 * for the given user. The caller is expected to launch this activity using
 * {@link android.app.Activity#startActivityForResult(Intent, int)} and check for
 * {@link android.app.Activity#RESULT_OK} if the user successfully completes the challenge.
 *
 * @return the intent for launching the activity or null if no password is required.
 *
 * @hide
 */
public Intent createConfirmDeviceCredentialIntent(
        CharSequence title, CharSequence description, int userId) {
    if (!isDeviceSecure(userId)) return null;
    Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER);
    intent.putExtra(EXTRA_TITLE, title);
    intent.putExtra(EXTRA_DESCRIPTION, description);
    intent.putExtra(Intent.EXTRA_USER_ID, userId);

    // explicitly set the package for security
    intent.setPackage(getSettingsPackageForIntent(intent));

    return intent;
}

Now there is no explanation what is userId expected in this method. Can someone point me to the relevant documentation, please? And second, is it better than building biometric prompt by myself and handling all its states ? I'm using currently

implementation 'androidx.biometric:biometric:1.2.0-alpha04
Evgeniy Mishustin
  • 3,343
  • 3
  • 42
  • 81
  • I'm having the same extenstential crisis right now. What is the point of the androidx.biometric.auth package if it doesn't support either Class 3 biometrics OR lock screen authentication (before API 30) when this method in KeyguardManager exists? – var47 Mar 10 '23 at 21:34

1 Answers1

0

From what I can tell by looking through the Android Git history, it seems like this API has been around since 2015 and probably should have been deprecated in 2020 like the other method, but was missed since it is annotated @hide (and thus hidden from the API documentation).

https://android.googlesource.com/platform/frameworks/base/+blame/master/core/java/android/app/KeyguardManager.java

var47
  • 422
  • 3
  • 6