Merge "Fix background bypass via notifications" into qt-dev am: 22500563c1 am: 57af3050d2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14937196 Change-Id: I0bf46422d4f7d2621a33776a4c98375d566af117
This commit is contained in:
@@ -3028,6 +3028,19 @@ public class Notification implements Parcelable
|
|||||||
builder.build(); // callers expect this notification to be ready to use
|
builder.build(); // callers expect this notification to be ready to use
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the token used for background operations for the pending intents associated with this
|
||||||
|
* notification.
|
||||||
|
*
|
||||||
|
* This token is automatically set during deserialization for you, you usually won't need to
|
||||||
|
* call this unless you want to change the existing token, if any.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void setAllowlistToken(@Nullable IBinder token) {
|
||||||
|
mWhitelistToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3848,6 +3848,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Notifications returned here will have allowlistToken stripped from them. */
|
||||||
private StatusBarNotification sanitizeSbn(String pkg, int userId,
|
private StatusBarNotification sanitizeSbn(String pkg, int userId,
|
||||||
StatusBarNotification sbn) {
|
StatusBarNotification sbn) {
|
||||||
if (sbn.getUserId() == userId) {
|
if (sbn.getUserId() == userId) {
|
||||||
@@ -3855,11 +3856,16 @@ public class NotificationManagerService extends SystemService {
|
|||||||
// We could pass back a cloneLight() but clients might get confused and
|
// We could pass back a cloneLight() but clients might get confused and
|
||||||
// try to send this thing back to notify() again, which would not work
|
// try to send this thing back to notify() again, which would not work
|
||||||
// very well.
|
// very well.
|
||||||
|
Notification notification = sbn.getNotification().clone();
|
||||||
|
// Remove background token before returning notification to untrusted app, this
|
||||||
|
// ensures the app isn't able to perform background operations that are
|
||||||
|
// associated with notification interactions.
|
||||||
|
notification.setAllowlistToken(null);
|
||||||
return new StatusBarNotification(
|
return new StatusBarNotification(
|
||||||
sbn.getPackageName(),
|
sbn.getPackageName(),
|
||||||
sbn.getOpPkg(),
|
sbn.getOpPkg(),
|
||||||
sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(),
|
sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(),
|
||||||
sbn.getNotification().clone(),
|
notification,
|
||||||
sbn.getUser(), sbn.getOverrideGroupKey(), sbn.getPostTime());
|
sbn.getUser(), sbn.getOverrideGroupKey(), sbn.getPostTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user