Merge "Do not allow setting notification access across users." into tm-dev am: 2335fc14da
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/25096532
Change-Id: I95ea1749ddd8912d42a53f49bc3c9b14eaefc983
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index 3ac7b8e..5f6211f 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -543,8 +543,7 @@
public PendingIntent requestNotificationAccess(ComponentName component, int userId)
throws RemoteException {
String callingPackage = component.getPackageName();
- checkCanCallNotificationApi(callingPackage);
- // TODO: check userId.
+ checkCanCallNotificationApi(callingPackage, userId);
if (component.flattenToString().length() > MAX_CN_LENGTH) {
throw new IllegalArgumentException("Component name is too long.");
}
@@ -570,7 +569,7 @@
@Deprecated
@Override
public boolean hasNotificationAccess(ComponentName component) throws RemoteException {
- checkCanCallNotificationApi(component.getPackageName());
+ checkCanCallNotificationApi(component.getPackageName(), getCallingUserId());
NotificationManager nm = getContext().getSystemService(NotificationManager.class);
return nm.isNotificationListenerAccessGranted(component);
}
@@ -727,8 +726,7 @@
legacyCreateAssociation(userId, macAddress, packageName, null);
}
- private void checkCanCallNotificationApi(String callingPackage) {
- final int userId = getCallingUserId();
+ private void checkCanCallNotificationApi(String callingPackage, int userId) {
enforceCallerIsSystemOr(userId, callingPackage);
if (getCallingUid() == SYSTEM_UID) return;