summaryrefslogtreecommitdiffstats
path: root/core/java/android/service
diff options
context:
space:
mode:
authorDan Sandler <dsandler@android.com>2015-07-22 10:45:30 -0400
committerDan Sandler <dsandler@android.com>2015-07-29 13:50:32 -0400
commit68079d54f3690885df9c5bbb691090633f3ef541 (patch)
tree4e38d02f0a1b2b9367e54e23bfd97db019e63986 /core/java/android/service
parent8be305dd6582f154c5a5894034a35fc8ec225b71 (diff)
downloadframeworks_base-68079d54f3690885df9c5bbb691090633f3ef541.zip
frameworks_base-68079d54f3690885df9c5bbb691090633f3ef541.tar.gz
frameworks_base-68079d54f3690885df9c5bbb691090633f3ef541.tar.bz2
Fix media notification action icons.
In addition to cleaning up some bare references to the icon slot, we now apply updates to notification RemoteViews in the context of the supplying app's package. This ensures we can find the drawables inside any Icon objects that were constructed without a proper package name, such as is the case with Actions (because the builder and constructor are Context-free and so don't know the package name). This CL also makes clear what was previously only implied: Non-resource action icons are not actually supported yet since they can't be pushed to TextView compound drawables using today's RemoteViews APIs. That will require an API change. Bug: 22600607 Change-Id: Ie6b88aed36e4db05be35f843ea3bc1898d4a5c96
Diffstat (limited to 'core/java/android/service')
-rw-r--r--core/java/android/service/notification/StatusBarNotification.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/service/notification/StatusBarNotification.java b/core/java/android/service/notification/StatusBarNotification.java
index 0eda692..2cab914 100644
--- a/core/java/android/service/notification/StatusBarNotification.java
+++ b/core/java/android/service/notification/StatusBarNotification.java
@@ -17,6 +17,9 @@
package android.service.notification;
import android.app.Notification;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
@@ -40,6 +43,7 @@ public class StatusBarNotification implements Parcelable {
private final long postTime;
private final int score;
+ private Context mContext; // used for inflation & icon expansion
/** @hide */
public StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid,
@@ -261,4 +265,24 @@ public class StatusBarNotification implements Parcelable {
public String getGroupKey() {
return groupKey;
}
+
+ /**
+ * @hide
+ */
+ public Context getPackageContext(Context context) {
+ if (mContext == null) {
+ try {
+ ApplicationInfo ai = context.getPackageManager()
+ .getApplicationInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES);
+ mContext = context.createApplicationContext(ai,
+ Context.CONTEXT_RESTRICTED);
+ } catch (PackageManager.NameNotFoundException e) {
+ mContext = null;
+ }
+ }
+ if (mContext == null) {
+ mContext = context;
+ }
+ return mContext;
+ }
}