Skip to content

Trust controllers from apps in current UID #2555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,18 @@ public int getMaxCommandsForMediaItems() {
}

/**
* Returns if the controller has been granted {@code android.permission.MEDIA_CONTENT_CONTROL}
* or has an enabled notification listener so it can be trusted to accept connection and
* incoming command requests.
* Returns whether one or more of the following is true:
*
* <ul>
* <li>the controller's app UID is in the same UID as the current process
* <li>the controller's app UID is the system UID
* <li>the controller has been granted {@code android.permission.MEDIA_CONTENT_CONTROL}
* <li>the controller has been granted {@code android.permission.STATUS_BAR_SERVICE}
* <li>the controller has an enabled notification listener
* </ul>
*
* to determine if the controller can be trusted to accept connection and incoming command
* requests.
*/
@UnstableApi
public boolean isTrusted() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public boolean isTrustedForMediaControl(MediaSessionManager.RemoteUserInfoImpl u
return isPermissionGranted(userInfo, PERMISSION_STATUS_BAR_SERVICE)
|| isPermissionGranted(userInfo, PERMISSION_MEDIA_CONTENT_CONTROL)
|| userInfo.getUid() == Process.SYSTEM_UID
|| userInfo.getUid() == Process.myUid()
|| isEnabledNotificationListener(userInfo);
}

Expand Down