From 7dda2657be1fcc808566dab3482df9d643ceb0f5 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Fri, 11 Apr 2014 14:57:12 -0700 Subject: [PATCH] Expose an API to generate a badged icon for managed profiles. Change-Id: I6257f43934ba6eefe752003942d8d3bcf207d5f9 --- api/current.txt | 1 + core/java/android/os/UserManager.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/api/current.txt b/api/current.txt index 7de59d5eaa21c..9683990ce1e48 100644 --- a/api/current.txt +++ b/api/current.txt @@ -19947,6 +19947,7 @@ 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); method public long getSerialNumberForUser(android.os.UserHandle); method public int getUserCount(); method public android.os.UserHandle getUserForSerialNumber(long); diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 728c5607f0d8b..8aef9bdccb82b 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -492,7 +492,20 @@ public class UserManager { return profiles; } - /** @hide */ + /** + * 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. + *

+ * If the original drawable is not a BitmapDrawable, then the original + * drawable is returned. + *

+ * + * @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 Drawable getBadgedDrawableForUser(Drawable icon, UserHandle user) { int badgeResId = getBadgeResIdForUser(user.getIdentifier()); if (badgeResId == 0) {