Loading core/java/android/app/Notification.java +11 −12 Original line number Diff line number Diff line Loading @@ -762,14 +762,13 @@ public class Notification implements Parcelable public Bundle extras = new Bundle(); /** * All pending intents in the notification extras (notification extras, actions extras, * and remote input extras) as the system needs to be able to access them but touching * the extras bundle in the system process is not safe because the bundle may contain * All pending intents in the notification as the system needs to be able to access them but * touching the extras bundle in the system process is not safe because the bundle may contain * custom parcelable objects. * * @hide */ public ArraySet<PendingIntent> extrasPendingIntents; public ArraySet<PendingIntent> allPendingIntents; /** * {@link #extras} key: this is the title of the notification, Loading Loading @@ -1569,7 +1568,7 @@ public class Notification implements Parcelable // intents in extras are always written as the last entry. readFromParcelImpl(parcel); // Must be read last! extrasPendingIntents = (ArraySet<PendingIntent>) parcel.readArraySet(null); allPendingIntents = (ArraySet<PendingIntent>) parcel.readArraySet(null); } private void readFromParcelImpl(Parcel parcel) Loading Loading @@ -1727,8 +1726,8 @@ public class Notification implements Parcelable } } if (!ArrayUtils.isEmpty(extrasPendingIntents)) { that.extrasPendingIntents = new ArraySet<>(extrasPendingIntents); if (!ArrayUtils.isEmpty(allPendingIntents)) { that.allPendingIntents = new ArraySet<>(allPendingIntents); } if (this.actions != null) { Loading Loading @@ -1854,15 +1853,15 @@ public class Notification implements Parcelable // cannot look into the extras as there may be parcelables there that // the platform does not know how to handle. To go around that we have // an explicit list of the pending intents in the extras bundle. final boolean collectPendingIntents = (extrasPendingIntents == null); final boolean collectPendingIntents = (allPendingIntents == null); if (collectPendingIntents) { PendingIntent.setOnMarshaledListener( (PendingIntent intent, Parcel out, int outFlags) -> { if (parcel == out) { if (extrasPendingIntents == null) { extrasPendingIntents = new ArraySet<>(); if (allPendingIntents == null) { allPendingIntents = new ArraySet<>(); } extrasPendingIntents.add(intent); allPendingIntents.add(intent); } }); } Loading @@ -1871,7 +1870,7 @@ public class Notification implements Parcelable // want to intercept all pending events written to the pacel. writeToParcelImpl(parcel, flags); // Must be written last! parcel.writeArraySet(extrasPendingIntents); parcel.writeArraySet(allPendingIntents); } finally { if (collectPendingIntents) { PendingIntent.setOnMarshaledListener(null); Loading services/core/java/com/android/server/notification/NotificationManagerService.java +16 −35 Original line number Diff line number Diff line Loading @@ -2563,7 +2563,22 @@ public class NotificationManagerService extends SystemService { + " id=" + id + " notification=" + notification); } markAsSentFromNotification(notification); // Whitelist pending intents. if (notification.allPendingIntents != null) { final int intentCount = notification.allPendingIntents.size(); if (intentCount > 0) { final ActivityManagerInternal am = LocalServices .getService(ActivityManagerInternal.class); final long duration = LocalServices.getService( DeviceIdleController.LocalService.class).getNotificationWhitelistDuration(); for (int i = 0; i < intentCount; i++) { PendingIntent pendingIntent = notification.allPendingIntents.valueAt(i); if (pendingIntent != null) { am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(), duration); } } } } // Sanitize inputs notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN, Loading @@ -2579,40 +2594,6 @@ public class NotificationManagerService extends SystemService { idOut[0] = id; } private static void markAsSentFromNotification(Notification notification) { final ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class); final long duration = LocalServices.getService(DeviceIdleController.LocalService.class) .getNotificationWhitelistDuration(); if (notification.contentIntent != null) { am.setPendingIntentWhitelistDuration(notification.contentIntent.getTarget(), duration); } if (notification.deleteIntent != null) { am.setPendingIntentWhitelistDuration(notification.deleteIntent.getTarget(), duration); } if (notification.fullScreenIntent != null) { am.setPendingIntentWhitelistDuration(notification.fullScreenIntent.getTarget(), duration); } if (notification.actions != null) { for (Notification.Action action: notification.actions) { if (action.actionIntent == null) { continue; } am.setPendingIntentWhitelistDuration(action.actionIntent.getTarget(), duration); } } if (notification.extrasPendingIntents != null) { final int intentCount = notification.extrasPendingIntents.size(); for (int i = 0; i < intentCount; i++) { PendingIntent pendingIntent = notification.extrasPendingIntents.valueAt(i); if (pendingIntent != null) { am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(), duration); } } } } private class EnqueueNotificationRunnable implements Runnable { private final NotificationRecord r; private final int userId; Loading Loading
core/java/android/app/Notification.java +11 −12 Original line number Diff line number Diff line Loading @@ -762,14 +762,13 @@ public class Notification implements Parcelable public Bundle extras = new Bundle(); /** * All pending intents in the notification extras (notification extras, actions extras, * and remote input extras) as the system needs to be able to access them but touching * the extras bundle in the system process is not safe because the bundle may contain * All pending intents in the notification as the system needs to be able to access them but * touching the extras bundle in the system process is not safe because the bundle may contain * custom parcelable objects. * * @hide */ public ArraySet<PendingIntent> extrasPendingIntents; public ArraySet<PendingIntent> allPendingIntents; /** * {@link #extras} key: this is the title of the notification, Loading Loading @@ -1569,7 +1568,7 @@ public class Notification implements Parcelable // intents in extras are always written as the last entry. readFromParcelImpl(parcel); // Must be read last! extrasPendingIntents = (ArraySet<PendingIntent>) parcel.readArraySet(null); allPendingIntents = (ArraySet<PendingIntent>) parcel.readArraySet(null); } private void readFromParcelImpl(Parcel parcel) Loading Loading @@ -1727,8 +1726,8 @@ public class Notification implements Parcelable } } if (!ArrayUtils.isEmpty(extrasPendingIntents)) { that.extrasPendingIntents = new ArraySet<>(extrasPendingIntents); if (!ArrayUtils.isEmpty(allPendingIntents)) { that.allPendingIntents = new ArraySet<>(allPendingIntents); } if (this.actions != null) { Loading Loading @@ -1854,15 +1853,15 @@ public class Notification implements Parcelable // cannot look into the extras as there may be parcelables there that // the platform does not know how to handle. To go around that we have // an explicit list of the pending intents in the extras bundle. final boolean collectPendingIntents = (extrasPendingIntents == null); final boolean collectPendingIntents = (allPendingIntents == null); if (collectPendingIntents) { PendingIntent.setOnMarshaledListener( (PendingIntent intent, Parcel out, int outFlags) -> { if (parcel == out) { if (extrasPendingIntents == null) { extrasPendingIntents = new ArraySet<>(); if (allPendingIntents == null) { allPendingIntents = new ArraySet<>(); } extrasPendingIntents.add(intent); allPendingIntents.add(intent); } }); } Loading @@ -1871,7 +1870,7 @@ public class Notification implements Parcelable // want to intercept all pending events written to the pacel. writeToParcelImpl(parcel, flags); // Must be written last! parcel.writeArraySet(extrasPendingIntents); parcel.writeArraySet(allPendingIntents); } finally { if (collectPendingIntents) { PendingIntent.setOnMarshaledListener(null); Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +16 −35 Original line number Diff line number Diff line Loading @@ -2563,7 +2563,22 @@ public class NotificationManagerService extends SystemService { + " id=" + id + " notification=" + notification); } markAsSentFromNotification(notification); // Whitelist pending intents. if (notification.allPendingIntents != null) { final int intentCount = notification.allPendingIntents.size(); if (intentCount > 0) { final ActivityManagerInternal am = LocalServices .getService(ActivityManagerInternal.class); final long duration = LocalServices.getService( DeviceIdleController.LocalService.class).getNotificationWhitelistDuration(); for (int i = 0; i < intentCount; i++) { PendingIntent pendingIntent = notification.allPendingIntents.valueAt(i); if (pendingIntent != null) { am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(), duration); } } } } // Sanitize inputs notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN, Loading @@ -2579,40 +2594,6 @@ public class NotificationManagerService extends SystemService { idOut[0] = id; } private static void markAsSentFromNotification(Notification notification) { final ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class); final long duration = LocalServices.getService(DeviceIdleController.LocalService.class) .getNotificationWhitelistDuration(); if (notification.contentIntent != null) { am.setPendingIntentWhitelistDuration(notification.contentIntent.getTarget(), duration); } if (notification.deleteIntent != null) { am.setPendingIntentWhitelistDuration(notification.deleteIntent.getTarget(), duration); } if (notification.fullScreenIntent != null) { am.setPendingIntentWhitelistDuration(notification.fullScreenIntent.getTarget(), duration); } if (notification.actions != null) { for (Notification.Action action: notification.actions) { if (action.actionIntent == null) { continue; } am.setPendingIntentWhitelistDuration(action.actionIntent.getTarget(), duration); } } if (notification.extrasPendingIntents != null) { final int intentCount = notification.extrasPendingIntents.size(); for (int i = 0; i < intentCount; i++) { PendingIntent pendingIntent = notification.extrasPendingIntents.valueAt(i); if (pendingIntent != null) { am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(), duration); } } } } private class EnqueueNotificationRunnable implements Runnable { private final NotificationRecord r; private final int userId; Loading