Loading core/java/android/service/notification/NotificationListenerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -1220,6 +1220,7 @@ public abstract class NotificationListenerService extends Service { // convert icon metadata to legacy format for older clients createLegacyIconExtras(sbn.getNotification()); maybePopulateRemoteViews(sbn.getNotification()); maybePopulatePeople(sbn.getNotification()); } catch (IllegalArgumentException e) { // warn and drop corrupt notification Log.w(TAG, "onNotificationPosted: can't rebuild notification from " + Loading services/core/java/com/android/server/notification/ValidateNotificationPeople.java +27 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.notification; import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.content.pm.PackageManager; Loading Loading @@ -45,8 +46,6 @@ import java.util.Set; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import android.os.SystemClock; /** * This {@link NotificationSignalExtractor} attempts to validate * people references. Also elevates the priority of real people. Loading Loading @@ -231,7 +230,6 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { private PeopleRankingReconsideration validatePeople(Context context, String key, Bundle extras, List<String> peopleOverride, float[] affinityOut) { long start = SystemClock.elapsedRealtime(); float affinity = NONE; if (extras == null) { return null; Loading @@ -239,7 +237,7 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { final Set<String> people = new ArraySet<>(peopleOverride); final String[] notificationPeople = getExtraPeople(extras); if (notificationPeople != null ) { people.addAll(Arrays.asList(getExtraPeople(extras))); people.addAll(Arrays.asList(notificationPeople)); } if (VERBOSE) Slog.i(TAG, "Validating: " + key + " for " + context.getUserId()); Loading Loading @@ -283,7 +281,31 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { // VisibleForTesting public static String[] getExtraPeople(Bundle extras) { Object people = extras.get(Notification.EXTRA_PEOPLE_LIST); String[] peopleList = getExtraPeopleForKey(extras, Notification.EXTRA_PEOPLE_LIST); String[] legacyPeople = getExtraPeopleForKey(extras, Notification.EXTRA_PEOPLE); return combineLists(legacyPeople, peopleList); } private static String[] combineLists(String[] first, String[] second) { if (first == null) { return second; } if (second == null) { return first; } ArraySet<String> people = new ArraySet<>(first.length + second.length); for (String person: first) { people.add(person); } for (String person: second) { people.add(person); } return (String[]) people.toArray(); } @Nullable private static String[] getExtraPeopleForKey(Bundle extras, String key) { Object people = extras.get(key); if (people instanceof String[]) { return (String[]) people; } Loading Loading @@ -458,7 +480,6 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { @Override public void work() { long start = SystemClock.elapsedRealtime(); if (VERBOSE) Slog.i(TAG, "Executing: validation for: " + mKey); long timeStartMs = System.currentTimeMillis(); for (final String handle: mPendingLookups) { Loading Loading
core/java/android/service/notification/NotificationListenerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -1220,6 +1220,7 @@ public abstract class NotificationListenerService extends Service { // convert icon metadata to legacy format for older clients createLegacyIconExtras(sbn.getNotification()); maybePopulateRemoteViews(sbn.getNotification()); maybePopulatePeople(sbn.getNotification()); } catch (IllegalArgumentException e) { // warn and drop corrupt notification Log.w(TAG, "onNotificationPosted: can't rebuild notification from " + Loading
services/core/java/com/android/server/notification/ValidateNotificationPeople.java +27 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.notification; import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.content.pm.PackageManager; Loading Loading @@ -45,8 +46,6 @@ import java.util.Set; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import android.os.SystemClock; /** * This {@link NotificationSignalExtractor} attempts to validate * people references. Also elevates the priority of real people. Loading Loading @@ -231,7 +230,6 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { private PeopleRankingReconsideration validatePeople(Context context, String key, Bundle extras, List<String> peopleOverride, float[] affinityOut) { long start = SystemClock.elapsedRealtime(); float affinity = NONE; if (extras == null) { return null; Loading @@ -239,7 +237,7 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { final Set<String> people = new ArraySet<>(peopleOverride); final String[] notificationPeople = getExtraPeople(extras); if (notificationPeople != null ) { people.addAll(Arrays.asList(getExtraPeople(extras))); people.addAll(Arrays.asList(notificationPeople)); } if (VERBOSE) Slog.i(TAG, "Validating: " + key + " for " + context.getUserId()); Loading Loading @@ -283,7 +281,31 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { // VisibleForTesting public static String[] getExtraPeople(Bundle extras) { Object people = extras.get(Notification.EXTRA_PEOPLE_LIST); String[] peopleList = getExtraPeopleForKey(extras, Notification.EXTRA_PEOPLE_LIST); String[] legacyPeople = getExtraPeopleForKey(extras, Notification.EXTRA_PEOPLE); return combineLists(legacyPeople, peopleList); } private static String[] combineLists(String[] first, String[] second) { if (first == null) { return second; } if (second == null) { return first; } ArraySet<String> people = new ArraySet<>(first.length + second.length); for (String person: first) { people.add(person); } for (String person: second) { people.add(person); } return (String[]) people.toArray(); } @Nullable private static String[] getExtraPeopleForKey(Bundle extras, String key) { Object people = extras.get(key); if (people instanceof String[]) { return (String[]) people; } Loading Loading @@ -458,7 +480,6 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { @Override public void work() { long start = SystemClock.elapsedRealtime(); if (VERBOSE) Slog.i(TAG, "Executing: validation for: " + mKey); long timeStartMs = System.currentTimeMillis(); for (final String handle: mPendingLookups) { Loading