Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d75a03b7 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Add plumbing for setRequireConfirmation to CC

Bug: 111461540

Test: Builds
Change-Id: I3fdb93282ceea091a459d014759ba747892f1a8c
parent cf2f6e74
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -100,6 +100,12 @@ public class KeyguardManager {
     */
    public static final String EXTRA_DESCRIPTION = "android.app.extra.DESCRIPTION";

    /**
     * A boolean value to forward to {@link android.hardware.biometrics.BiometricPrompt}.
     * @hide
     */
    public static final String EXTRA_USE_IMPLICIT = "android.app.extra.USE_IMPLICIT";

    /**
     * A CharSequence description to show to the user on the alternate button when used with
     * {@link #ACTION_CONFIRM_FRP_CREDENTIAL}.
@@ -123,14 +129,39 @@ public class KeyguardManager {
     * {@link android.app.Activity#startActivityForResult(Intent, int)} and check for
     * {@link android.app.Activity#RESULT_OK} if the user successfully completes the challenge.
     *
     * @param title Title to be shown on the dialog.
     * @param description Description to be shown on the dialog.
     * @return the intent for launching the activity or null if no password is required.
     **/
    @RequiresFeature(PackageManager.FEATURE_SECURE_LOCK_SCREEN)
    public Intent createConfirmDeviceCredentialIntent(CharSequence title, CharSequence description) {
        if (!isDeviceSecure()) return null;
        return createConfirmDeviceCredentialIntent(title, description, false /* useImplicit */);
    }

    /**
     * Get an intent to prompt the user to confirm credentials (pin, pattern or password)
     * for the current user of the device. 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.
     *
     * @param title Title to be shown on the dialog.
     * @param description Description to be shown on the dialog.
     * @param useImplicit If useImplicit is set to true, ConfirmDeviceCredentials will invoke
     *      {@link android.hardware.biometrics.BiometricPrompt} with
     *      {@link android.hardware.biometrics.BiometricPrompt.Builder#setRequireConfirmation(
     *      boolean)} set to false.
     * @return the intent for launching the activity or null if no password is required.
     * @hide
     */
    public Intent createConfirmDeviceCredentialIntent(CharSequence title, CharSequence description,
            boolean useImplicit) {
        if (!isDeviceSecure()) {
            return null;
        }
        Intent intent = new Intent(ACTION_CONFIRM_DEVICE_CREDENTIAL);
        intent.putExtra(EXTRA_TITLE, title);
        intent.putExtra(EXTRA_DESCRIPTION, description);
        intent.putExtra(EXTRA_USE_IMPLICIT, useImplicit);

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