Allow Device Management Role Holder to update Settings strings.

Test: manual
Bug: 188414370
Change-Id: I6e1a06619799a9e99382d791e72e2e4518f93cac
This commit is contained in:
Jonathan Scott
2022-01-19 15:19:08 +00:00
parent 47d115c3ff
commit e0d439472f
55 changed files with 788 additions and 231 deletions

View File

@@ -13,6 +13,9 @@
*/
package com.android.settings.enterprise;
import static android.app.admin.DevicePolicyResources.Strings.Settings.NUMBER_OF_DEVICE_ADMINS_NONE;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import com.android.settings.R;
@@ -23,20 +26,28 @@ import com.android.settings.overlay.FeatureFactory;
public class ManageDeviceAdminPreferenceController extends BasePreferenceController {
private final EnterprisePrivacyFeatureProvider mFeatureProvider;
private final DevicePolicyManager mDevicePolicyManager;
public ManageDeviceAdminPreferenceController(Context context, String key) {
super(context, key);
mFeatureProvider = FeatureFactory.getFactory(context)
.getEnterprisePrivacyFeatureProvider(context);
mDevicePolicyManager =
mContext.getSystemService(DevicePolicyManager.class);
}
@Override
public CharSequence getSummary() {
final int activeAdmins
= mFeatureProvider.getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile();
return activeAdmins == 0
? mContext.getResources().getString(R.string.number_of_device_admins_none)
: mContext.getResources().getQuantityString(R.plurals.number_of_device_admins,
if (activeAdmins == 0) {
return mDevicePolicyManager.getString(NUMBER_OF_DEVICE_ADMINS_NONE,
() -> mContext.getResources().getString(R.string.number_of_device_admins_none));
}
// TODO: override
return mContext.getResources().getQuantityString(R.plurals.number_of_device_admins,
activeAdmins, activeAdmins);
}