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

Commit 920804a0 authored by Shenqiu Zhang's avatar Shenqiu Zhang Committed by Android (Google) Code Review
Browse files

Merge "Fix the failure of transferring to unselected system route" into main

parents 87895445 9d4971dc
Loading
Loading
Loading
Loading
+22 −3
Original line number Original line Diff line number Diff line
@@ -1091,6 +1091,12 @@ public final class MediaRouter2 {
            @NonNull MediaRoute2Info route,
            @NonNull MediaRoute2Info route,
            long managerRequestId) {
            long managerRequestId) {


        if (Flags.fixTransferFromUserRouteToUnselectedSystemRoute() && route.isSystemRoute()) {
            notifyTransfer(controller, getSystemController());
            controller.release();
            return;
        }

        final int requestId = mNextRequestId.getAndIncrement();
        final int requestId = mNextRequestId.getAndIncrement();


        ControllerCreationRequest request =
        ControllerCreationRequest request =
@@ -2979,9 +2985,9 @@ public final class MediaRouter2 {
                return;
                return;
            }
            }


            // If this call is trying to transfer to a selected system route, we let them
            // If this call is trying to transfer from an existing system route to a selected system
            // through as a provider driven transfer in order to update the transfer reason and
            // route, we will handle the transfer through as a provider driven transfer in order to
            // initiator data.
            // update the transfer reason and initiator data.
            boolean isSystemRouteReselection =
            boolean isSystemRouteReselection =
                    Flags.enableBuiltInSpeakerRouteSuitabilityStatuses()
                    Flags.enableBuiltInSpeakerRouteSuitabilityStatuses()
                            && sessionInfo.isSystemSession()
                            && sessionInfo.isSystemSession()
@@ -2991,6 +2997,19 @@ public final class MediaRouter2 {
                    || isSystemRouteReselection) {
                    || isSystemRouteReselection) {
                transferToRoute(sessionInfo, route, mClientUser, mClientPackageName);
                transferToRoute(sessionInfo, route, mClientUser, mClientPackageName);
            } else {
            } else {
                RoutingSessionInfo systemSessionInfo = mSystemController.getRoutingSessionInfo();
                boolean isTransferFromUserRouteToUnselectedSystemRoute =
                        Flags.fixTransferFromUserRouteToUnselectedSystemRoute()
                                && !sessionInfo.isSystemSession()
                                && route.isSystemRoute()
                                && !systemSessionInfo.getSelectedRoutes().contains(route.getId());
                if (isTransferFromUserRouteToUnselectedSystemRoute) {
                    // During a transfer from a user route to an unselected system route, the system
                    // session must first be transferred to the target system route. Subsequently,
                    // the user route to system route transfer is processed by releasing the user
                    // route.
                    transferToRoute(systemSessionInfo, route, mClientUser, mClientPackageName);
                }
                requestCreateSession(sessionInfo, route);
                requestCreateSession(sessionInfo, route);
            }
            }
        }
        }
+11 −1
Original line number Original line Diff line number Diff line
@@ -276,3 +276,13 @@ flag {
    description: "Enables personal audio sharing in the output switcher."
    description: "Enables personal audio sharing in the output switcher."
    bug: "385672684"
    bug: "385672684"
}
}

flag {
    name: "fix_transfer_from_user_route_to_unselected_system_route"
    namespace: "media_better_together"
    description: "Fixes a bug causing the failure of transferring to a builtin speaker."
    bug: "398527989"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}