Part2 - Don't add padlock if the restriction is not set by admin.

Bug: 26687435
Change-Id: I85ef42e1ff1216791d1393a975e8559191b3781f
This commit is contained in:
Sudheer Shanka
2016-02-11 17:17:21 +00:00
parent ab1a97c307
commit 29737ad910
2 changed files with 23 additions and 9 deletions

View File

@@ -169,7 +169,9 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
} catch (IllegalArgumentException ignored) {
isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
}
if (!mUserManager.isAdminUser() || !isCellBroadcastAppLinkEnabled) {
if (!mUserManager.isAdminUser() || !isCellBroadcastAppLinkEnabled ||
RestrictedLockUtils.hasBaseUserRestriction(mContext,
UserManager.DISALLOW_CONFIG_CELL_BROADCASTS, UserHandle.myUserId())) {
removePreference(KEY_CELL_BROADCAST_SETTINGS);
}
initRingtones();
@@ -193,12 +195,15 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(mContext,
UserManager.DISALLOW_ADJUST_VOLUME, UserHandle.myUserId());
final boolean hasBaseRestriction = RestrictedLockUtils.hasBaseUserRestriction(mContext,
UserManager.DISALLOW_ADJUST_VOLUME, UserHandle.myUserId());
for (String key : RESTRICTED_KEYS) {
Preference pref = findPreference(key);
if (pref instanceof RestrictedPreference) {
if (pref != null) {
pref.setEnabled(!hasBaseRestriction);
}
if (pref instanceof RestrictedPreference && !hasBaseRestriction) {
((RestrictedPreference) pref).setDisabledByAdmin(admin);
} else if (pref != null) {
pref.setEnabled(admin == null);
}
}
RestrictedPreference broadcastSettingsPref = (RestrictedPreference) findPreference(