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

Commit 310ba607 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Remove duplicate check before transfer

Before this check, the transfer is checking for the existence of the
target route in the list of selected routes twice. This change is
preliminary work for allowing the selection of the selected system route
for populating the transfer reason.

Test: Non-functional refactor.
Flag: EXEMPT refactor
Bug: b/319645714
Change-Id: I36a87790df3ffc2be2ab0f1eafee6b3096e7d4a0
parent 731423a0
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() {