Loading core/java/android/app/ContextImpl.java +2 −55 Original line number Diff line number Diff line Loading @@ -2148,31 +2148,7 @@ class ContextImpl extends Context { } @Override public Drawable getApplicationIcon(ApplicationInfo info) { final int icon = info.icon; if (icon != 0) { ResourceName name = new ResourceName(info, icon); Drawable dr = getCachedIcon(name); if (dr != null) { return dr; } try { Resources r = getResourcesForApplication(info); dr = r.getDrawable(icon); if (DEBUG_ICONS) Log.v(TAG, "Getting drawable 0x" + Integer.toHexString(icon) + " from " + r + ": " + dr); putCachedIcon(name, dr); return dr; } catch (NameNotFoundException e) { Log.w("PackageManager", "Failure retrieving resources for" + info.packageName); } catch (RuntimeException e) { // If an exception was thrown, fall through to return // default icon. Log.w("PackageManager", "Failure retrieving app icon", e); } } return getDefaultActivityIcon(); return info.loadIcon(this); } @Override public Drawable getApplicationIcon(String packageName) Loading Loading @@ -2413,25 +2389,6 @@ class ContextImpl extends Context { } } private CharSequence getLabel(ResourceName name, ApplicationInfo app, int id) { CharSequence cs = getCachedString(name); if (cs != null) { return cs; } try { Resources r = getResourcesForApplication(app); cs = r.getText(id); putCachedString(name, cs); } catch (NameNotFoundException e) { Log.w("PackageManager", "Failure retrieving resources for" + app.packageName); } catch (RuntimeException e) { // If an exception was thrown, fall through to return null Log.w("ApplicationInfo", "Failure retrieving activity name", e); } return cs; } @Override public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) { Loading Loading @@ -2493,17 +2450,7 @@ class ContextImpl extends Context { @Override public CharSequence getApplicationLabel(ApplicationInfo info) { if (info.nonLocalizedLabel != null) { return info.nonLocalizedLabel; } final int id = info.labelRes; if (id != 0) { CharSequence cs = getLabel(new ResourceName(info, id), info, id); if (cs != null) { return cs; } } return info.packageName; return info.loadLabel(this); } @Override Loading core/java/android/content/pm/ApplicationInfo.java +31 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package android.content.pm; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; import android.util.Printer; Loading Loading @@ -496,7 +499,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { */ public CharSequence loadDescription(PackageManager pm) { if (descriptionRes != 0) { CharSequence label = pm.getText(packageName, descriptionRes, null); CharSequence label = pm.getText(packageName, descriptionRes, this); if (label != null) { return label; } Loading @@ -514,4 +517,31 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS | FLAG_SUPPORTS_SCREEN_DENSITIES); } /** * @hide */ @Override protected Drawable loadDefaultIcon(PackageManager pm) { if ((flags & FLAG_EXTERNAL_STORAGE) != 0 && isPackageUnavailable(pm)) { return Resources.getSystem().getDrawable( com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon); } return pm.getDefaultActivityIcon(); } private boolean isPackageUnavailable(PackageManager pm) { try { return pm.getPackageInfo(packageName, 0) == null; } catch (NameNotFoundException ex) { return true; } } /** * @hide */ @Override protected ApplicationInfo getApplicationInfo() { return this; } } core/java/android/content/pm/ComponentInfo.java +15 −19 Original line number Diff line number Diff line Loading @@ -99,24 +99,6 @@ public class ComponentInfo extends PackageItemInfo { return name; } @Override public Drawable loadIcon(PackageManager pm) { ApplicationInfo ai = applicationInfo; Drawable dr; if (icon != 0) { dr = pm.getDrawable(packageName, icon, ai); if (dr != null) { return dr; } } if (ai.icon != 0) { dr = pm.getDrawable(packageName, ai.icon, ai); if (dr != null) { return dr; } } return pm.getDefaultActivityIcon(); } /** * Return the icon resource identifier to use for this component. If * the component defines an icon, that is used; else, the application Loading Loading @@ -164,4 +146,18 @@ public class ComponentInfo extends PackageItemInfo { enabled = (source.readInt() != 0); exported = (source.readInt() != 0); } /** * @hide */ @Override protected Drawable loadDefaultIcon(PackageManager pm) { return applicationInfo.loadIcon(pm); } /** * @hide */ @Override protected ApplicationInfo getApplicationInfo() { return applicationInfo; } } core/java/android/content/pm/PackageItemInfo.java +33 −5 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public class PackageItemInfo { return nonLocalizedLabel; } if (labelRes != 0) { CharSequence label = pm.getText(packageName, labelRes, null); CharSequence label = pm.getText(packageName, labelRes, getApplicationInfo()); if (label != null) { return label.toString().trim(); } Loading @@ -123,15 +123,31 @@ public class PackageItemInfo { * 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 default activity icon is returned. * item does not have an icon, the item's default icon is returned * such as the default activity icon. */ public Drawable loadIcon(PackageManager pm) { if (icon != 0) { Drawable dr = pm.getDrawable(packageName, icon, null); Drawable dr = pm.getDrawable(packageName, icon, getApplicationInfo()); if (dr != null) { return dr; } } return loadDefaultIcon(pm); } /** * Retrieve the default graphical icon associated with this item. * * @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 default icon * such as the default activity icon. * * @hide */ protected Drawable loadDefaultIcon(PackageManager pm) { return pm.getDefaultActivityIcon(); } Loading @@ -152,7 +168,7 @@ public class PackageItemInfo { if (metaData != null) { int resid = metaData.getInt(name); if (resid != 0) { return pm.getXml(packageName, resid, null); return pm.getXml(packageName, resid, getApplicationInfo()); } } return null; Loading Loading @@ -193,6 +209,18 @@ public class PackageItemInfo { metaData = source.readBundle(); } /** * Get the ApplicationInfo for the application to which this item belongs, * if available, otherwise returns null. * * @return Returns the ApplicationInfo of this item, or null if not known. * * @hide */ protected ApplicationInfo getApplicationInfo() { return null; } public static class DisplayNameComparator implements Comparator<PackageItemInfo> { public DisplayNameComparator(PackageManager pm) { Loading core/java/android/content/pm/ResolveInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -163,8 +163,6 @@ public class ResolveInfo implements Parcelable { * item does not have an icon, the default activity icon is returned. */ public Drawable loadIcon(PackageManager pm) { ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo; ApplicationInfo ai = ci.applicationInfo; Drawable dr; if (resolvePackageName != null && icon != 0) { dr = pm.getDrawable(resolvePackageName, icon, null); Loading @@ -172,6 +170,8 @@ public class ResolveInfo implements Parcelable { return dr; } } ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo; ApplicationInfo ai = ci.applicationInfo; if (icon != 0) { dr = pm.getDrawable(ci.packageName, icon, ai); if (dr != null) { Loading Loading
core/java/android/app/ContextImpl.java +2 −55 Original line number Diff line number Diff line Loading @@ -2148,31 +2148,7 @@ class ContextImpl extends Context { } @Override public Drawable getApplicationIcon(ApplicationInfo info) { final int icon = info.icon; if (icon != 0) { ResourceName name = new ResourceName(info, icon); Drawable dr = getCachedIcon(name); if (dr != null) { return dr; } try { Resources r = getResourcesForApplication(info); dr = r.getDrawable(icon); if (DEBUG_ICONS) Log.v(TAG, "Getting drawable 0x" + Integer.toHexString(icon) + " from " + r + ": " + dr); putCachedIcon(name, dr); return dr; } catch (NameNotFoundException e) { Log.w("PackageManager", "Failure retrieving resources for" + info.packageName); } catch (RuntimeException e) { // If an exception was thrown, fall through to return // default icon. Log.w("PackageManager", "Failure retrieving app icon", e); } } return getDefaultActivityIcon(); return info.loadIcon(this); } @Override public Drawable getApplicationIcon(String packageName) Loading Loading @@ -2413,25 +2389,6 @@ class ContextImpl extends Context { } } private CharSequence getLabel(ResourceName name, ApplicationInfo app, int id) { CharSequence cs = getCachedString(name); if (cs != null) { return cs; } try { Resources r = getResourcesForApplication(app); cs = r.getText(id); putCachedString(name, cs); } catch (NameNotFoundException e) { Log.w("PackageManager", "Failure retrieving resources for" + app.packageName); } catch (RuntimeException e) { // If an exception was thrown, fall through to return null Log.w("ApplicationInfo", "Failure retrieving activity name", e); } return cs; } @Override public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) { Loading Loading @@ -2493,17 +2450,7 @@ class ContextImpl extends Context { @Override public CharSequence getApplicationLabel(ApplicationInfo info) { if (info.nonLocalizedLabel != null) { return info.nonLocalizedLabel; } final int id = info.labelRes; if (id != 0) { CharSequence cs = getLabel(new ResourceName(info, id), info, id); if (cs != null) { return cs; } } return info.packageName; return info.loadLabel(this); } @Override Loading
core/java/android/content/pm/ApplicationInfo.java +31 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package android.content.pm; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; import android.util.Printer; Loading Loading @@ -496,7 +499,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { */ public CharSequence loadDescription(PackageManager pm) { if (descriptionRes != 0) { CharSequence label = pm.getText(packageName, descriptionRes, null); CharSequence label = pm.getText(packageName, descriptionRes, this); if (label != null) { return label; } Loading @@ -514,4 +517,31 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS | FLAG_SUPPORTS_SCREEN_DENSITIES); } /** * @hide */ @Override protected Drawable loadDefaultIcon(PackageManager pm) { if ((flags & FLAG_EXTERNAL_STORAGE) != 0 && isPackageUnavailable(pm)) { return Resources.getSystem().getDrawable( com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon); } return pm.getDefaultActivityIcon(); } private boolean isPackageUnavailable(PackageManager pm) { try { return pm.getPackageInfo(packageName, 0) == null; } catch (NameNotFoundException ex) { return true; } } /** * @hide */ @Override protected ApplicationInfo getApplicationInfo() { return this; } }
core/java/android/content/pm/ComponentInfo.java +15 −19 Original line number Diff line number Diff line Loading @@ -99,24 +99,6 @@ public class ComponentInfo extends PackageItemInfo { return name; } @Override public Drawable loadIcon(PackageManager pm) { ApplicationInfo ai = applicationInfo; Drawable dr; if (icon != 0) { dr = pm.getDrawable(packageName, icon, ai); if (dr != null) { return dr; } } if (ai.icon != 0) { dr = pm.getDrawable(packageName, ai.icon, ai); if (dr != null) { return dr; } } return pm.getDefaultActivityIcon(); } /** * Return the icon resource identifier to use for this component. If * the component defines an icon, that is used; else, the application Loading Loading @@ -164,4 +146,18 @@ public class ComponentInfo extends PackageItemInfo { enabled = (source.readInt() != 0); exported = (source.readInt() != 0); } /** * @hide */ @Override protected Drawable loadDefaultIcon(PackageManager pm) { return applicationInfo.loadIcon(pm); } /** * @hide */ @Override protected ApplicationInfo getApplicationInfo() { return applicationInfo; } }
core/java/android/content/pm/PackageItemInfo.java +33 −5 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public class PackageItemInfo { return nonLocalizedLabel; } if (labelRes != 0) { CharSequence label = pm.getText(packageName, labelRes, null); CharSequence label = pm.getText(packageName, labelRes, getApplicationInfo()); if (label != null) { return label.toString().trim(); } Loading @@ -123,15 +123,31 @@ public class PackageItemInfo { * 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 default activity icon is returned. * item does not have an icon, the item's default icon is returned * such as the default activity icon. */ public Drawable loadIcon(PackageManager pm) { if (icon != 0) { Drawable dr = pm.getDrawable(packageName, icon, null); Drawable dr = pm.getDrawable(packageName, icon, getApplicationInfo()); if (dr != null) { return dr; } } return loadDefaultIcon(pm); } /** * Retrieve the default graphical icon associated with this item. * * @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 default icon * such as the default activity icon. * * @hide */ protected Drawable loadDefaultIcon(PackageManager pm) { return pm.getDefaultActivityIcon(); } Loading @@ -152,7 +168,7 @@ public class PackageItemInfo { if (metaData != null) { int resid = metaData.getInt(name); if (resid != 0) { return pm.getXml(packageName, resid, null); return pm.getXml(packageName, resid, getApplicationInfo()); } } return null; Loading Loading @@ -193,6 +209,18 @@ public class PackageItemInfo { metaData = source.readBundle(); } /** * Get the ApplicationInfo for the application to which this item belongs, * if available, otherwise returns null. * * @return Returns the ApplicationInfo of this item, or null if not known. * * @hide */ protected ApplicationInfo getApplicationInfo() { return null; } public static class DisplayNameComparator implements Comparator<PackageItemInfo> { public DisplayNameComparator(PackageManager pm) { Loading
core/java/android/content/pm/ResolveInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -163,8 +163,6 @@ public class ResolveInfo implements Parcelable { * item does not have an icon, the default activity icon is returned. */ public Drawable loadIcon(PackageManager pm) { ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo; ApplicationInfo ai = ci.applicationInfo; Drawable dr; if (resolvePackageName != null && icon != 0) { dr = pm.getDrawable(resolvePackageName, icon, null); Loading @@ -172,6 +170,8 @@ public class ResolveInfo implements Parcelable { return dr; } } ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo; ApplicationInfo ai = ci.applicationInfo; if (icon != 0) { dr = pm.getDrawable(ci.packageName, icon, ai); if (dr != null) { Loading