Skip to content

Commit

Permalink
Fix CDM.requestNotificationAccess() in profile.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Change-Id: Id33c4956097300c5ec1c6c50ebee91dee9a49c33
  • Loading branch information
oasisfeng authored and sagarrokade006 committed Sep 22, 2020
1 parent 0c4a484 commit 8878a3b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,14 @@ public PendingIntent requestNotificationAccess(ComponentName component)
.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);
}
Expand Down

0 comments on commit 8878a3b

Please sign in to comment.