Add MDM app name under "Work" in Accounts section of Settings.

Bug: 20024761
Change-Id: I3fe3fd6be8a2d96b36c402ea9bde8cc782797262
This commit is contained in:
Sudheer Shanka
2015-04-30 12:18:19 +01:00
parent e8d8af2b46
commit 0488dc9768
2 changed files with 60 additions and 5 deletions

View File

@@ -29,6 +29,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -269,8 +271,14 @@ public class AccountSettings extends SettingsPreferenceFragment
profileData.userInfo = userInfo;
if (addCategory) {
profileData.preferenceGroup = new PreferenceCategory(context);
profileData.preferenceGroup.setTitle(userInfo.isManagedProfile()
? R.string.category_work : R.string.category_personal);
if (userInfo.isManagedProfile()) {
profileData.preferenceGroup.setLayoutResource(R.layout.work_profile_category);
profileData.preferenceGroup.setTitle(R.string.category_work);
profileData.preferenceGroup.setSummary(getWorkGroupSummary(context, userInfo));
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
} else {
profileData.preferenceGroup.setTitle(R.string.category_personal);
}
parent.addPreference(profileData.preferenceGroup);
} else {
profileData.preferenceGroup = parent;
@@ -282,9 +290,6 @@ public class AccountSettings extends SettingsPreferenceFragment
profileData.addAccountPreference = newAddAccountPreference(context);
}
}
if (userInfo.isManagedProfile()) {
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
}
mProfiles.put(userInfo.id, profileData);
}
@@ -306,6 +311,16 @@ public class AccountSettings extends SettingsPreferenceFragment
return preference;
}
private String getWorkGroupSummary(Context context, UserInfo userInfo) {
PackageManager packageManager = context.getPackageManager();
ApplicationInfo adminApplicationInfo = Utils.getAdminApplicationInfo(context, userInfo.id);
if (adminApplicationInfo == null) {
return null;
}
CharSequence appLabel = packageManager.getApplicationLabel(adminApplicationInfo);
return getString(R.string.managing_admin, appLabel);
}
private void cleanUpPreferences() {
PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {