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

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23629341

Change-Id: I58bc332082495cf4451228aa8179f6d2e6a2c73b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Rhed Jao
2023-06-15 06:34:53 +00:00
committed by Automerger Merge Worker
8 changed files with 68 additions and 8 deletions

View File

@@ -2398,6 +2398,7 @@
<action android:name="android.app.action.CONFIRM_DEVICE_CREDENTIAL" /> <action android:name="android.app.action.CONFIRM_DEVICE_CREDENTIAL" />
<action android:name="android.app.action.CONFIRM_FRP_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.PREPARE_REPAIR_MODE_DEVICE_CREDENTIAL" />
<action android:name="android.app.action.CONFIRM_REPAIR_MODE_DEVICE_CREDENTIAL" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>

View File

@@ -3495,6 +3495,18 @@
<!-- Checkbox label to set password as new screen lock if remote device credential validation succeeds. [CHAR LIMIT=43] --> <!-- 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> <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 <!-- Security & location settings screen, change security method screen instruction if user
enters incorrect PIN [CHAR LIMIT=30] --> enters incorrect PIN [CHAR LIMIT=30] -->

View File

@@ -708,9 +708,13 @@ public final class Utils extends com.android.settingslib.Utils {
final int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId()); final int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
if (userId == LockPatternUtils.USER_FRP) { if (userId == LockPatternUtils.USER_FRP) {
return allowAnyUser ? userId : checkUserOwnsFrpCredential(context, userId); 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."); + " 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. * Returns the given user id if it belongs to the current user.
* *

View File

@@ -362,7 +362,8 @@ public final class ChooseLockSettingsHelper {
} }
@NonNull public ChooseLockSettingsHelper build() { @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); Utils.enforceSameOwner(mActivity, mUserId);
} }

View File

