summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-11-04 12:15:05 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-11-04 12:15:05 +0000
commitae64fbca6fcadf8897411a9b53261e2bf1f88c5d (patch)
treece9dbb20fbd0688462fa60e985e285fe4c4fd860
parentb0dd13a861d5bbc04faf7aaf06ad6bc770f56621 (diff)
parent63baa239493661163cd5df7bb6d499533408183a (diff)
downloadbase-android14-mainline-media-release.tar.gz
Snap for 11052082 from 63baa239493661163cd5df7bb6d499533408183a to mainline-media-releaseaml_med_341312300aml_med_341312020android14-mainline-media-release
Change-Id: I014b2c501ff1f19d9dc5ab710526e9cdf761eea8
-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 0a617cdd2168..5c36a6b07392 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -685,8 +685,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.");
}
@@ -712,7 +711,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);
}
@@ -908,8 +907,7 @@ public class CompanionDeviceManagerService extends SystemService {
createNewAssociation(userId, packageName, macAddressObj, null, null, false);
}
- private void checkCanCallNotificationApi(String callingPackage) {
- final int userId = getCallingUserId();
+ private void checkCanCallNotificationApi(String callingPackage, int userId) {
enforceCallerIsSystemOr(userId, callingPackage);
if (getCallingUid() == SYSTEM_UID) return;