Changed the managed profile switching icon

Switched CrossProfileApps#getProfileSwitchingIconDrawable to use
PackageManager#getUserBadgeForDensityNoBackground which returns a
drawable that could be updated by the device management role holder.

Test: manual
Bug: 203548565
Bug: 188410712
Change-Id: Ia4246d7196b9d16e940d19752076b7d7f8916120
This commit is contained in:
kholoud mohamed
2021-11-23 17:27:15 +00:00
committed by Kholoud Mohamed
parent 3df423f2a8
commit 6c9333974d
2 changed files with 7 additions and 2 deletions

View File

@@ -282,7 +282,8 @@ public class CrossProfileApps {
final boolean isManagedProfile =
mUserManager.isManagedProfile(userHandle.getIdentifier());
if (isManagedProfile) {
return mResources.getDrawable(R.drawable.ic_corp_badge, null);
return mContext.getPackageManager().getUserBadgeForDensityNoBackground(
userHandle, /* density= */ 0);
} else {
return UserIcons.getDefaultUserIcon(
mResources, UserHandle.USER_SYSTEM, true /* light */);

View File

@@ -71,6 +71,8 @@ public class CrossProfileAppsTest {
private Resources mResources;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Drawable mDrawable;
@Mock
private PackageManager mPackageManager;
private CrossProfileApps mCrossProfileApps;
@Before
@@ -87,6 +89,7 @@ public class CrossProfileAppsTest {
Context.DEVICE_POLICY_SERVICE);
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(
mDevicePolicyManager);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
}
@Before
@@ -131,7 +134,8 @@ public class CrossProfileAppsTest {
setValidTargetProfile(MANAGED_PROFILE);
mCrossProfileApps.getProfileSwitchingIconDrawable(MANAGED_PROFILE);
verify(mResources).getDrawable(R.drawable.ic_corp_badge, null);
verify(mPackageManager).getUserBadgeForDensityNoBackground(
MANAGED_PROFILE, /* density= */0);
}
@Test