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
This commit is contained in:
josephpv
2023-12-11 11:34:00 +00:00
committed by Joseph Vincent
parent bb49d847a2
commit 223737e0b5
4 changed files with 70 additions and 16 deletions

View File

@@ -1312,6 +1312,12 @@
<string name="private_space_lock_setup_title">Choose a lock for your private space</string> <string name="private_space_lock_setup_title">Choose a lock for your private space</string>
<!-- private space lock setup screen description [CHAR LIMIT=NONE] --> <!-- 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> <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. --> <!-- 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] --> <!-- Header in hide Private Space settings page to unhide Private Space. [CHAR LIMIT=90] -->

View File

@@ -260,7 +260,6 @@ public class ChooseLockPassword extends SettingsActivity {
private LockscreenCredential mFirstPassword; private LockscreenCredential mFirstPassword;
private RecyclerView mPasswordRestrictionView; private RecyclerView mPasswordRestrictionView;
protected boolean mIsAlphaMode; protected boolean mIsAlphaMode;
protected boolean mIsManagedProfile;
protected FooterButton mSkipOrClearButton; protected FooterButton mSkipOrClearButton;
private FooterButton mNextButton; private FooterButton mNextButton;
private TextView mMessage; private TextView mMessage;
@@ -272,6 +271,14 @@ public class ChooseLockPassword extends SettingsActivity {
private static final int CONFIRM_EXISTING_REQUEST = 58; private static final int CONFIRM_EXISTING_REQUEST = 58;
static final int RESULT_FINISHED = RESULT_FIRST_USER; 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. * 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_fingerprint,
R.string.lockpassword_choose_your_password_header_for_face, R.string.lockpassword_choose_your_password_header_for_face,
R.string.lockpassword_choose_your_password_header_for_biometrics, 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 R.string.lockpassword_choose_your_pin_header, // pin
SET_WORK_PROFILE_PIN_HEADER, SET_WORK_PROFILE_PIN_HEADER,
R.string.lockpassword_choose_your_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_fingerprint,
R.string.lockpassword_choose_your_pin_header_for_face, R.string.lockpassword_choose_your_pin_header_for_face,
R.string.lockpassword_choose_your_pin_header_for_biometrics, 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.lock_settings_picker_biometrics_added_security_message, R.string.lock_settings_picker_biometrics_added_security_message,
R.string.next_label), 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_password_header, R.string.lockpassword_confirm_your_password_header,
R.string.lockpassword_confirm_your_password_header,
R.string.lockpassword_confirm_your_pin_header, R.string.lockpassword_confirm_your_pin_header,
REENTER_WORK_PROFILE_PIN_HEADER, REENTER_WORK_PROFILE_PIN_HEADER,
R.string.lockpassword_reenter_your_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,
R.string.lockpassword_confirm_your_pin_header, R.string.lockpassword_confirm_your_pin_header,
R.string.lockpassword_confirm_your_pin_header,
0, 0,
0, 0,
R.string.lockpassword_confirm_label), 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_passwords_dont_match, R.string.lockpassword_confirm_passwords_dont_match,
R.string.lockpassword_confirm_passwords_dont_match,
R.string.lockpassword_confirm_pins_dont_match, R.string.lockpassword_confirm_pins_dont_match,
UNDEFINED, 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, 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,
0, 0,
R.string.lockpassword_confirm_label); R.string.lockpassword_confirm_label);
@@ -335,29 +348,33 @@ public class ChooseLockPassword extends SettingsActivity {
int hintInAlphaForFingerprint, int hintInAlphaForFingerprint,
int hintInAlphaForFace, int hintInAlphaForFace,
int hintInAlphaForBiometrics, int hintInAlphaForBiometrics,
int hintInAlphaForPrivateProfile,
int hintInNumeric, int hintInNumeric,
String hintOverrideInNumericForProfile, String hintOverrideInNumericForProfile,
int hintInNumericForProfile, int hintInNumericForProfile,
int hintInNumericForFingerprint, int hintInNumericForFingerprint,
int hintInNumericForFace, int hintInNumericForFace,
int hintInNumericForBiometrics, int hintInNumericForBiometrics,
int hintInNumericForPrivateProfile,
int messageInAlphaForBiometrics, int messageInAlphaForBiometrics,
int messageInNumericForBiometrics, int messageInNumericForBiometrics,
int nextButtonText) { int nextButtonText) {
this.alphaHint = hintInAlpha; this.alphaHint = hintInAlpha;
this.alphaHintOverrideForProfile = hintOverrideInAlphaForProfile; this.alphaHintOverrideForProfile = hintOverrideInAlphaForProfile;
this.alphaHintForProfile = hintInAlphaForProfile; this.alphaHintForManagedProfile = hintInAlphaForProfile;
this.alphaHintForFingerprint = hintInAlphaForFingerprint; this.alphaHintForFingerprint = hintInAlphaForFingerprint;
this.alphaHintForFace = hintInAlphaForFace; this.alphaHintForFace = hintInAlphaForFace;
this.alphaHintForBiometrics = hintInAlphaForBiometrics; this.alphaHintForBiometrics = hintInAlphaForBiometrics;
this.alphaHintForPrivateProfile = hintInAlphaForPrivateProfile;
this.numericHint = hintInNumeric; this.numericHint = hintInNumeric;
this.numericHintOverrideForProfile = hintOverrideInNumericForProfile; this.numericHintOverrideForProfile = hintOverrideInNumericForProfile;
this.numericHintForProfile = hintInNumericForProfile; this.numericHintForManagedProfile = hintInNumericForProfile;
this.numericHintForFingerprint = hintInNumericForFingerprint; this.numericHintForFingerprint = hintInNumericForFingerprint;
this.numericHintForFace = hintInNumericForFace; this.numericHintForFace = hintInNumericForFace;
this.numericHintForBiometrics = hintInNumericForBiometrics; this.numericHintForBiometrics = hintInNumericForBiometrics;
this.numericHintForPrivateProfile = hintInNumericForPrivateProfile;
this.alphaMessageForBiometrics = messageInAlphaForBiometrics; this.alphaMessageForBiometrics = messageInAlphaForBiometrics;
this.numericMessageForBiometrics = messageInNumericForBiometrics; this.numericMessageForBiometrics = messageInNumericForBiometrics;
@@ -372,16 +389,18 @@ public class ChooseLockPassword extends SettingsActivity {
// Password header // Password header
public final int alphaHint; public final int alphaHint;
public final int alphaHintForPrivateProfile;
public final String alphaHintOverrideForProfile; public final String alphaHintOverrideForProfile;
public final int alphaHintForProfile; public final int alphaHintForManagedProfile;
public final int alphaHintForFingerprint; public final int alphaHintForFingerprint;
public final int alphaHintForFace; public final int alphaHintForFace;
public final int alphaHintForBiometrics; public final int alphaHintForBiometrics;
// PIN header // PIN header
public final int numericHint; public final int numericHint;
public final int numericHintForPrivateProfile;
public final String numericHintOverrideForProfile; public final String numericHintOverrideForProfile;
public final int numericHintForProfile; public final int numericHintForManagedProfile;
public final int numericHintForFingerprint; public final int numericHintForFingerprint;
public final int numericHintForFace; public final int numericHintForFace;
public final int numericHintForBiometrics; public final int numericHintForBiometrics;
@@ -394,34 +413,40 @@ public class ChooseLockPassword extends SettingsActivity {
public final int buttonText; 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 (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); return context.getString(alphaHintForFingerprint);
} else if (type == TYPE_FACE) { } else if (type == TYPE_FACE) {
return context.getString(alphaHintForFace); return context.getString(alphaHintForFace);
} else if (type == TYPE_BIOMETRIC) { } else if (type == TYPE_BIOMETRIC) {
return context.getString(alphaHintForBiometrics); return context.getString(alphaHintForBiometrics);
} else if (isProfile) { } else if (profile.equals(ProfileType.Managed)) {
return context.getSystemService(DevicePolicyManager.class).getResources() return context.getSystemService(DevicePolicyManager.class).getResources()
.getString(alphaHintOverrideForProfile, .getString(alphaHintOverrideForProfile,
() -> context.getString(alphaHintForProfile)); () -> context.getString(alphaHintForManagedProfile));
} else { } else {
return context.getString(alphaHint); return context.getString(alphaHint);
} }
} else { } 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); return context.getString(numericHintForFingerprint);
} else if (type == TYPE_FACE) { } else if (type == TYPE_FACE) {
return context.getString(numericHintForFace); return context.getString(numericHintForFace);
} else if (type == TYPE_BIOMETRIC) { } else if (type == TYPE_BIOMETRIC) {
return context.getString(numericHintForBiometrics); return context.getString(numericHintForBiometrics);
} else if (isProfile) { } else if (profile.equals(ProfileType.Managed)) {
return context.getSystemService(DevicePolicyManager.class).getResources() return context.getSystemService(DevicePolicyManager.class).getResources()
.getString(numericHintOverrideForProfile, .getString(numericHintOverrideForProfile,
() -> context.getString(numericHintForProfile)); () -> context.getString(numericHintForManagedProfile));
} else { } 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. // Only take this argument into account if it belongs to the current profile.
mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras()); mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mUserId); mProfileType = getProfileType();
mForFingerprint = intent.getBooleanExtra( mForFingerprint = intent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false); ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
mForFace = intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false); mForFace = intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false);
@@ -602,7 +627,7 @@ public class ChooseLockPassword extends SettingsActivity {
if (activity instanceof SettingsActivity) { if (activity instanceof SettingsActivity) {
final SettingsActivity sa = (SettingsActivity) activity; final SettingsActivity sa = (SettingsActivity) activity;
String title = Stage.Introduction.getHint( String title = Stage.Introduction.getHint(
getContext(), mIsAlphaMode, getStageType(), mIsManagedProfile); getContext(), mIsAlphaMode, getStageType(), mProfileType);
sa.setTitle(title); sa.setTitle(title);
mLayout.setHeaderText(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. // Hide password requirement view when we are just asking user to confirm the pw.
mPasswordRestrictionView.setVisibility(View.GONE); mPasswordRestrictionView.setVisibility(View.GONE);
setHeaderText(mUiStage.getHint(getContext(), mIsAlphaMode, getStageType(), setHeaderText(mUiStage.getHint(getContext(), mIsAlphaMode, getStageType(),
mIsManagedProfile)); mProfileType));
setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE); setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE);
mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0)); 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;
}
} }
} }

