diff options
author | josephpv <josephpv@google.com> | 2023-12-11 11:34:00 +0000 |
---|---|---|
committer | Ellen Arteca <emarteca@google.com> | 2024-04-02 23:12:43 +0000 |
commit | e1acfb3db1282143ec859ae5e9be0e014cd22300 (patch) | |
tree | 8fdc4fd2cc308ac3a25ec9ec811ae4a423782d69 | |
parent | 1614fc418018ce0f458a0761198e1373522a01af (diff) | |
download | Settings-e1acfb3db1282143ec859ae5e9be0e014cd22300.tar.gz |
Show customized message for private space while choosing lock
The change adds private profile checks in addition to the exisiting
managed profile check to show customized message while choosing lock for
private profile in Pattern, PIN and Password screens.
Bug: 311343571
Test: Verify lock screen message for private space
Change-Id: Ic8173ff8c1af23fc593390acaff4c67390f99b9c
Merged-In: Ic8173ff8c1af23fc593390acaff4c67390f99b9c
4 files changed, 70 insertions, 16 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 9f4f8e53a91..bf5643a58c2 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1315,6 +1315,12 @@ <string name="private_space_lock_setup_title">Choose a lock for your private space</string> <!-- private space lock setup screen description [CHAR LIMIT=NONE] --> <string name="private_space_lock_setup_description">You can unlock your private space using your fingerprint. For security, this option requires a backup lock.</string> + <!-- Header for private space choose your PIN screen [CHAR LIMIT=40] --> + <string name="private_space_choose_your_pin_header">Set a PIN for your private space</string> + <!-- Header for private space choose your password screen [CHAR LIMIT=40] --> + <string name="private_space_choose_your_password_header">Set a password for your private space</string> + <!-- Header for private space choose your pattern screen [CHAR LIMIT=40] --> + <string name="private_space_choose_your_pattern_header">Set a pattern for your private space</string> <!-- TODO(b/309950257): Remove below strings once QSTIle fulfillment is complete. --> <!-- Header in hide Private Space settings page to unhide Private Space. [CHAR LIMIT=90] --> diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java index 800adb063cb..97d4d913454 100644 --- a/src/com/android/settings/password/ChooseLockPassword.java +++ b/src/com/android/settings/password/ChooseLockPassword.java @@ -260,7 +260,6 @@ public class ChooseLockPassword extends SettingsActivity { private LockscreenCredential mFirstPassword; private RecyclerView mPasswordRestrictionView; protected boolean mIsAlphaMode; - protected boolean mIsManagedProfile; protected FooterButton mSkipOrClearButton; private FooterButton mNextButton; private TextView mMessage; @@ -272,6 +271,14 @@ public class ChooseLockPassword extends SettingsActivity { private static final int CONFIRM_EXISTING_REQUEST = 58; static final int RESULT_FINISHED = RESULT_FIRST_USER; + /** Used to store the profile type for which pin/password is being set */ + protected enum ProfileType { + None, + Managed, + Private, + Other + }; + protected ProfileType mProfileType; /** * Keep track internally of where the user is in choosing a pattern. @@ -285,12 +292,14 @@ public class ChooseLockPassword extends SettingsActivity { R.string.lockpassword_choose_your_password_header_for_fingerprint, R.string.lockpassword_choose_your_password_header_for_face, R.string.lockpassword_choose_your_password_header_for_biometrics, + R.string.private_space_choose_your_password_header, // private space password R.string.lockpassword_choose_your_pin_header, // pin SET_WORK_PROFILE_PIN_HEADER, R.string.lockpassword_choose_your_profile_pin_header, R.string.lockpassword_choose_your_pin_header_for_fingerprint, R.string.lockpassword_choose_your_pin_header_for_face, R.string.lockpassword_choose_your_pin_header_for_biometrics, + R.string.private_space_choose_your_pin_header, // private space pin R.string.lock_settings_picker_biometrics_added_security_message, R.string.lock_settings_picker_biometrics_added_security_message, R.string.next_label), @@ -302,12 +311,14 @@ public class ChooseLockPassword extends SettingsActivity { R.string.lockpassword_confirm_your_password_header, R.string.lockpassword_confirm_your_password_header, R.string.lockpassword_confirm_your_password_header, + R.string.lockpassword_confirm_your_password_header, R.string.lockpassword_confirm_your_pin_header, REENTER_WORK_PROFILE_PIN_HEADER, R.string.lockpassword_reenter_your_profile_pin_header, R.string.lockpassword_confirm_your_pin_header, R.string.lockpassword_confirm_your_pin_header, R.string.lockpassword_confirm_your_pin_header, + R.string.lockpassword_confirm_your_pin_header, 0, 0, R.string.lockpassword_confirm_label), @@ -319,12 +330,14 @@ public class ChooseLockPassword extends SettingsActivity { R.string.lockpassword_confirm_passwords_dont_match, R.string.lockpassword_confirm_passwords_dont_match, R.string.lockpassword_confirm_passwords_dont_match, + R.string.lockpassword_confirm_passwords_dont_match, R.string.lockpassword_confirm_pins_dont_match, UNDEFINED, R.string.lockpassword_confirm_pins_dont_match, R.string.lockpassword_confirm_pins_dont_match, R.string.lockpassword_confirm_pins_dont_match, R.string.lockpassword_confirm_pins_dont_match, + R.string.lockpassword_confirm_pins_dont_match, 0, 0, R.string.lockpassword_confirm_label); @@ -335,29 +348,33 @@ public class ChooseLockPassword extends SettingsActivity { int hintInAlphaForFingerprint, int hintInAlphaForFace, int hintInAlphaForBiometrics, + int hintInAlphaForPrivateProfile, int hintInNumeric, String hintOverrideInNumericForProfile, int hintInNumericForProfile, int hintInNumericForFingerprint, int hintInNumericForFace, int hintInNumericForBiometrics, + int hintInNumericForPrivateProfile, int messageInAlphaForBiometrics, int messageInNumericForBiometrics, int nextButtonText) { this.alphaHint = hintInAlpha; this.alphaHintOverrideForProfile = hintOverrideInAlphaForProfile; - this.alphaHintForProfile = hintInAlphaForProfile; + this.alphaHintForManagedProfile = hintInAlphaForProfile; this.alphaHintForFingerprint = hintInAlphaForFingerprint; this.alphaHintForFace = hintInAlphaForFace; this.alphaHintForBiometrics = hintInAlphaForBiometrics; + this.alphaHintForPrivateProfile = hintInAlphaForPrivateProfile; this.numericHint = hintInNumeric; this.numericHintOverrideForProfile = hintOverrideInNumericForProfile; - this.numericHintForProfile = hintInNumericForProfile; + this.numericHintForManagedProfile = hintInNumericForProfile; this.numericHintForFingerprint = hintInNumericForFingerprint; this.numericHintForFace = hintInNumericForFace; this.numericHintForBiometrics = hintInNumericForBiometrics; + this.numericHintForPrivateProfile = hintInNumericForPrivateProfile; this.alphaMessageForBiometrics = messageInAlphaForBiometrics; this.numericMessageForBiometrics = messageInNumericForBiometrics; @@ -372,16 +389,18 @@ public class ChooseLockPassword extends SettingsActivity { // Password header public final int alphaHint; + public final int alphaHintForPrivateProfile; public final String alphaHintOverrideForProfile; - public final int alphaHintForProfile; + public final int alphaHintForManagedProfile; public final int alphaHintForFingerprint; public final int alphaHintForFace; public final int alphaHintForBiometrics; // PIN header public final int numericHint; + public final int numericHintForPrivateProfile; public final String numericHintOverrideForProfile; - public final int numericHintForProfile; + public final int numericHintForManagedProfile; public final int numericHintForFingerprint; public final int numericHintForFace; public final int numericHintForBiometrics; @@ -394,34 +413,40 @@ public class ChooseLockPassword extends SettingsActivity { public final int buttonText; - public String getHint(Context context, boolean isAlpha, int type, boolean isProfile) { + public String getHint(Context context, boolean isAlpha, int type, ProfileType profile) { if (isAlpha) { - if (type == TYPE_FINGERPRINT) { + if (android.os.Flags.allowPrivateProfile() + && profile.equals(ProfileType.Private)) { + return context.getString(alphaHintForPrivateProfile); + } else if (type == TYPE_FINGERPRINT) { return context.getString(alphaHintForFingerprint); } else if (type == TYPE_FACE) { return context.getString(alphaHintForFace); } else if (type == TYPE_BIOMETRIC) { return context.getString(alphaHintForBiometrics); - } else if (isProfile) { + } else if (profile.equals(ProfileType.Managed)) { return context.getSystemService(DevicePolicyManager.class).getResources() .getString(alphaHintOverrideForProfile, - () -> context.getString(alphaHintForProfile)); + () -> context.getString(alphaHintForManagedProfile)); } else { return context.getString(alphaHint); } } else { - if (type == TYPE_FINGERPRINT) { + if (android.os.Flags.allowPrivateProfile() + && profile.equals(ProfileType.Private)) { + return context.getString(numericHintForPrivateProfile); + } else if (type == TYPE_FINGERPRINT) { return context.getString(numericHintForFingerprint); } else if (type == TYPE_FACE) { return context.getString(numericHintForFace); } else if (type == TYPE_BIOMETRIC) { return context.getString(numericHintForBiometrics); - } else if (isProfile) { + } else if (profile.equals(ProfileType.Managed)) { return context.getSystemService(DevicePolicyManager.class).getResources() .getString(numericHintOverrideForProfile, - () -> context.getString(numericHintForProfile)); + () -> context.getString(numericHintForManagedProfile)); } else { - return context.getString(numericHint); + return context.getString(numericHint); } } } @@ -455,7 +480,7 @@ public class ChooseLockPassword extends SettingsActivity { } // Only take this argument into account if it belongs to the current profile. mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras()); - mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mUserId); + mProfileType = getProfileType(); mForFingerprint = intent.getBooleanExtra( ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false); mForFace = intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false); @@ -602,7 +627,7 @@ public class ChooseLockPassword extends SettingsActivity { if (activity instanceof SettingsActivity) { final SettingsActivity sa = (SettingsActivity) activity; String title = Stage.Introduction.getHint( - getContext(), mIsAlphaMode, getStageType(), mIsManagedProfile); + getContext(), mIsAlphaMode, getStageType(), mProfileType); sa.setTitle(title); mLayout.setHeaderText(title); } @@ -938,7 +963,7 @@ public class ChooseLockPassword extends SettingsActivity { // Hide password requirement view when we are just asking user to confirm the pw. mPasswordRestrictionView.setVisibility(View.GONE); setHeaderText(mUiStage.getHint(getContext(), mIsAlphaMode, getStageType(), - mIsManagedProfile)); + mProfileType)); setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE); mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0)); @@ -1110,5 +1135,18 @@ public class ChooseLockPassword extends SettingsActivity { } } } + + private ProfileType getProfileType() { + UserManager userManager = getContext().createContextAsUser(UserHandle.of(mUserId), + /*flags=*/0).getSystemService(UserManager.class); + if (userManager.isManagedProfile()) { + return ProfileType.Managed; + } else if (android.os.Flags.allowPrivateProfile() && userManager.isPrivateProfile()) { + return ProfileType.Private; + } else if (userManager.isProfile()) { + return ProfileType.Other; + } + return ProfileType.None; + } } } diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java index 20d1e7d8cd1..e8595af8eb6 100644 --- a/src/com/android/settings/password/ChooseLockPattern.java +++ b/src/com/android/settings/password/ChooseLockPattern.java @@ -478,6 +478,8 @@ public class ChooseLockPattern extends SettingsActivity { .getString(SET_WORK_PROFILE_PATTERN_HEADER, () -> getString( R.string.lockpassword_choose_your_profile_pattern_header)); + } else if (android.os.Flags.allowPrivateProfile() && isPrivateProfile()) { + msg = getString(R.string.private_space_choose_your_pattern_header); } else { msg = getString(R.string.lockpassword_choose_your_pattern_header); } @@ -873,5 +875,11 @@ public class ChooseLockPattern extends SettingsActivity { } getActivity().finish(); } + + private boolean isPrivateProfile() { + UserManager userManager = getContext().createContextAsUser(UserHandle.of(mUserId), + /*flags=*/0).getSystemService(UserManager.class); + return userManager.isPrivateProfile(); + } } } diff --git a/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java b/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java index 20298a1c003..efbe9f9200d 100644 --- a/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java +++ b/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java @@ -20,6 +20,7 @@ import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSW import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PATTERN; import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PIN; import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS; +import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE; import android.content.Context; import android.content.Intent; @@ -94,6 +95,7 @@ public class PrivateSpaceLockController extends AbstractPreferenceController { final Bundle extras = new Bundle(); extras.putInt(Intent.EXTRA_USER_ID, mProfileUserId); extras.putBoolean(HIDE_INSECURE_OPTIONS, true); + extras.putInt(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, R.string.private_space_lock_setup_title); new SubSettingLauncher(mContext) .setDestination(ChooseLockGeneric.ChooseLockGenericFragment.class.getName()) .setSourceMetricsCategory(mHost.getMetricsCategory()) |