summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Chen <evanxinchen@google.com>2023-11-02 17:18:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-11-02 17:18:34 +0000
commita200a009ad02c10ad87d5d752c1491d1acea9baa (patch)
tree0a106f9ba86dff79a87ed4f781b5aeca6687d7b7
parentaa94ed987068c1e7982ead86036556a32589b37c (diff)
parentee88e15751ff0bc3da6b7c43dc7d94cebf1fc1a2 (diff)
downloadbase-a200a009ad02c10ad87d5d752c1491d1acea9baa.tar.gz
Merge "Do not allow setting notification access across users." into tm-qpr-dev
-rw-r--r--services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java8
1 files changed, 3 insertions, 5 deletions
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index f5ce00cb31c9..41546d2bdc38 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -620,8 +620,7 @@ public class CompanionDeviceManagerService extends SystemService {
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.");
}
@@ -647,7 +646,7 @@ public class CompanionDeviceManagerService extends SystemService {
@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);
}
@@ -804,8 +803,7 @@ public class CompanionDeviceManagerService extends SystemService {
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;