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

Commit e3863740 authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

Remove MediaSession2Record

Test: passed MediaComponentsTest
Change-Id: Iec56106877da82ba7466a83ac26727e2498bae23
parent 643825e4
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -118,16 +118,15 @@ public class MediaController2Impl implements MediaController2Provider {

    @Override
    public void initialize() {
        SessionToken2Impl impl = SessionToken2Impl.from(mToken);
        // TODO(jaewan): More sanity checks.
        if (impl.getSessionBinder() == null) {
        if (mToken.getType() == SessionToken2.TYPE_SESSION) {
            // Session
            mServiceConnection = null;
            connectToSession(SessionToken2Impl.from(mToken).getSessionBinder());
        } else {
            // Session service
            mServiceConnection = new SessionServiceConnection();
            connectToService();
        } else {
            // Session
            mServiceConnection = null;
            connectToSession(impl.getSessionBinder());
        }
    }

+4 −4
Original line number Diff line number Diff line
@@ -148,10 +148,10 @@ public class MediaSession2Impl implements MediaSession2Provider {
                    + " session services define the same id=" + id);
        } else if (libraryService != null) {
            mSessionToken = new SessionToken2Impl(context, Process.myUid(), TYPE_LIBRARY_SERVICE,
                    mContext.getPackageName(), libraryService, id, mSessionStub).getInstance();
                    mContext.getPackageName(), libraryService, id, null).getInstance();
        } else if (sessionService != null) {
            mSessionToken = new SessionToken2Impl(context, Process.myUid(), TYPE_SESSION_SERVICE,
                    mContext.getPackageName(), sessionService, id, mSessionStub).getInstance();
                    mContext.getPackageName(), sessionService, id, null).getInstance();
        } else {
            mSessionToken = new SessionToken2Impl(context, Process.myUid(), TYPE_SESSION,
                    mContext.getPackageName(), null, id, mSessionStub).getInstance();
@@ -166,7 +166,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
        // a session in another package.
        MediaSessionManager manager =
                (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE);
        if (!manager.onSessionCreated(mSessionToken)) {
        if (!manager.createSession2(mSessionToken)) {
            throw new IllegalStateException("Session with the same id is already used by"
                    + " another process. Use MediaController2 instead.");
        }
@@ -281,7 +281,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
        // Stop system service from listening this session first.
        MediaSessionManager manager =
                (MediaSessionManager) mContext.getSystemService(Context.MEDIA_SESSION_SERVICE);
        manager.onSessionDestroyed(mSessionToken);
        manager.destroySession2(mSessionToken);

        if (mSessionStub != null) {
            if (DEBUG) {
+8 −8
Original line number Diff line number Diff line
@@ -126,26 +126,26 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
            throws RuntimeException {
        final MediaSession2Impl sessionImpl = getSession();
        final Context context = sessionImpl.getContext();
        final ControllerInfo request = new ControllerInfo(context,
        final ControllerInfo controllerInfo = new ControllerInfo(context,
                Binder.getCallingUid(), Binder.getCallingPid(), callingPackage, caller);
        sessionImpl.getCallbackExecutor().execute(() -> {
            final MediaSession2Impl session = mSession.get();
            if (session == null) {
                return;
            }
            CommandGroup allowedCommands = session.getCallback().onConnect(request);
            // Don't reject connection for the request from trusted app.
            CommandGroup allowedCommands = session.getCallback().onConnect(controllerInfo);
            // Don't reject connection for the controllerInfo from trusted app.
            // Otherwise server will fail to retrieve session's information to dispatch
            // media keys to.
            boolean accept = allowedCommands != null || request.isTrusted();
            ControllerInfoImpl impl = ControllerInfoImpl.from(request);
            boolean accept = allowedCommands != null || controllerInfo.isTrusted();
            ControllerInfoImpl impl = ControllerInfoImpl.from(controllerInfo);
            if (accept) {
                if (DEBUG) {
                    Log.d(TAG, "Accepting connection, request=" + request
                    Log.d(TAG, "Accepting connection, controllerInfo=" + controllerInfo
                            + " allowedCommands=" + allowedCommands);
                }
                synchronized (mLock) {
                    mControllers.put(impl.getId(), request);
                    mControllers.put(impl.getId(), controllerInfo);
                }
                if (allowedCommands == null) {
                    // For trusted apps, send non-null allowed commands to keep connection.
@@ -195,7 +195,7 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
                }
            } else {
                if (DEBUG) {
                    Log.d(TAG, "Rejecting connection, request=" + request);
                    Log.d(TAG, "Rejecting connection, controllerInfo=" + controllerInfo);
                }
                try {
                    caller.onDisconnected();
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ public class MediaSessionService2Impl implements MediaSessionService2Provider {

    public IBinder onBind_impl(Intent intent) {
        if (MediaSessionService2.SERVICE_INTERFACE.equals(intent.getAction())) {
            return SessionToken2Impl.from(mSession.getToken()).getSessionBinder().asBinder();
            return ((MediaSession2Impl) mSession.getProvider()).getSessionStub().asBinder();
        }
        return null;
    }
+6 −15
Original line number Diff line number Diff line
@@ -235,8 +235,7 @@ public class SessionToken2Impl implements SessionToken2Provider {
                + prime * (mUid
                + prime * (mPackageName.hashCode()
                + prime * (mId.hashCode()
                + prime * ((mServiceName != null ? mServiceName.hashCode() : 0)
                + prime * (mSessionBinder != null ? mSessionBinder.asBinder().hashCode() : 0)))));
                + prime * (mServiceName != null ? mServiceName.hashCode() : 0))));
    }

    @Override
@@ -245,19 +244,11 @@ public class SessionToken2Impl implements SessionToken2Provider {
            return false;
        }
        SessionToken2Impl other = from((SessionToken2) obj);
        if (mUid != other.mUid
                || !TextUtils.equals(mPackageName, other.mPackageName)
                || !TextUtils.equals(mServiceName, other.mServiceName)
                || !TextUtils.equals(mId, other.mId)
                || mType != other.mType) {
            return false;
        }
        if (mSessionBinder == other.mSessionBinder) {
            return true;
        } else if (mSessionBinder == null || other.mSessionBinder == null) {
            return false;
        }
        return mSessionBinder.asBinder().equals(other.mSessionBinder.asBinder());
        return mUid == other.mUid
                && TextUtils.equals(mPackageName, other.mPackageName)
                && TextUtils.equals(mServiceName, other.mServiceName)
                && TextUtils.equals(mId, other.mId)
                && mType == other.mType;
    }

    @Override
Loading