Modify clone profile accounts info section

This change renames clone profile accounts header on the account
management dashboard to "Clone" from "Personal" by using the newly added
clone category header config. This also includes changes to remove the
add account preference from the clone profile accounts.

Bug: 260181765
Test: Flashed on a sunfish device and tested

Change-Id: Iff8b75119d85d2cd8ab065ed1057fb2b35e64650
This commit is contained in:
Jigar Thakkar
2023-01-17 18:14:49 +00:00
parent d7bbff0041
commit 0e8b8ec57f
2 changed files with 47 additions and 17 deletions

View File

@@ -16,8 +16,10 @@
package com.android.settings.accounts;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_CLONE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_PERSONAL;
import static android.app.admin.DevicePolicyResources.Strings.Settings.ACCESSIBILITY_CATEGORY_WORK;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CLONE_CATEGORY_HEADER;
import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_BY;
import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_PROFILE_SETTINGS_TITLE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_CATEGORY_HEADER;
@@ -349,28 +351,34 @@ public class AccountPreferenceController extends AbstractPreferenceController
preferenceGroup.setContentDescription(title);
} else if (userInfo.isManagedProfile()) {
if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle(
mDpm.getResources().getString(WORK_CATEGORY_HEADER,
() -> mContext.getString(R.string.category_work)));
setCategoryTitleFromDevicePolicyResource(preferenceGroup, WORK_CATEGORY_HEADER,
R.string.category_work);
final String workGroupSummary = getWorkGroupSummary(context, userInfo);
preferenceGroup.setSummary(workGroupSummary);
preferenceGroup.setContentDescription(
mDpm.getResources().getString(ACCESSIBILITY_CATEGORY_WORK, () ->
mContext.getString(
R.string.accessibility_category_work, workGroupSummary)));
setContentDescriptionFromDevicePolicyResource(preferenceGroup,
ACCESSIBILITY_CATEGORY_WORK, R.string.accessibility_category_work,
workGroupSummary);
}
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference();
mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference,
DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
profileData.managedProfilePreference = newManagedProfileSettings();
} else {
} else if (userInfo.isCloneProfile()) {
if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle(
mDpm.getResources().getString(PERSONAL_CATEGORY_HEADER,
() -> mContext.getString(R.string.category_personal)));
preferenceGroup.setContentDescription(
mDpm.getResources().getString(ACCESSIBILITY_CATEGORY_PERSONAL, () ->
mContext.getString(R.string.accessibility_category_personal)));
setCategoryTitleFromDevicePolicyResource(preferenceGroup, CLONE_CATEGORY_HEADER,
R.string.category_clone);
setContentDescriptionFromDevicePolicyResource(preferenceGroup,
ACCESSIBILITY_CATEGORY_CLONE, R.string.accessibility_category_clone,
null);
}
} else {
// Primary Profile
if (mType == ProfileSelectFragment.ProfileType.ALL) {
setCategoryTitleFromDevicePolicyResource(preferenceGroup, PERSONAL_CATEGORY_HEADER,
R.string.category_personal);
setContentDescriptionFromDevicePolicyResource(preferenceGroup,
ACCESSIBILITY_CATEGORY_PERSONAL, R.string.accessibility_category_personal,
null);
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
@@ -381,13 +389,33 @@ public class AccountPreferenceController extends AbstractPreferenceController
if (userInfo.isEnabled()) {
profileData.authenticatorHelper = new AuthenticatorHelper(context,
userInfo.getUserHandle(), this);
profileData.addAccountPreference = newAddAccountPreference();
mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference,
DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
if (!userInfo.isCloneProfile()) {
profileData.addAccountPreference = newAddAccountPreference();
mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference,
DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
}
}
mProfiles.put(userInfo.id, profileData);
}
private void setCategoryTitleFromDevicePolicyResource(
AccessiblePreferenceCategory preferenceGroup, String stringId, int resourceIdentifier) {
preferenceGroup.setTitle(
mDpm.getResources().getString(stringId,
() -> mContext.getString(resourceIdentifier)));
}
private void setContentDescriptionFromDevicePolicyResource(
AccessiblePreferenceCategory preferenceGroup, String stringId, int resourceIdentifier,
String formatArgs) {
preferenceGroup.setContentDescription(mDpm.getResources().getString(stringId, () -> {
if (formatArgs != null) {
return mContext.getString(resourceIdentifier, formatArgs);
}
return mContext.getString(resourceIdentifier);
}));
}
private RestrictedPreference newAddAccountPreference() {
RestrictedPreference preference =
new RestrictedPreference(mFragment.getPreferenceManager().getContext());