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

Commit 3559a202 authored by Santiago Seifert's avatar Santiago Seifert Committed by Android (Google) Code Review
Browse files

Merge "Remove duplicate check before transfer" into main

parents ef5f494d 310ba607
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -2064,24 +2064,31 @@ public final class MediaRouter2 {
        }

        /**
         * Transfers to a given route for the remote session. The given route must be included in
         * {@link RoutingSessionInfo#getTransferableRoutes()}.
         * Attempts a transfer to a {@link RoutingSessionInfo#getTransferableRoutes() transferable
         * route}.
         *
         * <p>Transferring to a transferable route does not require the app to transfer the playback
         * state from one route to the other. The route provider completely manages the transfer. An
         * example of provider-managed transfers are the switches between the system's routes, like
         * the built-in speakers and a BT headset.
         *
         * @return True if the transfer is handled by this controller, or false if a new controller
         *     should be created instead.
         * @see RoutingSessionInfo#getSelectedRoutes()
         * @see RoutingSessionInfo#getTransferableRoutes()
         * @see ControllerCallback#onControllerUpdated
         */
        void transferToRoute(@NonNull MediaRoute2Info route) {
        boolean tryTransferWithinProvider(@NonNull MediaRoute2Info route) {
            Objects.requireNonNull(route, "route must not be null");
            synchronized (mControllerLock) {
                if (isReleased()) {
                    Log.w(TAG, "transferToRoute: Called on released controller. Ignoring.");
                    return;
                    return true;
                }

                if (!mSessionInfo.getTransferableRoutes().contains(route.getId())) {
                    Log.w(TAG, "Ignoring transferring to a non-transferable route=" + route);
                    return;
                    return false;
                }
            }

@@ -2096,6 +2103,7 @@ public final class MediaRouter2 {
                    Log.e(TAG, "Unable to transfer to route for session.", ex);
                }
            }
            return true;
        }

        /**
@@ -3587,14 +3595,7 @@ public final class MediaRouter2 {
            }

            RoutingController controller = getCurrentController();
            if (controller
                    .getRoutingSessionInfo()
                    .getTransferableRoutes()
                    .contains(route.getId())) {
                controller.transferToRoute(route);
                return;
            }

            if (!controller.tryTransferWithinProvider(route)) {
                requestCreateController(
                        controller,
                        route,
@@ -3602,6 +3603,7 @@ public final class MediaRouter2 {
                        Process.myUserHandle(),
                        mContext.getPackageName());
            }
        }

        @Override
        public void stop() {