Skip to content

Commit 04946cf

Browse files
oasisfengaviraxp
authored andcommitted
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
1 parent df8fb7a commit 04946cf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,14 @@ public PendingIntent requestNotificationAccess(ComponentName component)
316316
.toString());
317317
long identity = Binder.clearCallingIdentity();
318318
try {
319-
return PendingIntent.getActivity(getContext(),
319+
return PendingIntent.getActivityAsUser(getContext(),
320320
0 /* request code */,
321321
NotificationAccessConfirmationActivityContract.launcherIntent(
322322
userId, component, packageTitle),
323323
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT
324-
| PendingIntent.FLAG_CANCEL_CURRENT);
324+
| PendingIntent.FLAG_CANCEL_CURRENT,
325+
null /* options */,
326+
new UserHandle(userId));
325327
} finally {
326328
Binder.restoreCallingIdentity(identity);
327329
}

0 commit comments

Comments
 (0)