Make Work profile lock unification a toggle
The setting to unify work and personal locks is now a toggle, and therefore always available. When unifying, if the work lock is sufficient as a device lock we confirm both locks and set the work lock as the device lock. If the work lock is not sufficient for the device, the user is informed and taken to the lock setup flow to set a new unified lock for both. Also fix related Strings given UX feedback. Bug: 26816580 Change-Id: Id019234b0a5ff4462c5f9ba86e53e30981a03e0d
This commit is contained in:
@@ -3155,15 +3155,19 @@
|
|||||||
<!-- Security & location settings screen, title when changing or confirming the work profile lock -->
|
<!-- Security & location settings screen, title when changing or confirming the work profile lock -->
|
||||||
<string name="lock_settings_profile_screen_lock_title">Work profile screen lock</string>
|
<string name="lock_settings_profile_screen_lock_title">Work profile screen lock</string>
|
||||||
<!-- Security & location settings screen, setting option name to unify work and personal locks -->
|
<!-- Security & location settings screen, setting option name to unify work and personal locks -->
|
||||||
<string name="lock_settings_profile_unification_title">Use same screen lock</string>
|
<string name="lock_settings_profile_unification_title">Use the same lock</string>
|
||||||
<!-- Security & location settings screen, setting option explanation to unify work and personal locks -->
|
<!-- Security & location settings screen, setting option explanation to unify work and personal locks -->
|
||||||
<string name="lock_settings_profile_unification_summary">Change primary profile to match work profile</string>
|
<string name="lock_settings_profile_unification_summary">Change device screen lock to match work profile?</string>
|
||||||
<!-- Security & location settings screen, title of the dialog asking if the user wants to unify work and personal locks -->
|
<!-- Security & location settings screen, title of the dialog asking if the user wants to unify work and personal locks -->
|
||||||
<string name="lock_settings_profile_unification_dialog_title">Use the same screen lock?</string>
|
<string name="lock_settings_profile_unification_dialog_title">Use the same screen lock?</string>
|
||||||
<!-- Security & location settings screen, explanation in the dialog asking if the user wants to unify work and personal locks -->
|
<!-- Security & location settings screen, explanation in the dialog asking if the user wants to unify work and personal locks -->
|
||||||
<string name="lock_settings_profile_unification_dialog_body">You can use this lock for your device but it will include all screen lock related policies set by your IT admin on the work profile.\nDo you want to use the same screen lock for your device?</string>
|
<string name="lock_settings_profile_unification_dialog_body">You can use this lock for your device but it will include all screen lock related policies set by your IT admin on the work profile.\nDo you want to use the same screen lock for your device?</string>
|
||||||
|
<!-- Security & location settings screen, explanation in the dialog asking if the user wants to create a new lock for personal and work as the current work lock is not enough for the device. -->
|
||||||
|
<string name="lock_settings_profile_unification_dialog_uncompliant_body">Your work screen lock doesn\'t meet your organization\'s security requirements.\nYou can set a new screen lock for both your device and your work profile, but any work screen lock policies will apply to your device screen lock as well.</string>
|
||||||
|
<!-- Security & location settings screen, confirmation button of the dialog asking if the user wants to create a new lock for both personal and work profiles. -->
|
||||||
|
<string name="lock_settings_profile_unification_dialog_uncompliant_confirm">Change lock</string>
|
||||||
<!-- Security & location settings screen, summary of the item that changes your work profile lock when it is unified with the personal lock -->
|
<!-- Security & location settings screen, summary of the item that changes your work profile lock when it is unified with the personal lock -->
|
||||||
<string name="lock_settings_profile_unified_summary">Same as your device lock</string>
|
<string name="lock_settings_profile_unified_summary">Same as device screen lock</string>
|
||||||
|
|
||||||
<!-- Applications Settings --> <skip />
|
<!-- Applications Settings --> <skip />
|
||||||
<!-- Applications settings screen, setting option name for the user to go to the screen to manage installed applications -->
|
<!-- Applications settings screen, setting option name for the user to go to the screen to manage installed applications -->
|
||||||
|
@@ -18,11 +18,10 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
android:title="@string/security_settings_title">
|
android:title="@string/security_settings_title">
|
||||||
|
|
||||||
<PreferenceScreen
|
<SwitchPreference
|
||||||
android:key="unification"
|
android:key="unification"
|
||||||
android:title="@string/lock_settings_profile_unification_title"
|
android:title="@string/lock_settings_profile_unification_title"
|
||||||
android:summary="@string/lock_settings_profile_unification_summary"
|
android:summary="@string/lock_settings_profile_unification_summary"
|
||||||
settings:keywords="@string/keywords_unification"
|
settings:keywords="@string/keywords_unification"/>
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -117,7 +117,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
// These switch preferences need special handling since they're not all stored in Settings.
|
// These switch preferences need special handling since they're not all stored in Settings.
|
||||||
private static final String SWITCH_PREFERENCE_KEYS[] = {
|
private static final String SWITCH_PREFERENCE_KEYS[] = {
|
||||||
KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS };
|
KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS, KEY_UNIFICATION };
|
||||||
|
|
||||||
// Only allow one trust agent on the platform.
|
// Only allow one trust agent on the platform.
|
||||||
private static final boolean ONLY_ONE_TRUST_AGENT = true;
|
private static final boolean ONLY_ONE_TRUST_AGENT = true;
|
||||||
@@ -132,6 +132,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
|
|
||||||
private SwitchPreference mVisiblePatternProfile;
|
private SwitchPreference mVisiblePatternProfile;
|
||||||
|
private SwitchPreference mUnifyProfile;
|
||||||
|
|
||||||
private SwitchPreference mShowPassword;
|
private SwitchPreference mShowPassword;
|
||||||
|
|
||||||
@@ -235,13 +236,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
getActivity(), mLockPatternUtils, mProfileChallengeUserId);
|
getActivity(), mLockPatternUtils, mProfileChallengeUserId);
|
||||||
addPreferencesFromResource(profileResid);
|
addPreferencesFromResource(profileResid);
|
||||||
maybeAddFingerprintPreference(root, mProfileChallengeUserId);
|
maybeAddFingerprintPreference(root, mProfileChallengeUserId);
|
||||||
if (mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
|
addPreferencesFromResource(R.xml.security_settings_unification);
|
||||||
maybeAddUnificationPreference();
|
if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
|
||||||
} else {
|
|
||||||
Preference lockPreference = root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
|
Preference lockPreference = root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
|
||||||
String summary = getContext().getString(
|
String summary = getContext().getString(
|
||||||
R.string.lock_settings_profile_unified_summary);
|
R.string.lock_settings_profile_unified_summary);
|
||||||
lockPreference.setSummary(summary);
|
lockPreference.setSummary(summary);
|
||||||
|
lockPreference.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,6 +274,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
mVisiblePatternProfile =
|
mVisiblePatternProfile =
|
||||||
(SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN_PROFILE);
|
(SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN_PROFILE);
|
||||||
|
mUnifyProfile = (SwitchPreference) root.findPreference(KEY_UNIFICATION);
|
||||||
|
|
||||||
// Append the rest of the settings
|
// Append the rest of the settings
|
||||||
addPreferencesFromResource(R.xml.security_settings_misc);
|
addPreferencesFromResource(R.xml.security_settings_misc);
|
||||||
@@ -386,15 +388,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeAddUnificationPreference() {
|
|
||||||
if (mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId)
|
|
||||||
>= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
|
|
||||||
&& mLockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
|
|
||||||
mProfileChallengeUserId)) {
|
|
||||||
addPreferencesFromResource(R.xml.security_settings_unification);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addTrustAgentSettings(PreferenceGroup securityCategory) {
|
private void addTrustAgentSettings(PreferenceGroup securityCategory) {
|
||||||
final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
|
final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
|
||||||
ArrayList<TrustAgentComponentInfo> agents =
|
ArrayList<TrustAgentComponentInfo> agents =
|
||||||
@@ -560,12 +553,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
// depend on others...
|
// depend on others...
|
||||||
createPreferenceHierarchy();
|
createPreferenceHierarchy();
|
||||||
|
|
||||||
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
|
||||||
if (mVisiblePatternProfile != null) {
|
if (mVisiblePatternProfile != null) {
|
||||||
mVisiblePatternProfile.setChecked(lockPatternUtils.isVisiblePatternEnabled(
|
mVisiblePatternProfile.setChecked(mLockPatternUtils.isVisiblePatternEnabled(
|
||||||
mProfileChallengeUserId));
|
mProfileChallengeUserId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateUnificationPreference();
|
||||||
|
|
||||||
if (mShowPassword != null) {
|
if (mShowPassword != null) {
|
||||||
mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
|
mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
|
||||||
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
|
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
|
||||||
@@ -576,6 +570,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateUnificationPreference() {
|
||||||
|
if (mUnifyProfile != null) {
|
||||||
|
mUnifyProfile.setChecked(!mLockPatternUtils.isSeparateProfileChallengeEnabled(
|
||||||
|
mProfileChallengeUserId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(Preference preference) {
|
public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
final String key = preference.getKey();
|
final String key = preference.getKey();
|
||||||
@@ -599,11 +600,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
startActivity(mTrustAgentClickIntent);
|
startActivity(mTrustAgentClickIntent);
|
||||||
mTrustAgentClickIntent = null;
|
mTrustAgentClickIntent = null;
|
||||||
}
|
}
|
||||||
} else if (KEY_UNIFICATION.equals(key)) {
|
|
||||||
UnificationConfirmationDialog dialog =
|
|
||||||
UnificationConfirmationDialog.newIntance(mProfileChallengeUserId);
|
|
||||||
dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
// If we didn't handle it, let preferences handle it.
|
// If we didn't handle it, let preferences handle it.
|
||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
@@ -680,6 +676,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
mCurrentProfilePassword = null;
|
mCurrentProfilePassword = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unifyUncompliantLocks() {
|
||||||
|
mLockPatternUtils.clearLock(mProfileChallengeUserId);
|
||||||
|
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, false);
|
||||||
|
startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
|
||||||
|
R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
@@ -687,6 +690,20 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
||||||
if (KEY_VISIBLE_PATTERN_PROFILE.equals(key)) {
|
if (KEY_VISIBLE_PATTERN_PROFILE.equals(key)) {
|
||||||
lockPatternUtils.setVisiblePatternEnabled((Boolean) value, mProfileChallengeUserId);
|
lockPatternUtils.setVisiblePatternEnabled((Boolean) value, mProfileChallengeUserId);
|
||||||
|
} else if (KEY_UNIFICATION.equals(key)) {
|
||||||
|
if ((Boolean) value) {
|
||||||
|
final boolean compliantForDevice =
|
||||||
|
(mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId)
|
||||||
|
>= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
|
||||||
|
&& mLockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
|
||||||
|
mProfileChallengeUserId));
|
||||||
|
UnificationConfirmationDialog dialog =
|
||||||
|
UnificationConfirmationDialog.newIntance(compliantForDevice);
|
||||||
|
dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
|
||||||
|
} else {
|
||||||
|
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, true);
|
||||||
|
createPreferenceHierarchy();
|
||||||
|
}
|
||||||
} else if (KEY_SHOW_PASSWORD.equals(key)) {
|
} else if (KEY_SHOW_PASSWORD.equals(key)) {
|
||||||
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
|
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
|
||||||
((Boolean) value) ? 1 : 0);
|
((Boolean) value) ? 1 : 0);
|
||||||
@@ -946,13 +963,12 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
createPreferenceHierarchy();
|
createPreferenceHierarchy();
|
||||||
|
|
||||||
final LockPatternUtils lockPatternUtils = mLockPatternUtils;
|
|
||||||
if (mVisiblePattern != null) {
|
if (mVisiblePattern != null) {
|
||||||
mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(
|
mVisiblePattern.setChecked(mLockPatternUtils.isVisiblePatternEnabled(
|
||||||
MY_USER_ID));
|
MY_USER_ID));
|
||||||
}
|
}
|
||||||
if (mPowerButtonInstantlyLocks != null) {
|
if (mPowerButtonInstantlyLocks != null) {
|
||||||
mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks(
|
mPowerButtonInstantlyLocks.setChecked(mLockPatternUtils.getPowerButtonInstantlyLocks(
|
||||||
MY_USER_ID));
|
MY_USER_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1205,9 +1221,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class UnificationConfirmationDialog extends DialogFragment {
|
public static class UnificationConfirmationDialog extends DialogFragment {
|
||||||
|
private static final String EXTRA_COMPLIANT = "compliant";
|
||||||
|
|
||||||
public static UnificationConfirmationDialog newIntance(int userId) {
|
public static UnificationConfirmationDialog newIntance(boolean compliant) {
|
||||||
UnificationConfirmationDialog dialog = new UnificationConfirmationDialog();
|
UnificationConfirmationDialog dialog = new UnificationConfirmationDialog();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean(EXTRA_COMPLIANT, compliant);
|
||||||
|
dialog.setArguments(args);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1222,14 +1242,21 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
final SecuritySettings parentFragment = ((SecuritySettings) getParentFragment());
|
final SecuritySettings parentFragment = ((SecuritySettings) getParentFragment());
|
||||||
|
final boolean compliant = getArguments().getBoolean(EXTRA_COMPLIANT);
|
||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(R.string.lock_settings_profile_unification_dialog_title)
|
.setTitle(R.string.lock_settings_profile_unification_dialog_title)
|
||||||
.setMessage(R.string.lock_settings_profile_unification_dialog_body)
|
.setMessage(compliant ? R.string.lock_settings_profile_unification_dialog_body
|
||||||
.setPositiveButton(R.string.okay,
|
: R.string.lock_settings_profile_unification_dialog_uncompliant_body)
|
||||||
|
.setPositiveButton(compliant ? R.string.okay
|
||||||
|
: R.string.lock_settings_profile_unification_dialog_uncompliant_confirm,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
parentFragment.launchConfirmDeviceLockForUnification();
|
if (compliant) {
|
||||||
|
parentFragment.launchConfirmDeviceLockForUnification();
|
||||||
|
} else {
|
||||||
|
parentFragment.unifyUncompliantLocks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1237,6 +1264,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
|
parentFragment.updateUnificationPreference();
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user