View File

@@ -478,6 +478,8 @@ public class ChooseLockPattern extends SettingsActivity {
.getString(SET_WORK_PROFILE_PATTERN_HEADER, .getString(SET_WORK_PROFILE_PATTERN_HEADER,
() -> getString( () -> getString(
R.string.lockpassword_choose_your_profile_pattern_header)); 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 { } else {
msg = getString(R.string.lockpassword_choose_your_pattern_header); msg = getString(R.string.lockpassword_choose_your_pattern_header);
} }
@@ -873,5 +875,11 @@ public class ChooseLockPattern extends SettingsActivity {
} }
getActivity().finish(); getActivity().finish();
} }
private boolean isPrivateProfile() {
UserManager userManager = getContext().createContextAsUser(UserHandle.of(mUserId),
/*flags=*/0).getSystemService(UserManager.class);
return userManager.isPrivateProfile();
}
} }
} }

View File

@@ -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_PATTERN;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PIN; 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.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.Context;
import android.content.Intent; import android.content.Intent;
@@ -94,6 +95,7 @@ public class PrivateSpaceLockController extends AbstractPreferenceController {
final Bundle extras = new Bundle(); final Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, mProfileUserId); extras.putInt(Intent.EXTRA_USER_ID, mProfileUserId);
extras.putBoolean(HIDE_INSECURE_OPTIONS, true); extras.putBoolean(HIDE_INSECURE_OPTIONS, true);
extras.putInt(EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, R.string.private_space_lock_setup_title);
new SubSettingLauncher(mContext) new SubSettingLauncher(mContext)
.setDestination(ChooseLockGeneric.ChooseLockGenericFragment.class.getName()) .setDestination(ChooseLockGeneric.ChooseLockGenericFragment.class.getName())
.setSourceMetricsCategory(mHost.getMetricsCategory()) .setSourceMetricsCategory(mHost.getMetricsCategory())