summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt9
-rw-r--r--api/removed.txt6
-rw-r--r--core/java/android/app/ApplicationPackageManager.java123
-rw-r--r--core/java/android/app/Notification.java5
-rw-r--r--core/java/android/content/pm/LauncherActivityInfo.java11
-rw-r--r--core/java/android/content/pm/PackageManager.java74
-rw-r--r--core/java/android/os/UserManager.java159
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java4
-rw-r--r--test-runner/src/android/test/mock/MockPackageManager.java25
11 files changed, 246 insertions, 183 deletions
diff --git a/api/current.txt b/api/current.txt
index e21bfb9..eb458f7 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -8843,6 +8843,9 @@ package android.content.pm {
method public abstract android.content.pm.FeatureInfo[] getSystemAvailableFeatures();
method public abstract java.lang.String[] getSystemSharedLibraryNames();
method public abstract java.lang.CharSequence getText(java.lang.String, int, android.content.pm.ApplicationInfo);
+ method public abstract android.graphics.drawable.Drawable getUserBadgedDrawableForDensity(android.graphics.drawable.Drawable, android.os.UserHandle, android.graphics.Rect, int);
+ method public abstract android.graphics.drawable.Drawable getUserBadgedIcon(android.graphics.drawable.Drawable, android.os.UserHandle);
+ method public abstract java.lang.CharSequence getUserBadgedLabel(java.lang.CharSequence, android.os.UserHandle);
method public abstract android.content.res.XmlResourceParser getXml(java.lang.String, int, android.content.pm.ApplicationInfo);
method public abstract boolean hasSystemFeature(java.lang.String);
method public abstract boolean isSafeMode();
@@ -22465,9 +22468,6 @@ package android.os {
public class UserManager {
method public android.os.Bundle getApplicationRestrictions(java.lang.String);
- method public android.graphics.drawable.Drawable getBadgedDrawableForUser(android.graphics.drawable.Drawable, android.os.UserHandle, android.graphics.Rect, int);
- method public android.graphics.drawable.Drawable getBadgedIconForUser(android.graphics.drawable.Drawable, android.os.UserHandle);
- method public java.lang.CharSequence getBadgedLabelForUser(java.lang.CharSequence, android.os.UserHandle);
method public long getSerialNumberForUser(android.os.UserHandle);
method public int getUserCount();
method public android.os.UserHandle getUserForSerialNumber(long);
@@ -29741,6 +29741,9 @@ package android.test.mock {
method public android.content.pm.FeatureInfo[] getSystemAvailableFeatures();
method public java.lang.String[] getSystemSharedLibraryNames();
method public java.lang.CharSequence getText(java.lang.String, int, android.content.pm.ApplicationInfo);
+ method public android.graphics.drawable.Drawable getUserBadgedDrawableForDensity(android.graphics.drawable.Drawable, android.os.UserHandle, android.graphics.Rect, int);
+ method public android.graphics.drawable.Drawable getUserBadgedIcon(android.graphics.drawable.Drawable, android.os.UserHandle);
+ method public java.lang.CharSequence getUserBadgedLabel(java.lang.CharSequence, android.os.UserHandle);
method public android.content.res.XmlResourceParser getXml(java.lang.String, int, android.content.pm.ApplicationInfo);
method public boolean hasSystemFeature(java.lang.String);
method public boolean isSafeMode();
diff --git a/api/removed.txt b/api/removed.txt
index a910e78..0aa6d54 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -30,6 +30,12 @@ package android.os {
method public void wakeUp(long);
}
+ public class UserManager {
+ method public android.graphics.drawable.Drawable getBadgedDrawableForUser(android.graphics.drawable.Drawable, android.os.UserHandle, android.graphics.Rect, int);
+ method public android.graphics.drawable.Drawable getBadgedIconForUser(android.graphics.drawable.Drawable, android.os.UserHandle);
+ method public java.lang.CharSequence getBadgedLabelForUser(java.lang.CharSequence, android.os.UserHandle);
+ }
+
}
package android.service.notification {
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index e2def31..8b755cc 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -45,14 +45,17 @@ import android.content.pm.PermissionInfo;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
+import android.content.pm.UserInfo;
import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -864,6 +867,49 @@ final class ApplicationPackageManager extends PackageManager {
return getApplicationLogo(getApplicationInfo(packageName, 0));
}
+ @Override
+ public Drawable getUserBadgedIcon(Drawable icon, UserHandle user) {
+ final int badgeResId = getBadgeResIdForUser(user.getIdentifier());
+ if (badgeResId == 0) {
+ return icon;
+ }
+ Drawable badgeIcon = getDrawable("system", badgeResId, null);
+ return getBadgedDrawable(icon, badgeIcon, null, true);
+ }
+
+ @Override
+ public Drawable getUserBadgedDrawableForDensity(Drawable drawable, UserHandle user,
+ Rect badgeLocation, int badgeDensity) {
+ Drawable badgeDrawable = getUserBadgeForDensity(user, badgeDensity);
+ if (badgeDrawable == null) {
+ return drawable;
+ }
+ return getBadgedDrawable(drawable, badgeDrawable, badgeLocation, true);
+ }
+
+ @Override
+ public Drawable getUserBadgeForDensity(UserHandle user, int density) {
+ UserInfo userInfo = getUserIfProfile(user.getIdentifier());
+ if (userInfo != null && userInfo.isManagedProfile()) {
+ if (density <= 0) {
+ density = mContext.getResources().getDisplayMetrics().densityDpi;
+ }
+ return Resources.getSystem().getDrawableForDensity(
+ com.android.internal.R.drawable.ic_corp_badge, density);
+ }
+ return null;
+ }
+
+ @Override
+ public CharSequence getUserBadgedLabel(CharSequence label, UserHandle user) {
+ UserInfo userInfo = getUserIfProfile(user.getIdentifier());
+ if (userInfo != null && userInfo.isManagedProfile()) {
+ return Resources.getSystem().getString(
+ com.android.internal.R.string.managed_profile_label_badge, label);
+ }
+ return label;
+ }
+
@Override public Resources getResourcesForActivity(
ComponentName activityName) throws NameNotFoundException {
return getResourcesForApplication(
@@ -1647,8 +1693,79 @@ final class ApplicationPackageManager extends PackageManager {
if (dr == null) {
dr = itemInfo.loadDefaultIcon(this);
}
- return getUserManager().getBadgedDrawableForUser(dr,
- new UserHandle(mContext.getUserId()));
+ return getUserBadgedDrawableForDensity(dr, new UserHandle(mContext.getUserId()), null, 0);
+ }
+
+ private Drawable getBadgedDrawable(Drawable drawable, Drawable badgeDrawable,
+ Rect badgeLocation, boolean tryBadgeInPlace) {
+ final int badgedWidth = drawable.getIntrinsicWidth();
+ final int badgedHeight = drawable.getIntrinsicHeight();
+ final boolean canBadgeInPlace = tryBadgeInPlace
+ && (drawable instanceof BitmapDrawable)
+ && ((BitmapDrawable) drawable).getBitmap().isMutable();
+
+ final Bitmap bitmap;
+ if (canBadgeInPlace) {
+ bitmap = ((BitmapDrawable) drawable).getBitmap();
+ } else {
+ bitmap = Bitmap.createBitmap(badgedWidth, badgedHeight, Bitmap.Config.ARGB_8888);
+ }
+ Canvas canvas = new Canvas(bitmap);
+
+ if (!canBadgeInPlace) {
+ drawable.setBounds(0, 0, badgedWidth, badgedHeight);
+ drawable.draw(canvas);
+ }
+
+ if (badgeLocation != null) {
+ if (badgeLocation.left < 0 || badgeLocation.top < 0
+ || badgeLocation.width() > badgedWidth || badgeLocation.height() > badgedHeight) {
+ throw new IllegalArgumentException("Badge location " + badgeLocation
+ + " not in badged drawable bounds "
+ + new Rect(0, 0, badgedWidth, badgedHeight));
+ }
+ badgeDrawable.setBounds(0, 0, badgeLocation.width(), badgeLocation.height());
+
+ canvas.save();
+ canvas.translate(badgeLocation.left, badgeLocation.top);
+ badgeDrawable.draw(canvas);
+ canvas.restore();
+ } else {
+ badgeDrawable.setBounds(0, 0, badgedWidth, badgedHeight);
+ badgeDrawable.draw(canvas);
+ }
+
+ if (!canBadgeInPlace) {
+ BitmapDrawable mergedDrawable = new BitmapDrawable(mContext.getResources(), bitmap);
+
+ if (drawable instanceof BitmapDrawable) {
+ BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
+ mergedDrawable.setTargetDensity(bitmapDrawable.getBitmap().getDensity());
+ }
+
+ return mergedDrawable;
+ }
+
+ return drawable;
+ }
+
+ private int getBadgeResIdForUser(int userHandle) {
+ // Return the framework-provided badge.
+ UserInfo userInfo = getUserIfProfile(userHandle);
+ if (userInfo != null && userInfo.isManagedProfile()) {
+ return com.android.internal.R.drawable.ic_corp_icon_badge;
+ }
+ return 0;
+ }
+
+ private UserInfo getUserIfProfile(int userHandle) {
+ List<UserInfo> userProfiles = mUserManager.getProfiles(UserHandle.myUserId());
+ for (UserInfo user : userProfiles) {
+ if (user.id == userHandle) {
+ return user;
+ }
+ }
+ return null;
}
private final ContextImpl mContext;
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index f8dfdd9..1083943 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -38,7 +38,6 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.os.UserHandle;
-import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.MathUtils;
@@ -2581,8 +2580,8 @@ public class Notification implements Parcelable
private Drawable getProfileBadgeDrawable() {
// Note: This assumes that the current user can read the profile badge of the
// originating user.
- UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- return userManager.getBadgeForUser(new UserHandle(mContext.getUserId()), 0);
+ return mContext.getPackageManager().getUserBadgeForDensity(
+ new UserHandle(mContext.getUserId()), 0);
}
private Bitmap getProfileBadge() {
diff --git a/core/java/android/content/pm/LauncherActivityInfo.java b/core/java/android/content/pm/LauncherActivityInfo.java
index 0cff08b..ee23fcd 100644
--- a/core/java/android/content/pm/LauncherActivityInfo.java
+++ b/core/java/android/content/pm/LauncherActivityInfo.java
@@ -18,16 +18,10 @@ package android.content.pm;
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Bitmap.Config;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.DisplayMetrics;
@@ -39,11 +33,9 @@ import android.util.Log;
* and badged icon for the activity.
*/
public class LauncherActivityInfo {
- private static final boolean DEBUG = false;
private static final String TAG = "LauncherActivityInfo";
private final PackageManager mPm;
- private final UserManager mUm;
private ActivityInfo mActivityInfo;
private ComponentName mComponentName;
@@ -68,7 +60,6 @@ public class LauncherActivityInfo {
LauncherActivityInfo(Context context) {
mPm = context.getPackageManager();
- mUm = UserManager.get(context);
}
/**
@@ -179,7 +170,7 @@ public class LauncherActivityInfo {
}
if (originalIcon instanceof BitmapDrawable) {
- return mUm.getBadgedIconForUser(originalIcon, mUser);
+ return mPm.getUserBadgedIcon(originalIcon, mUser);
} else {
Log.e(TAG, "Unable to create badged icon for " + mActivityInfo);
}
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 1b15ff5..e87adda 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -31,6 +31,7 @@ import android.content.IntentSender;
import android.content.pm.PackageParser.PackageParserException;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
+import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -2882,6 +2883,79 @@ public abstract class PackageManager {
throws NameNotFoundException;
/**
+ * If the target user is a managed profile of the calling user or the caller
+ * is itself a managed profile, then this returns a badged copy of the given
+ * icon to be able to distinguish it from the original icon. For badging an
+ * arbitrary drawable use {@link #getUserBadgedDrawableForDensity(
+ * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
+ * <p>
+ * If the original drawable is a BitmapDrawable and the backing bitmap is
+ * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
+ * is performed in place and the original drawable is returned.
+ * </p>
+ *
+ * @param icon The icon to badge.
+ * @param user The target user.
+ * @return A drawable that combines the original icon and a badge as
+ * determined by the system.
+ */
+ public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
+
+ /**
+ * If the target user is a managed profile of the calling user or the caller
+ * is itself a managed profile, then this returns a badged copy of the given
+ * drawable allowing the user to distinguish it from the original drawable.
+ * The caller can specify the location in the bounds of the drawable to be
+ * badged where the badge should be applied as well as the density of the
+ * badge to be used.
+ * <p>
+ * If the original drawable is a BitmapDrawable and the backing bitmap is
+ * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
+ * is performed in place and the original drawable is returned.
+ * </p>
+ *
+ * @param drawable The drawable to badge.
+ * @param user The target user.
+ * @param badgeLocation Where in the bounds of the badged drawable to place
+ * the badge. If not provided, the badge is applied on top of the entire
+ * drawable being badged.
+ * @param badgeDensity The optional desired density for the badge as per
+ * {@link android.util.DisplayMetrics#densityDpi}. If not provided,
+ * the density of the display is used.
+ * @return A drawable that combines the original drawable and a badge as
+ * determined by the system.
+ */
+ public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
+ UserHandle user, Rect badgeLocation, int badgeDensity);
+
+ /**
+ * If the target user is a managed profile of the calling user or the caller
+ * is itself a managed profile, then this returns a drawable to use as a small
+ * icon to include in a view to distinguish it from the original icon.
+ *
+ * @param user The target user.
+ * @param density The optional desired density for the badge as per
+ * {@link android.util.DisplayMetrics#densityDpi}. If not provided
+ * the density of the current display is used.
+ * @return the drawable or null if no drawable is required.
+ * @hide
+ */
+ public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
+
+ /**
+ * If the target user is a managed profile of the calling user or the caller
+ * is itself a managed profile, then this returns a copy of the label with
+ * badging for accessibility services like talkback. E.g. passing in "Email"
+ * and it might return "Work Email" for Email in the work profile.
+ *
+ * @param label The label to change.
+ * @param user The target user.
+ * @return A label that combines the original label and a badge as
+ * determined by the system.
+ */
+ public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
+
+ /**
* Retrieve text from a package. This is a low-level API used by
* the various package manager info structures (such as
* {@link ComponentInfo} to implement retrieval of their associated
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 3749892..ec77a5e 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -22,10 +22,7 @@ import android.content.Context;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Bitmap.Config;
import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.provider.Settings;
import android.util.Log;
@@ -838,46 +835,10 @@ public class UserManager {
* @param user The target user.
* @return A drawable that combines the original icon and a badge as
* determined by the system.
+ * @removed
*/
public Drawable getBadgedIconForUser(Drawable icon, UserHandle user) {
- final int badgeResId = getBadgeResIdForUser(user.getIdentifier());
- if (badgeResId == 0) {
- return icon;
- }
- Drawable badgeIcon = mContext.getPackageManager()
- .getDrawable("system", badgeResId, null);
- return getBadgedDrawable(icon, badgeIcon, null, true);
- }
-
- /**
- * If the target user is a managed profile of the calling user or the caller
- * is itself a managed profile, then this returns a badged copy of the given
- * icon to be able to distinguish it from the original icon.
- * <p>
- * If the original drawable is not a BitmapDrawable, then the original
- * drawable is returned.
- * </p>
- *
- * @param icon The icon to badge.
- * @param user The target user.
- * @return A drawable that combines the original icon and a badge as
- * determined by the system.
- *
- * @deprecation Use {@link #getBadgedIconForUser(
- * android.graphics.drawable.Drawable, UserHandle)}
- *
- * @hide
- */
- @Deprecated
- public Drawable getBadgedDrawableForUser(Drawable icon, UserHandle user) {
- int badgeResId = getBadgeResIdForUser(user.getIdentifier());
- if (badgeResId == 0) {
- return icon;
- } else {
- Drawable badgeIcon = mContext.getPackageManager()
- .getDrawable("system", badgeResId, null);
- return getBadgedDrawable(icon, badgeIcon, null, false);
- }
+ return mContext.getPackageManager().getUserBadgedIcon(icon, user);
}
/**
@@ -903,14 +864,12 @@ public class UserManager {
* the density of the display is used.
* @return A drawable that combines the original drawable and a badge as
* determined by the system.
+ * @removed
*/
public Drawable getBadgedDrawableForUser(Drawable badgedDrawable, UserHandle user,
Rect badgeLocation, int badgeDensity) {
- Drawable badgeDrawable = getBadgeForUser(user, badgeDensity);
- if (badgeDrawable == null) {
- return badgedDrawable;
- }
- return getBadgedDrawable(badgedDrawable, badgeDrawable, badgeLocation, true);
+ return mContext.getPackageManager().getUserBadgedDrawableForDensity(badgedDrawable, user,
+ badgeLocation, badgeDensity);
}
/**
@@ -923,114 +882,10 @@ public class UserManager {
* @param user The target user.
* @return A label that combines the original label and a badge as
* determined by the system.
+ * @removed
*/
public CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user) {
- UserInfo userInfo = getUserIfProfile(user.getIdentifier());
- if (userInfo != null && userInfo.isManagedProfile()) {
- return Resources.getSystem().getString(
- R.string.managed_profile_label_badge, label);
- }
- return label;
- }
-
- /**
- * If the target user is a managed profile of the calling user or the caller
- * is itself a managed profile, then this returns a drawable to use as a small
- * icon to include in a view to distinguish it from the original icon.
- *
- * @param user The target user.
- * @param density The optional desired density for the badge as per
- * {@link android.util.DisplayMetrics#densityDpi}. If not provided
- * the density of the current display is used.
- * @return the drawable or null if no drawable is required.
- * @hide
- */
- public Drawable getBadgeForUser(UserHandle user, int density) {
- UserInfo userInfo = getUserIfProfile(user.getIdentifier());
- if (userInfo != null && userInfo.isManagedProfile()) {
- if (density <= 0) {
- density = mContext.getResources().getDisplayMetrics().densityDpi;
- }
- return Resources.getSystem().getDrawableForDensity(
- com.android.internal.R.drawable.ic_corp_badge, density);
- }
- return null;
- }
-
- private int getBadgeResIdForUser(int userHandle) {
- // Return the framework-provided badge.
- UserInfo userInfo = getUserIfProfile(userHandle);
- if (userInfo != null && userInfo.isManagedProfile()) {
- return com.android.internal.R.drawable.ic_corp_icon_badge;
- }
- return 0;
- }
-
- /**
- * @return UserInfo for userHandle if it exists and is a profile of the current
- * user or null.
- */
- private UserInfo getUserIfProfile(int userHandle) {
- List<UserInfo> userProfiles = getProfiles(getUserHandle());
- for (UserInfo user : userProfiles) {
- if (user.id == userHandle) {
- return user;
- }
- }
- return null;
- }
-
- private Drawable getBadgedDrawable(Drawable badgedDrawable, Drawable badgeDrawable,
- Rect badgeLocation, boolean tryBadgeInPlace) {
- final int badgedWidth = badgedDrawable.getIntrinsicWidth();
- final int badgedHeight = badgedDrawable.getIntrinsicHeight();
- final boolean canBadgeInPlace = tryBadgeInPlace
- && (badgedDrawable instanceof BitmapDrawable)
- && ((BitmapDrawable) badgedDrawable).getBitmap().isMutable();
-
- final Bitmap bitmap;
- if (canBadgeInPlace) {
- bitmap = ((BitmapDrawable) badgedDrawable).getBitmap();
- } else {
- bitmap = Bitmap.createBitmap(badgedWidth, badgedHeight, Config.ARGB_8888);
- }
- Canvas canvas = new Canvas(bitmap);
-
- if (!canBadgeInPlace) {
- badgedDrawable.setBounds(0, 0, badgedWidth, badgedHeight);
- badgedDrawable.draw(canvas);
- }
-
- if (badgeLocation != null) {
- if (badgeLocation.left < 0 || badgeLocation.top < 0
- || badgeLocation.width() > badgedWidth || badgeLocation.height() > badgedHeight) {
- throw new IllegalArgumentException("Badge location " + badgeLocation
- + " not in badged drawable bounds "
- + new Rect(0, 0, badgedWidth, badgedHeight));
- }
- badgeDrawable.setBounds(0, 0, badgeLocation.width(), badgeLocation.height());
-
- canvas.save();
- canvas.translate(badgeLocation.left, badgeLocation.top);
- badgeDrawable.draw(canvas);
- canvas.restore();
- } else {
- badgeDrawable.setBounds(0, 0, badgedWidth, badgedHeight);
- badgeDrawable.draw(canvas);
- }
-
- if (!canBadgeInPlace) {
- BitmapDrawable mergedDrawable = new BitmapDrawable(mContext.getResources(), bitmap);
-
- if (badgedDrawable instanceof BitmapDrawable) {
- BitmapDrawable bitmapDrawable = (BitmapDrawable) badgedDrawable;
- mergedDrawable.setTargetDensity(bitmapDrawable.getBitmap().getDensity());
- }
-
- return mergedDrawable;
- }
-
- return badgedDrawable;
+ return mContext.getPackageManager().getUserBadgedLabel(label, user);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
index 3e2ef94..b7434fd 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
@@ -34,14 +34,12 @@ import android.os.Handler;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.os.UserManager;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.android.systemui.R;
import com.android.systemui.recents.misc.SystemServicesProxy;
-import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import java.util.ArrayList;
@@ -205,8 +203,8 @@ public class RecentTasksLoader implements View.OnTouchListener {
Drawable icon = getFullResIcon(td.resolveInfo, pm);
if (td.userId != UserHandle.myUserId()) {
// Need to badge the icon
- final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- icon = um.getBadgedDrawableForUser(icon, new UserHandle(td.userId));
+ icon = mContext.getPackageManager().getUserBadgedDrawableForDensity(icon,
+ new UserHandle(td.userId), null, 0);
}
if (DEBUG) Log.v(TAG, "Loaded bitmap for task "
+ td + ": " + thumbnail);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 78fc4fb..07a42bd 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -49,7 +49,6 @@ import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
import android.util.Pair;
@@ -79,7 +78,6 @@ public class SystemServicesProxy {
AppWidgetManager mAwm;
PackageManager mPm;
IPackageManager mIpm;
- UserManager mUm;
SearchManager mSm;
WindowManager mWm;
Display mDisplay;
@@ -103,7 +101,6 @@ public class SystemServicesProxy {
mIam = ActivityManagerNative.getDefault();
mAwm = AppWidgetManager.getInstance(context);
mPm = context.getPackageManager();
- mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
mIpm = AppGlobals.getPackageManager();
mSm = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
@@ -343,7 +340,7 @@ public class SystemServicesProxy {
* necessary.
*/
public Drawable getActivityIcon(ActivityInfo info, int userId) {
- if (mPm == null || mUm == null) return null;
+ if (mPm == null) return null;
// If we are mocking, then return a mock label
if (Constants.DebugFlags.App.EnableSystemServicesProxy) {
@@ -359,7 +356,7 @@ public class SystemServicesProxy {
*/
public Drawable getBadgedIcon(Drawable icon, int userId) {
if (userId != UserHandle.myUserId()) {
- icon = mUm.getBadgedDrawableForUser(icon, new UserHandle(userId));
+ icon = mPm.getUserBadgedDrawableForDensity(icon, new UserHandle(userId), null, 0);
}
return icon;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index e5ca488..1c4556f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -1358,8 +1358,8 @@ public abstract class BaseStatusBar extends SystemUI implements
}
if (profileBadge != null) {
- Drawable profileDrawable
- = mUserManager.getBadgeForUser(entry.notification.getUser(), 0);
+ Drawable profileDrawable = mContext.getPackageManager().getUserBadgeForDensity(
+ entry.notification.getUser(), 0);
if (profileDrawable != null) {
profileBadge.setImageDrawable(profileDrawable);
profileBadge.setVisibility(View.VISIBLE);
diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java
index cd7d178..5a4e0eb 100644
--- a/test-runner/src/android/test/mock/MockPackageManager.java
+++ b/test-runner/src/android/test/mock/MockPackageManager.java
@@ -46,7 +46,7 @@ import android.content.pm.VerificationParams;
import android.content.pm.VerifierDeviceIdentity;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
-import android.graphics.Bitmap;
+import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.UserHandle;
@@ -403,6 +403,29 @@ public class MockPackageManager extends PackageManager {
}
@Override
+ public Drawable getUserBadgedIcon(Drawable icon, UserHandle user) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getUserBadgedDrawableForDensity(Drawable drawable, UserHandle user,
+ Rect badgeLocation,
+ int badgeDensity) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** @hide */
+ @Override
+ public Drawable getUserBadgeForDensity(UserHandle user, int density) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CharSequence getUserBadgedLabel(CharSequence label, UserHandle user) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) {
throw new UnsupportedOperationException();
}