Loading core/java/android/app/Notification.java +25 −19 Original line number Diff line number Diff line Loading @@ -1915,6 +1915,19 @@ public class Notification implements Parcelable builder.build(); // callers expect this notification to be ready to use } /** * @hide */ public static void addFieldsFromContext(Context context, Notification notification) { if (notification.extras.getParcelable(EXTRA_BUILDER_APPLICATION_INFO) == null) { notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, context.getApplicationInfo()); } if (!notification.extras.containsKey(EXTRA_ORIGINATING_USERID)) { notification.extras.putInt(EXTRA_ORIGINATING_USERID, context.getUserId()); } } @Override public String toString() { StringBuilder sb = new StringBuilder(); Loading Loading @@ -2104,11 +2117,6 @@ public class Notification implements Parcelable private NotificationColorUtil mColorUtil; private boolean mColorUtilInited = false; /** * The user that built the notification originally. */ private int mOriginatingUserId; /** * Constructs a new Builder with the defaults: * Loading Loading @@ -2940,7 +2948,7 @@ public class Notification implements Parcelable // Note: This assumes that the current user can read the profile badge of the // originating user. return mContext.getPackageManager().getUserBadgeForDensity( new UserHandle(mOriginatingUserId), 0); new UserHandle(mContext.getUserId()), 0); } private Bitmap getProfileBadge() { Loading Loading @@ -3428,10 +3436,6 @@ public class Notification implements Parcelable mN.extras.putStringArray(EXTRA_PEOPLE, mPersonList.toArray(new String[mPersonList.size()])); } if (mN.topic == null) { mN.topic = new Topic(TOPIC_DEFAULT, mContext.getString( R.string.default_notification_topic_label)); } return mN; } Loading @@ -3440,6 +3444,7 @@ public class Notification implements Parcelable ApplicationInfo applicationInfo = n.extras.getParcelable( EXTRA_BUILDER_APPLICATION_INFO); Context builderContext; if (applicationInfo != null) { try { builderContext = context.createApplicationContext(applicationInfo, Context.CONTEXT_RESTRICTED); Loading @@ -3447,6 +3452,9 @@ public class Notification implements Parcelable Log.e(TAG, "ApplicationInfo " + applicationInfo + " not found"); builderContext = context; // try with our context } } else { builderContext = context; // try with given context } return new Builder(builderContext, n); } Loading Loading @@ -3494,9 +3502,7 @@ public class Notification implements Parcelable } // lazy stuff from mContext; see comment in Builder(Context, Notification) mN.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, mContext.getApplicationInfo()); mOriginatingUserId = mContext.getUserId(); mN.extras.putInt(EXTRA_ORIGINATING_USERID, mOriginatingUserId); Notification.addFieldsFromContext(mContext, mN); buildUnstyled(); Loading core/java/android/app/NotificationManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,8 @@ public class NotificationManager int[] idOut = new int[1]; INotificationManager service = getService(); String pkg = mContext.getPackageName(); // Fix the notification as best we can. Notification.addFieldsFromContext(mContext, notification); if (notification.sound != null) { notification.sound = notification.sound.getCanonicalUri(); if (StrictMode.vmFileUriExposureEnabled()) { Loading services/core/java/com/android/server/notification/RankingHelper.java +9 −3 Original line number Diff line number Diff line Loading @@ -226,9 +226,7 @@ public class RankingHelper implements RankingConfig { r = new Record(); r.pkg = pkg; r.uid = uid; r.topics.put(Notification.TOPIC_DEFAULT, new Topic(new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(R.string.default_notification_topic_label)))); r.topics.put(Notification.TOPIC_DEFAULT, new Topic(createDefaultTopic())); mRecords.put(key, r); } return r; Loading Loading @@ -406,6 +404,9 @@ public class RankingHelper implements RankingConfig { } private Topic getOrCreateTopic(Record r, Notification.Topic topic) { if (topic == null) { topic = createDefaultTopic(); } Topic t = r.topics.get(topic.getId()); if (t != null) { return t; Loading @@ -416,6 +417,11 @@ public class RankingHelper implements RankingConfig { } } private Notification.Topic createDefaultTopic() { return new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(R.string.default_notification_topic_label)); } public void dump(PrintWriter pw, String prefix, NotificationManagerService.DumpFilter filter) { if (filter == null) { final int N = mSignalExtractors.length; Loading Loading
core/java/android/app/Notification.java +25 −19 Original line number Diff line number Diff line Loading @@ -1915,6 +1915,19 @@ public class Notification implements Parcelable builder.build(); // callers expect this notification to be ready to use } /** * @hide */ public static void addFieldsFromContext(Context context, Notification notification) { if (notification.extras.getParcelable(EXTRA_BUILDER_APPLICATION_INFO) == null) { notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, context.getApplicationInfo()); } if (!notification.extras.containsKey(EXTRA_ORIGINATING_USERID)) { notification.extras.putInt(EXTRA_ORIGINATING_USERID, context.getUserId()); } } @Override public String toString() { StringBuilder sb = new StringBuilder(); Loading Loading @@ -2104,11 +2117,6 @@ public class Notification implements Parcelable private NotificationColorUtil mColorUtil; private boolean mColorUtilInited = false; /** * The user that built the notification originally. */ private int mOriginatingUserId; /** * Constructs a new Builder with the defaults: * Loading Loading @@ -2940,7 +2948,7 @@ public class Notification implements Parcelable // Note: This assumes that the current user can read the profile badge of the // originating user. return mContext.getPackageManager().getUserBadgeForDensity( new UserHandle(mOriginatingUserId), 0); new UserHandle(mContext.getUserId()), 0); } private Bitmap getProfileBadge() { Loading Loading @@ -3428,10 +3436,6 @@ public class Notification implements Parcelable mN.extras.putStringArray(EXTRA_PEOPLE, mPersonList.toArray(new String[mPersonList.size()])); } if (mN.topic == null) { mN.topic = new Topic(TOPIC_DEFAULT, mContext.getString( R.string.default_notification_topic_label)); } return mN; } Loading @@ -3440,6 +3444,7 @@ public class Notification implements Parcelable ApplicationInfo applicationInfo = n.extras.getParcelable( EXTRA_BUILDER_APPLICATION_INFO); Context builderContext; if (applicationInfo != null) { try { builderContext = context.createApplicationContext(applicationInfo, Context.CONTEXT_RESTRICTED); Loading @@ -3447,6 +3452,9 @@ public class Notification implements Parcelable Log.e(TAG, "ApplicationInfo " + applicationInfo + " not found"); builderContext = context; // try with our context } } else { builderContext = context; // try with given context } return new Builder(builderContext, n); } Loading Loading @@ -3494,9 +3502,7 @@ public class Notification implements Parcelable } // lazy stuff from mContext; see comment in Builder(Context, Notification) mN.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, mContext.getApplicationInfo()); mOriginatingUserId = mContext.getUserId(); mN.extras.putInt(EXTRA_ORIGINATING_USERID, mOriginatingUserId); Notification.addFieldsFromContext(mContext, mN); buildUnstyled(); Loading
core/java/android/app/NotificationManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,8 @@ public class NotificationManager int[] idOut = new int[1]; INotificationManager service = getService(); String pkg = mContext.getPackageName(); // Fix the notification as best we can. Notification.addFieldsFromContext(mContext, notification); if (notification.sound != null) { notification.sound = notification.sound.getCanonicalUri(); if (StrictMode.vmFileUriExposureEnabled()) { Loading
services/core/java/com/android/server/notification/RankingHelper.java +9 −3 Original line number Diff line number Diff line Loading @@ -226,9 +226,7 @@ public class RankingHelper implements RankingConfig { r = new Record(); r.pkg = pkg; r.uid = uid; r.topics.put(Notification.TOPIC_DEFAULT, new Topic(new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(R.string.default_notification_topic_label)))); r.topics.put(Notification.TOPIC_DEFAULT, new Topic(createDefaultTopic())); mRecords.put(key, r); } return r; Loading Loading @@ -406,6 +404,9 @@ public class RankingHelper implements RankingConfig { } private Topic getOrCreateTopic(Record r, Notification.Topic topic) { if (topic == null) { topic = createDefaultTopic(); } Topic t = r.topics.get(topic.getId()); if (t != null) { return t; Loading @@ -416,6 +417,11 @@ public class RankingHelper implements RankingConfig { } } private Notification.Topic createDefaultTopic() { return new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(R.string.default_notification_topic_label)); } public void dump(PrintWriter pw, String prefix, NotificationManagerService.DumpFilter filter) { if (filter == null) { final int N = mSignalExtractors.length; Loading