summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOasis Feng <git@id.oasisfeng.com>2020-08-31 02:53:45 +0000
committerOasis Feng <oasisfeng@gmail.com>2020-08-31 03:49:14 +0000
commitbec69ef42b4be53a69b83ac9af86b095d479dd23 (patch)
tree94a14e600f62ca0f538eba25a585289acba7856a
parent72eda1bb48c76ba5903441022aff4f761cd9bb4e (diff)
Fix CDM.requestNotificationAccess() in profile.
If invoked by app running in managed profile, CompanionDeviceManager .requestNotificationAccess() is actually trying to grant access to that app in parent profile, which may not even exist. Notification listener may not need to be running in managed profile, but in order to access and control media sessions in managed profile, notification listener must be granted access in that managed profile. Test: Run test cases of CompanionDeviceManager in managed profile. Signed-off-by: Oasis Feng <oasisfeng@gmail.com> Change-Id: Id33c4956097300c5ec1c6c50ebee91dee9a49c33
-rw-r--r--services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index 067becbf0c52..a4347333685b 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -316,12 +316,14 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
.toString());
long identity = Binder.clearCallingIdentity();
try {
- return PendingIntent.getActivity(getContext(),
+ return PendingIntent.getActivityAsUser(getContext(),
0 /* request code */,
NotificationAccessConfirmationActivityContract.launcherIntent(
userId, component, packageTitle),
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT
- | PendingIntent.FLAG_CANCEL_CURRENT);
+ | PendingIntent.FLAG_CANCEL_CURRENT,
+ null /* options */,
+ new UserHandle(userId));
} finally {
Binder.restoreCallingIdentity(identity);
}