@@ -166,8 +166,12 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
mDetails = intent.getCharSequenceExtra(KeyguardManager.EXTRA_DESCRIPTION); mDetails = intent.getCharSequenceExtra(KeyguardManager.EXTRA_DESCRIPTION);
String alternateButton = intent.getStringExtra( String alternateButton = intent.getStringExtra(
KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL); KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL);
boolean frp = KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction()); final boolean frp =
boolean remoteValidation = 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()); KeyguardManager.ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL.equals(intent.getAction());
mTaskOverlay = isInternalActivity() mTaskOverlay = isInternalActivity()
&& intent.getBooleanExtra(KeyguardManager.EXTRA_FORCE_TASK_OVERLAY, false); && intent.getBooleanExtra(KeyguardManager.EXTRA_FORCE_TASK_OVERLAY, false);
@@ -222,6 +226,14 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
.setExternal(true) .setExternal(true)
.setUserId(LockPatternUtils.USER_FRP) .setUserId(LockPatternUtils.USER_FRP)
.show(); .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) { } else if (remoteValidation) {
RemoteLockscreenValidationSession remoteLockscreenValidationSession = RemoteLockscreenValidationSession remoteLockscreenValidationSession =
intent.getParcelableExtra( intent.getParcelableExtra(

View File

@@ -106,6 +106,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
protected boolean mFrp; protected boolean mFrp;
protected boolean mRemoteValidation; protected boolean mRemoteValidation;
protected boolean mRequestWriteRepairModePassword; protected boolean mRequestWriteRepairModePassword;
protected boolean mRepairMode;
protected CharSequence mAlternateButtonText; protected CharSequence mAlternateButtonText;
protected BiometricManager mBiometricManager; protected BiometricManager mBiometricManager;
@Nullable protected RemoteLockscreenValidationSession mRemoteLockscreenValidationSession; @Nullable protected RemoteLockscreenValidationSession mRemoteLockscreenValidationSession;
@@ -181,6 +182,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras(), mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras(),
isInternalActivity()); isInternalActivity());
mFrp = (mUserId == LockPatternUtils.USER_FRP); mFrp = (mUserId == LockPatternUtils.USER_FRP);
mRepairMode = (mUserId == LockPatternUtils.USER_REPAIR_MODE);
mUserManager = UserManager.get(getActivity()); mUserManager = UserManager.get(getActivity());
mEffectiveUserId = mUserManager.getCredentialOwnerProfile(mUserId); mEffectiveUserId = mUserManager.getCredentialOwnerProfile(mUserId);
mLockPatternUtils = new LockPatternUtils(getActivity()); mLockPatternUtils = new LockPatternUtils(getActivity());
@@ -269,7 +271,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
// verifyTiedProfileChallenge. In such case, we also wanna show the user message that // verifyTiedProfileChallenge. In such case, we also wanna show the user message that
// fingerprint is disabled due to device restart. // fingerprint is disabled due to device restart.
protected boolean isStrongAuthRequired() { protected boolean isStrongAuthRequired() {
return mFrp return mFrp || mRepairMode
|| !mLockPatternUtils.isBiometricAllowedForUser(mEffectiveUserId) || !mLockPatternUtils.isBiometricAllowedForUser(mEffectiveUserId)
|| !mUserManager.isUserUnlocked(mUserId); || !mUserManager.isUserUnlocked(mUserId);
} }

View File

@@ -284,6 +284,11 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
return mIsAlpha ? getString(R.string.lockpassword_confirm_your_password_header_frp) return mIsAlpha ? getString(R.string.lockpassword_confirm_your_password_header_frp)
: getString(R.string.lockpassword_confirm_your_pin_header_frp); : getString(R.string.lockpassword_confirm_your_pin_header_frp);
} }
if (mRepairMode) {
return mIsAlpha
? getString(R.string.lockpassword_confirm_repair_mode_password_header)
: getString(R.string.lockpassword_confirm_repair_mode_pin_header);
}
if (mRemoteValidation) { if (mRemoteValidation) {
return getString(R.string.lockpassword_remote_validation_header); return getString(R.string.lockpassword_remote_validation_header);
} }
@@ -307,6 +312,11 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
return mIsAlpha ? getString(R.string.lockpassword_confirm_your_password_details_frp) return mIsAlpha ? getString(R.string.lockpassword_confirm_your_password_details_frp)
: getString(R.string.lockpassword_confirm_your_pin_details_frp); : getString(R.string.lockpassword_confirm_your_pin_details_frp);
} }
if (mRepairMode) {
return mIsAlpha
? getString(R.string.lockpassword_confirm_repair_mode_password_details)
: getString(R.string.lockpassword_confirm_repair_mode_pin_details);
}
if (mRemoteValidation) { if (mRemoteValidation) {
return getContext().getString(mIsAlpha return getContext().getString(mIsAlpha
? R.string.lockpassword_remote_validation_password_details ? R.string.lockpassword_remote_validation_password_details

View File

@@ -179,7 +179,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
// ability to disable the pattern in L. Remove this block after // ability to disable the pattern in L. Remove this block after
// ensuring it's safe to do so. (Note that ConfirmLockPassword // ensuring it's safe to do so. (Note that ConfirmLockPassword
// doesn't have this). // doesn't have this).
if (!mFrp && !mRemoteValidation if (!mFrp && !mRemoteValidation && !mRepairMode
&& !mLockPatternUtils.isLockPatternEnabled(mEffectiveUserId)) { && !mLockPatternUtils.isLockPatternEnabled(mEffectiveUserId)) {
getActivity().setResult(Activity.RESULT_OK); getActivity().setResult(Activity.RESULT_OK);
getActivity().finish(); getActivity().finish();
@@ -308,6 +308,9 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
if (mFrp) { if (mFrp) {
return getString(R.string.lockpassword_confirm_your_pattern_details_frp); return getString(R.string.lockpassword_confirm_your_pattern_details_frp);
} }
if (mRepairMode) {
return getString(R.string.lockpassword_confirm_repair_mode_pattern_details);
}
if (mRemoteValidation) { if (mRemoteValidation) {
return getString( return getString(
R.string.lockpassword_remote_validation_pattern_details); R.string.lockpassword_remote_validation_pattern_details);
@@ -402,7 +405,12 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
} }
private String getDefaultHeader() { private String getDefaultHeader() {
if (mFrp) return getString(R.string.lockpassword_confirm_your_pattern_header_frp); if (mFrp) {
return getString(R.string.lockpassword_confirm_your_pattern_header_frp);
}
if (mRepairMode) {
return getString(R.string.lockpassword_confirm_repair_mode_pattern_header);
}
if (mRemoteValidation) { if (mRemoteValidation) {
return getString(R.string.lockpassword_remote_validation_header); return getString(R.string.lockpassword_remote_validation_header);
} }