Merge "Check new user restriction for profile removal"
This commit is contained in:
committed by
Android (Google) Code Review
commit
e539c886fd
@@ -62,6 +62,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static android.content.Intent.EXTRA_USER;
|
import static android.content.Intent.EXTRA_USER;
|
||||||
import static android.os.UserManager.DISALLOW_MODIFY_ACCOUNTS;
|
import static android.os.UserManager.DISALLOW_MODIFY_ACCOUNTS;
|
||||||
|
import static android.os.UserManager.DISALLOW_REMOVE_MANAGED_PROFILE;
|
||||||
import static android.os.UserManager.DISALLOW_REMOVE_USER;
|
import static android.os.UserManager.DISALLOW_REMOVE_USER;
|
||||||
import static android.provider.Settings.EXTRA_AUTHORITIES;
|
import static android.provider.Settings.EXTRA_AUTHORITIES;
|
||||||
|
|
||||||
@@ -171,7 +172,7 @@ public class AccountPreferenceController extends PreferenceController
|
|||||||
rawData.add(data);
|
rawData.add(data);
|
||||||
}
|
}
|
||||||
if (userInfo.isManagedProfile()) {
|
if (userInfo.isManagedProfile()) {
|
||||||
if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_USER,
|
if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE,
|
||||||
UserHandle.myUserId())) {
|
UserHandle.myUserId())) {
|
||||||
SearchIndexableRaw data = new SearchIndexableRaw(mContext);
|
SearchIndexableRaw data = new SearchIndexableRaw(mContext);
|
||||||
data.title = res.getString(R.string.remove_managed_profile_label);
|
data.title = res.getString(R.string.remove_managed_profile_label);
|
||||||
@@ -305,7 +306,7 @@ public class AccountPreferenceController extends PreferenceController
|
|||||||
mContext.getString(R.string.accessibility_category_work, workGroupSummary));
|
mContext.getString(R.string.accessibility_category_work, workGroupSummary));
|
||||||
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
|
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
|
||||||
mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference,
|
mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference,
|
||||||
DISALLOW_REMOVE_USER, UserHandle.myUserId());
|
DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
|
||||||
profileData.managedProfilePreference = newManagedProfileSettings();
|
profileData.managedProfilePreference = newManagedProfileSettings();
|
||||||
} else {
|
} else {
|
||||||
preferenceGroup.setTitle(R.string.category_personal);
|
preferenceGroup.setTitle(R.string.category_personal);
|
||||||
|
@@ -244,7 +244,8 @@ public class AccountPreferenceControllerTest {
|
|||||||
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
|
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
|
||||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||||
when(mAccountHelper.hasBaseUserRestriction(eq(UserManager.DISALLOW_REMOVE_USER), anyInt()))
|
when(mAccountHelper.hasBaseUserRestriction(
|
||||||
|
eq(UserManager.DISALLOW_REMOVE_MANAGED_PROFILE), anyInt()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
|
|
||||||
mController.updateRawDataToIndex(data);
|
mController.updateRawDataToIndex(data);
|
||||||
|
Reference in New Issue
Block a user