Merge "Introduce new API to get an unbadged icon and unbadge permissions." into lmp-mr1-dev

This commit is contained in:
Benjamin Franz
2014-10-06 16:26:24 +00:00
committed by Android (Google) Code Review
5 changed files with 44 additions and 4 deletions

View File

@@ -1660,6 +1660,17 @@ final class ApplicationPackageManager extends PackageManager {
* @hide
*/
public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
Drawable dr = loadUnbadgedItemIcon(itemInfo, appInfo);
if (itemInfo.showUserIcon != UserHandle.USER_NULL) {
return dr;
}
return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId()));
}
/**
* @hide
*/
public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
if (itemInfo.showUserIcon != UserHandle.USER_NULL) {
Bitmap bitmap = getUserManager().getUserIcon(itemInfo.showUserIcon);
if (bitmap == null) {
@@ -1674,7 +1685,7 @@ final class ApplicationPackageManager extends PackageManager {
if (dr == null) {
dr = itemInfo.loadDefaultIcon(this);
}
return getUserBadgedIcon(dr, new UserHandle(mContext.getUserId()));
return dr;
}
private Drawable getBadgedDrawable(Drawable drawable, Drawable badgeDrawable,

View File

@@ -138,7 +138,7 @@ public class PackageItemInfo {
}
return packageName;
}
/**
* Retrieve the current graphical icon associated with this item. This
* will call back on the given PackageManager to load the icon from
@@ -155,6 +155,23 @@ public class PackageItemInfo {
return pm.loadItemIcon(this, getApplicationInfo());
}
/**
* Retrieve the current graphical icon associated with this item without
* the addition of a work badge if applicable.
* This will call back on the given PackageManager to load the icon from
* the application.
*
* @param pm A PackageManager from which the icon can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the item's icon. If the
* item does not have an icon, the item's default icon is returned
* such as the default activity icon.
*/
public Drawable loadUnbadgedIcon(PackageManager pm) {
return pm.loadUnbadgedItemIcon(this, getApplicationInfo());
}
/**
* Retrieve the current graphical banner associated with this item. This
* will call back on the given PackageManager to load the banner from

View File

@@ -3911,6 +3911,11 @@ public abstract class PackageManager {
*/
public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
/**
* @hide
*/
public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
/** {@hide} */
public abstract boolean isPackageAvailable(String packageName);

View File

@@ -99,12 +99,12 @@ public class AppSecurityPermissions {
public Drawable loadGroupIcon(PackageManager pm) {
if (icon != 0) {
return loadIcon(pm);
return loadUnbadgedIcon(pm);
} else {
ApplicationInfo appInfo;
try {
appInfo = pm.getApplicationInfo(packageName, 0);
return appInfo.loadIcon(pm);
return appInfo.loadUnbadgedIcon(pm);
} catch (NameNotFoundException e) {
}
}

View File

@@ -793,4 +793,11 @@ public class MockPackageManager extends PackageManager {
public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
throw new UnsupportedOperationException();
}
/**
* @hide
*/
public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
throw new UnsupportedOperationException();
}
}