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

Commit e1c9d65c authored by Rhed Jao's avatar Rhed Jao Committed by Android (Google) Code Review
Browse files

Merge "[Settings] Add a verification flow for exiting repair mode" into udc-qpr-dev

parents 8617f638 b7a4a7da
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2398,6 +2398,7 @@
                <action android:name="android.app.action.CONFIRM_DEVICE_CREDENTIAL" />
                <action android:name="android.app.action.CONFIRM_FRP_CREDENTIAL" />
                <action android:name="android.app.action.PREPARE_REPAIR_MODE_DEVICE_CREDENTIAL" />
                <action android:name="android.app.action.CONFIRM_REPAIR_MODE_DEVICE_CREDENTIAL" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
+12 −0
Original line number Diff line number Diff line
@@ -3495,6 +3495,18 @@
    <!-- Checkbox label to set password as new screen lock if remote device credential validation succeeds. [CHAR LIMIT=43] -->
    <string name="lockpassword_remote_validation_set_password_as_screenlock">Also use password to unlock this device</string>
    <!-- Header shown when pattern needs to be solved before the device exits repair mode. [CHAR LIMIT=100] [DO NOT TRANSLATE] TODO(b/275677027): update with finalized UX string -->
    <string name="lockpassword_confirm_repair_mode_pattern_header">Verify pattern</string>
    <!-- Header shown when the pin needs to be solved before the device exits repair mode. [CHAR LIMIT=100] [DO NOT TRANSLATE] TODO(b/275677027): update with finalized UX string -->
    <string name="lockpassword_confirm_repair_mode_pin_header">Verify PIN</string>
    <!-- Header shown when the password needs to be solved before the device exits repair mode. [CHAR LIMIT=100] [DO NOT TRANSLATE] TODO(b/275677027): update with finalized UX string -->
    <string name="lockpassword_confirm_repair_mode_password_header">Verify password</string>
    <!-- An explanation text that the pattern needs to be solved before the device exits repair mode. [CHAR LIMIT=100] [DO NOT TRANSLATE] TODO(b/275677027): update with finalized UX string -->
    <string name="lockpassword_confirm_repair_mode_pattern_details" translatable="false">Enter your device pattern enrolled in normal mode to continue</string>
    <!-- An explanation text that the PIN needs to be solved before the device exits repair mode. [CHAR LIMIT=100] [DO NOT TRANSLATE] TODO(b/275677027): update with finalized UX string -->
    <string name="lockpassword_confirm_repair_mode_pin_details" translatable="false">Enter your device PIN enrolled in normal mode to continue</string>
    <!-- An explanation text that the password needs to be solved before the device exits repair mode. [CHAR LIMIT=100] [DO NOT TRANSLATE] TODO(b/275677027): update with finalized UX string -->
    <string name="lockpassword_confirm_repair_mode_password_details" translatable="false">Enter your device password enrolled in normal mode to continue</string>
    <!-- Security & location settings screen, change security method screen instruction if user
         enters incorrect PIN [CHAR LIMIT=30] -->
+16 −2
Original line number Diff line number Diff line
@@ -708,9 +708,13 @@ public final class Utils extends com.android.settingslib.Utils {
        final int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
        if (userId == LockPatternUtils.USER_FRP) {
            return allowAnyUser ? userId : checkUserOwnsFrpCredential(context, userId);
        } else {
            return allowAnyUser ? userId : enforceSameOwner(context, userId);
        }
        if (userId == LockPatternUtils.USER_REPAIR_MODE) {
            enforceRepairModeActive(context);
            // any users can exit repair mode
            return userId;
        }
        return allowAnyUser ? userId : enforceSameOwner(context, userId);
    }

    /**
@@ -729,6 +733,16 @@ public final class Utils extends com.android.settingslib.Utils {
                + " does not own frp credential.");
    }

    /**
     * Throws {@link SecurityException} if repair mode is not active on the device.
     */
    private static void enforceRepairModeActive(Context context) {
        if (LockPatternUtils.isRepairModeActive(context)) {
            return;
        }
        throw new SecurityException("Repair mode is not active on the device.");
    }

    /**
     * Returns the given user id if it belongs to the current user.
     *
+2 −1
Original line number Diff line number Diff line
@@ -362,7 +362,8 @@ public final class ChooseLockSettingsHelper {
        }

        @NonNull public ChooseLockSettingsHelper build() {
            if (!mAllowAnyUserId && mUserId != LockPatternUtils.USER_FRP) {
            if (!mAllowAnyUserId && mUserId != LockPatternUtils.USER_FRP
                    && mUserId != LockPatternUtils.USER_REPAIR_MODE) {
                Utils.enforceSameOwner(mActivity, mUserId);
            }

+14 −2
Original line number Diff line number Diff line
@@ -166,8 +166,12 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
        mDetails = intent.getCharSequenceExtra(KeyguardManager.EXTRA_DESCRIPTION);
        String alternateButton = intent.getStringExtra(
                KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL);
        boolean frp = KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction());
        boolean remoteValidation =
        final boolean frp =
                KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction());
        final boolean repairMode =
                KeyguardManager.ACTION_CONFIRM_REPAIR_MODE_DEVICE_CREDENTIAL
                        .equals(intent.getAction());
        final boolean remoteValidation =
                KeyguardManager.ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL.equals(intent.getAction());
        mTaskOverlay = isInternalActivity()
                && intent.getBooleanExtra(KeyguardManager.EXTRA_FORCE_TASK_OVERLAY, false);
@@ -222,6 +226,14 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
                    .setExternal(true)
                    .setUserId(LockPatternUtils.USER_FRP)
                    .show();
        } else if (repairMode) {
            final ChooseLockSettingsHelper.Builder builder =
                    new ChooseLockSettingsHelper.Builder(this);
            launchedCDC = builder.setHeader(mTitle)
                    .setDescription(mDetails)
                    .setExternal(true)
                    .setUserId(LockPatternUtils.USER_REPAIR_MODE)
                    .show();
        } else if (remoteValidation) {
            RemoteLockscreenValidationSession remoteLockscreenValidationSession =
                    intent.getParcelableExtra(
Loading