Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ec0be1f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Stop using UserHandle.getUserId() in media sever"

parents b46aecc2 277ea28e
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -172,13 +172,14 @@ class AudioPlayerStateMonitor {
     */
    public void cleanUpAudioPlaybackUids(int mediaButtonSessionUid) {
        synchronized (mLock) {
            int userId = UserHandle.getUserId(mediaButtonSessionUid);
            int userId = UserHandle.getUserHandleForUid(mediaButtonSessionUid).getIdentifier();
            for (int i = mSortedAudioPlaybackClientUids.size() - 1; i >= 0; i--) {
                if (mSortedAudioPlaybackClientUids.get(i) == mediaButtonSessionUid) {
                    break;
                }
                int uid = mSortedAudioPlaybackClientUids.get(i);
                if (userId == UserHandle.getUserId(uid) && !isPlaybackActive(uid)) {
                if (userId == UserHandle.getUserHandleForUid(uid).getIdentifier()
                        && !isPlaybackActive(uid)) {
                    // Clean up unnecessary UIDs.
                    // It doesn't need to be managed profile aware because it's just to prevent
                    // the list from increasing indefinitely. The media button session updating
+3 −3
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ class MediaRouter2ServiceImpl {
    @NonNull
    public List<MediaRoute2Info> getSystemRoutes() {
        final int uid = Binder.getCallingUid();
        final int userId = UserHandle.getUserId(uid);
        final int userId = UserHandle.getUserHandleForUid(uid).getIdentifier();

        final long token = Binder.clearCallingIdentity();
        try {
@@ -117,7 +117,7 @@ class MediaRouter2ServiceImpl {

        final int uid = Binder.getCallingUid();
        final int pid = Binder.getCallingPid();
        final int userId = UserHandle.getUserId(uid);
        final int userId = UserHandle.getUserHandleForUid(uid).getIdentifier();
        final boolean trusted = mContext.checkCallingOrSelfPermission(
                android.Manifest.permission.CONFIGURE_WIFI_DISPLAY)
                == PackageManager.PERMISSION_GRANTED;
@@ -152,7 +152,7 @@ class MediaRouter2ServiceImpl {

        final int uid = Binder.getCallingUid();
        final int pid = Binder.getCallingPid();
        final int userId = UserHandle.getUserId(uid);
        final int userId = UserHandle.getUserHandleForUid(uid).getIdentifier();

        final long token = Binder.clearCallingIdentity();
        try {
+2 −1
Original line number Diff line number Diff line
@@ -579,7 +579,8 @@ public final class MediaRouterService extends IMediaRouterService.Stub
    void restoreRoute(int uid) {
        ClientRecord clientRecord = null;
        synchronized (mLock) {
            UserRecord userRecord = mUserRecords.get(UserHandle.getUserId(uid));
            UserRecord userRecord = mUserRecords.get(
                    UserHandle.getUserHandleForUid(uid).getIdentifier());
            if (userRecord != null && userRecord.mClientRecords != null) {
                for (ClientRecord cr : userRecord.mClientRecords) {
                    if (validatePackageName(uid, cr.mPackageName)) {
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class MediaSession2Record implements MediaSessionRecordImpl {

    @Override
    public int getUserId() {
        return UserHandle.getUserId(mSessionToken.getUid());
        return UserHandle.getUserHandleForUid(mSessionToken.getUid()).getIdentifier();
    }

    @Override
+4 −3
Original line number Diff line number Diff line
@@ -166,7 +166,8 @@ public class MediaSessionService extends SystemService implements Monitor {
                    }
                    synchronized (mLock) {
                        FullUserRecord user = getFullUserRecordLocked(
                                UserHandle.getUserId(config.getClientUid()));
                                UserHandle.getUserHandleForUid(config.getClientUid())
                                        .getIdentifier());
                        if (user != null) {
                            user.mPriorityStack.updateMediaButtonSessionIfNeeded();
                        }
@@ -472,8 +473,8 @@ public class MediaSessionService extends SystemService implements Monitor {
        if (mContext
                .checkPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL, pid, uid)
                != PackageManager.PERMISSION_GRANTED
                && !isEnabledNotificationListener(compName, UserHandle.getUserId(uid),
                resolvedUserId)) {
                && !isEnabledNotificationListener(compName,
                UserHandle.getUserHandleForUid(uid).getIdentifier(), resolvedUserId)) {
            throw new SecurityException("Missing permission to control media.");
        }
    }