Merge "Block "Screen lock" menu for Work Challenge." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4ffa5c8af5
@@ -22,7 +22,7 @@
|
|||||||
android:key="security_category"
|
android:key="security_category"
|
||||||
android:title="@string/lock_settings_title">
|
android:title="@string/lock_settings_title">
|
||||||
|
|
||||||
<PreferenceScreen
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="unlock_set_or_change"
|
android:key="unlock_set_or_change"
|
||||||
android:title="@string/unlock_set_unlock_launch_picker_title"
|
android:title="@string/unlock_set_unlock_launch_picker_title"
|
||||||
android:summary="@string/unlock_set_unlock_mode_off"
|
android:summary="@string/unlock_set_unlock_mode_off"
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
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
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="unlock_set_or_change_profile"
|
android:key="unlock_set_or_change_profile"
|
||||||
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
||||||
android:summary="@string/unlock_set_unlock_mode_off"
|
android:summary="@string/unlock_set_unlock_mode_off"
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
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
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="unlock_set_or_change_profile"
|
android:key="unlock_set_or_change_profile"
|
||||||
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
||||||
android:summary="@string/unlock_set_unlock_mode_password"
|
android:summary="@string/unlock_set_unlock_mode_password"
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
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
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="unlock_set_or_change_profile"
|
android:key="unlock_set_or_change_profile"
|
||||||
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
||||||
android:summary="@string/unlock_set_unlock_mode_pattern"
|
android:summary="@string/unlock_set_unlock_mode_pattern"
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
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
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="unlock_set_or_change_profile"
|
android:key="unlock_set_or_change_profile"
|
||||||
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
||||||
android:summary="@string/unlock_set_unlock_mode_pin"
|
android:summary="@string/unlock_set_unlock_mode_pin"
|
||||||
|
@@ -228,14 +228,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils, MY_USER_ID);
|
final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils, MY_USER_ID);
|
||||||
addPreferencesFromResource(resid);
|
addPreferencesFromResource(resid);
|
||||||
|
|
||||||
final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
|
// DO or PO installed in the user may disallow to change password.
|
||||||
getActivity(), MY_USER_ID);
|
disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, MY_USER_ID);
|
||||||
if (admin != null && mDPM.getPasswordQuality(admin.component) ==
|
|
||||||
DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
|
|
||||||
final GearPreference unlockSetOrChangePref =
|
|
||||||
(GearPreference) getPreferenceScreen().findPreference(KEY_UNLOCK_SET_OR_CHANGE);
|
|
||||||
unlockSetOrChangePref.setDisabledByAdmin(admin);
|
|
||||||
}
|
|
||||||
|
|
||||||
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
|
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
|
||||||
if (mProfileChallengeUserId != UserHandle.USER_NULL
|
if (mProfileChallengeUserId != UserHandle.USER_NULL
|
||||||
@@ -247,11 +241,20 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
addPreferencesFromResource(profileResid);
|
addPreferencesFromResource(profileResid);
|
||||||
maybeAddFingerprintPreference(root, mProfileChallengeUserId);
|
maybeAddFingerprintPreference(root, mProfileChallengeUserId);
|
||||||
if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
|
if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
|
||||||
Preference lockPreference = root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
|
final Preference lockPreference =
|
||||||
String summary = getContext().getString(
|
root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
|
||||||
|
final 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);
|
lockPreference.setEnabled(false);
|
||||||
|
// PO may disallow to change password for the profile, but screen lock and managed
|
||||||
|
// profile's lock is the same. Disable main "Screen lock" menu.
|
||||||
|
disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, mProfileChallengeUserId);
|
||||||
|
} else {
|
||||||
|
// PO may disallow to change profile password, and the profile's password is
|
||||||
|
// separated from screen lock password. Disable profile specific "Screen lock" menu.
|
||||||
|
disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE_PROFILE,
|
||||||
|
mProfileChallengeUserId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,6 +396,21 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
|
||||||
|
* The preference must be a RestrictedPreference.
|
||||||
|
*/
|
||||||
|
private void disableIfPasswordQualityManaged(String preferenceKey, int userId) {
|
||||||
|
final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
|
||||||
|
getActivity(), userId);
|
||||||
|
if (admin != null && mDPM.getPasswordQuality(admin.component, userId) ==
|
||||||
|
DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
|
||||||
|
final RestrictedPreference pref =
|
||||||
|
(RestrictedPreference) getPreferenceScreen().findPreference(preferenceKey);
|
||||||
|
pref.setDisabledByAdmin(admin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void maybeAddFingerprintPreference(PreferenceGroup securityCategory, int userId) {
|
private void maybeAddFingerprintPreference(PreferenceGroup securityCategory, int userId) {
|
||||||
Preference fingerprintPreference =
|
Preference fingerprintPreference =
|
||||||
FingerprintSettings.getFingerprintPreferenceForUser(
|
FingerprintSettings.getFingerprintPreferenceForUser(
|
||||||
@@ -777,23 +795,26 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
final List<SearchIndexableResource> index = new ArrayList<SearchIndexableResource>();
|
final List<SearchIndexableResource> index = new ArrayList<SearchIndexableResource>();
|
||||||
|
|
||||||
final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
||||||
final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
|
|
||||||
context, MY_USER_ID);
|
|
||||||
final DevicePolicyManager dpm = (DevicePolicyManager)
|
final DevicePolicyManager dpm = (DevicePolicyManager)
|
||||||
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
final UserManager um = UserManager.get(context);
|
final UserManager um = UserManager.get(context);
|
||||||
|
final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
|
||||||
|
|
||||||
if (admin == null || dpm.getPasswordQuality(admin.component) !=
|
// To add option for unlock screen, user's password must not be managed and
|
||||||
DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
|
// must not be unified with managed profile, whose password is managed.
|
||||||
|
if (!isPasswordManaged(MY_USER_ID, context, dpm)
|
||||||
|
&& (profileUserId == UserHandle.USER_NULL
|
||||||
|
|| lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)
|
||||||
|
|| !isPasswordManaged(profileUserId, context, dpm))) {
|
||||||
// Add options for lock/unlock screen
|
// Add options for lock/unlock screen
|
||||||
final int resId = getResIdForLockUnlockScreen(context, lockPatternUtils,
|
final int resId = getResIdForLockUnlockScreen(context, lockPatternUtils,
|
||||||
MY_USER_ID);
|
MY_USER_ID);
|
||||||
index.add(getSearchResource(context, resId));
|
index.add(getSearchResource(context, resId));
|
||||||
}
|
}
|
||||||
|
|
||||||
final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
|
|
||||||
if (profileUserId != UserHandle.USER_NULL
|
if (profileUserId != UserHandle.USER_NULL
|
||||||
&& lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)) {
|
&& lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)
|
||||||
|
&& !isPasswordManaged(profileUserId, context, dpm)) {
|
||||||
index.add(getSearchResource(context, getResIdForLockUnlockScreen(context,
|
index.add(getSearchResource(context, getResIdForLockUnlockScreen(context,
|
||||||
lockPatternUtils, profileUserId)));
|
lockPatternUtils, profileUserId)));
|
||||||
}
|
}
|
||||||
@@ -828,6 +849,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
return sir;
|
return sir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPasswordManaged(int userId, Context context, DevicePolicyManager dpm) {
|
||||||
|
final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
|
||||||
|
context, userId);
|
||||||
|
return admin != null && dpm.getPasswordQuality(admin.component, userId) ==
|
||||||
|
DevicePolicyManager.PASSWORD_QUALITY_MANAGED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
|
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
|
||||||
final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
|
final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
|
||||||
|
Reference in New Issue
Block a user