Part3 - Don't add padlock if the restriction is not set by admin.
Bug: 26687435 Change-Id: Ibfea6d7d5bd32e7a05dcc2cc32b121c9e50b6a34
This commit is contained in:
@@ -62,6 +62,7 @@ import com.android.settings.search.Index;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.users.UserDialogs;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.accounts.AuthenticatorHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -325,9 +326,12 @@ public class AccountSettings extends SettingsPreferenceFragment
|
||||
if (userInfo.isEnabled()) {
|
||||
profileData.authenticatorHelper = new AuthenticatorHelper(context,
|
||||
userInfo.getUserHandle(), this);
|
||||
profileData.addAccountPreference = newAddAccountPreference(context);
|
||||
profileData.addAccountPreference.checkRestrictionAndSetDisabled(
|
||||
DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
|
||||
if (!RestrictedLockUtils.hasBaseUserRestriction(context,
|
||||
UserManager.DISALLOW_MODIFY_ACCOUNTS, userInfo.id)) {
|
||||
profileData.addAccountPreference = newAddAccountPreference(context);
|
||||
profileData.addAccountPreference.checkRestrictionAndSetDisabled(
|
||||
DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
|
||||
}
|
||||
}
|
||||
mProfiles.put(userInfo.id, profileData);
|
||||
Index.getInstance(getActivity()).updateFromClassNameResource(
|
||||
@@ -715,13 +719,16 @@ public class AccountSettings extends SettingsPreferenceFragment
|
||||
for (int i = 0; i < profilesCount; i++) {
|
||||
UserInfo userInfo = profiles.get(i);
|
||||
if (userInfo.isEnabled()) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.add_account_label);
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
if (userInfo.isManagedProfile()) {
|
||||
if (!RestrictedLockUtils.hasBaseUserRestriction(context,
|
||||
DISALLOW_MODIFY_ACCOUNTS, userInfo.id)) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.add_account_label);
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
}
|
||||
if (userInfo.isManagedProfile()) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.remove_managed_profile_label);
|
||||
data.screenTitle = screenTitle;
|
||||
|
@@ -262,20 +262,23 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
MenuItem syncCancel = menu.add(0, MENU_SYNC_CANCEL_ID, 0,
|
||||
getString(R.string.sync_menu_sync_cancel))
|
||||
.setIcon(com.android.internal.R.drawable.ic_menu_close_clear_cancel);
|
||||
MenuItem removeAccount = menu.add(0, MENU_REMOVE_ACCOUNT_ID, 0,
|
||||
getString(R.string.remove_account_label))
|
||||
.setIcon(R.drawable.ic_menu_delete);
|
||||
removeAccount.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(
|
||||
getPrefContext(), UserManager.DISALLOW_MODIFY_ACCOUNTS,
|
||||
mUserHandle.getIdentifier());
|
||||
if (admin == null) {
|
||||
admin = RestrictedLockUtils.checkIfAccountManagementDisabled(
|
||||
getPrefContext(), mAccount.type, mUserHandle.getIdentifier());
|
||||
if (!RestrictedLockUtils.hasBaseUserRestriction(getPrefContext(),
|
||||
UserManager.DISALLOW_MODIFY_ACCOUNTS, mUserHandle.getIdentifier())) {
|
||||
MenuItem removeAccount = menu.add(0, MENU_REMOVE_ACCOUNT_ID, 0,
|
||||
getString(R.string.remove_account_label))
|
||||
.setIcon(R.drawable.ic_menu_delete);
|
||||
removeAccount.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(
|
||||
getPrefContext(), UserManager.DISALLOW_MODIFY_ACCOUNTS,
|
||||
mUserHandle.getIdentifier());
|
||||
if (admin == null) {
|
||||
admin = RestrictedLockUtils.checkIfAccountManagementDisabled(
|
||||
getPrefContext(), mAccount.type, mUserHandle.getIdentifier());
|
||||
}
|
||||
RestrictedLockUtils.setMenuItemAsDisabledByAdmin(getPrefContext(),
|
||||
removeAccount, admin);
|
||||
}
|
||||
RestrictedLockUtils.setMenuItemAsDisabledByAdmin(getPrefContext(),
|
||||
removeAccount, admin);
|
||||
syncNow.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
syncCancel.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||
|
Reference in New Issue
Block a user