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

Commit 54a5f51d authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Update settings together with frameworks/base"

parents dcd910ed 20249436
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -104,13 +104,13 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
                        .getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
                final int userId = getIntent()
                        .getIntExtra(Intent.EXTRA_USER_ID, UserHandle.USER_NULL);
                final byte[] gkPw = getIntent().getByteArrayExtra(
                        ChooseLockSettingsHelper.EXTRA_KEY_GK_PW);
                final long gkPwHandle = getIntent().getLongExtra(
                        ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, 0L);

                intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
                intent.putExtra(Intent.EXTRA_USER_ID, userId);
                if (gkPw != null) {
                    intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW, gkPw);
                if (gkPwHandle != 0L) {
                    intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, gkPwHandle);
                }
            }

+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
        final ChooseLockSettingsHelper.Builder builder = new ChooseLockSettingsHelper.Builder(this);
        builder.setRequestCode(CONFIRM_REQUEST)
                .setTitle(getString(titleResId))
                .setRequestGatekeeperPassword(true)
                .setRequestGatekeeperPasswordHandle(true)
                .setForegroundOnly(true)
                .setReturnCredentials(true);

+3 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW, true);
        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
        intent.putExtra(getExtraKeyForBiometric(), true);
        if (mUserId != UserHandle.USER_NULL) {
            intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
@@ -278,6 +278,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
                getNextButton().setEnabled(false);
                getChallenge(((sensorId, challenge) -> {
                    mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
                    BiometricUtils.removeGatekeeperPasswordHandle(this, data);
                    getNextButton().setEnabled(true);
                }));
            } else {
@@ -291,6 +292,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
                getNextButton().setEnabled(false);
                getChallenge(((sensorId, challenge) -> {
                    mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
                    BiometricUtils.removeGatekeeperPasswordHandle(this, data);
                    getNextButton().setEnabled(true);
                }));
            } else {
+28 −7
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.settings.biometrics;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

@@ -39,20 +38,42 @@ public class BiometricUtils {
     */
    public static byte[] requestGatekeeperHat(Context context, Intent result, int userId,
            long challenge) {
        final byte[] gkPassword = result.getByteArrayExtra(
                ChooseLockSettingsHelper.EXTRA_KEY_GK_PW);
        if (gkPassword == null) {
            throw new IllegalStateException("Gatekeeper Password is null!!");
        final long gatekeeperPasswordHandle = result.getLongExtra(
                ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, 0L);
        if (gatekeeperPasswordHandle == 0L) {
            throw new IllegalStateException("Gatekeeper Password is missing!!");
        }

        final LockPatternUtils utils = new LockPatternUtils(context);
        return utils.verifyGatekeeperPassword(gkPassword, challenge, userId).getGatekeeperHAT();
        return utils.verifyGatekeeperPasswordHandle(gatekeeperPasswordHandle, challenge, userId)
                .getGatekeeperHAT();
    }

    public static boolean containsGatekeeperPassword(Intent data) {
        if (data == null) {
            return false;
        }
        return data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW) != null;
        return data.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, 0L) != 0L;
    }

    /**
     * Requests {@link com.android.server.locksettings.LockSettingsService} to remove the
     * gatekeeper password associated with a previous
     * {@link ChooseLockSettingsHelper.Builder#setRequestGatekeeperPasswordHandle(boolean)}
     *
     * @param context Caller's context
     * @param data The onActivityResult intent from ChooseLock* or ConfirmLock*
     */
    public static void removeGatekeeperPasswordHandle(Context context, Intent data) {
        if (data == null) {
            return;
        }
        final long gatekeeperPasswordsHandle = data.getLongExtra(
                ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, 0L);
        if (gatekeeperPasswordsHandle == 0L) {
            return;
        }
        final LockPatternUtils utils = new LockPatternUtils(context);
        utils.removeGatekeeperPasswordHandle(gatekeeperPasswordsHandle);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
            // the challenge is ready. Let's just do this for now.
            mFaceManager.generateChallenge((sensorId, challenge) -> {
                mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
                BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
                mFooterBarMixin.getPrimaryButton().setEnabled(true);
            });
        }
Loading