Fix collection of Notification allPendingIntents
Notification.writeToParcel calls PendingIntent.setOnMarshaledListener() in order to "collect" all PendingIntents included anywhere inside it while serializing. This means that if _another notification_ is also serialized as part of this process, then the listener is overwritten -- and any fields written to the parcel after it will not participate in this collection. Notifications can contain other notifications (most obviously as their publicVersion, but also potentially inside any Bundle such as extras). There are two approaches to fixing this: 1) Make setOnMarshaledListener() *add* a listener instead of replacing it (renaming to add/remove). This will collect every PendingIntent wherever it is located, including recursively in other Notification objects. 2) Keep listeners exclusive but have writeToParcel() restore the previous one when exiting. This will not include other Notification objects, but also won't let those "break" the collection of their container. This CL goes with #1 because it seems the original intent of this code, collecting every PendingIntent (instead of an explicit list like contentIntent, deleteIntent, actions, etc). It also now collects the publicVersion's intents which is a bugfix. It will continue to collect PendingIntents present in whatever apps decide to stuff into extras -- but now including Notifications put in there too. Tests are added for the fixed behavior and to verify the allowlist calls from NotificationManagerService as well. Fixes: 282229007 Fixes: 289198162 Test: atest NotificationTest NotificationManagerServiceTest Change-Id: I836685c6aebe30276945e33a3dfdccd236fe89ec
Loading
Please register or sign in to comment