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

Commit e93c4bc9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Extract method and remove duplicate code in ProxyMediaRouter2Impl" into main

parents 4c1c98b6 70b0a426
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -3129,15 +3129,8 @@ public final class MediaRouter2 {

        private void onTransferred(
                @NonNull RoutingSessionInfo oldSession, @NonNull RoutingSessionInfo newSession) {
            if (!oldSession.isSystemSession()
                    && !TextUtils.equals(
                            getClientPackageName(), oldSession.getClientPackageName())) {
                return;
            }

            if (!newSession.isSystemSession()
                    && !TextUtils.equals(
                            getClientPackageName(), newSession.getClientPackageName())) {
            if (!isSessionRelatedToTargetPackageName(oldSession)
                    || !isSessionRelatedToTargetPackageName(newSession)) {
                return;
            }

@@ -3164,16 +3157,14 @@ public final class MediaRouter2 {

        private void onTransferFailed(
                @NonNull RoutingSessionInfo session, @NonNull MediaRoute2Info route) {
            if (!session.isSystemSession()
                    && !TextUtils.equals(getClientPackageName(), session.getClientPackageName())) {
            if (!isSessionRelatedToTargetPackageName(session)) {
                return;
            }
            notifyTransferFailure(route);
        }

        private void onSessionUpdated(@NonNull RoutingSessionInfo session) {
            if (!session.isSystemSession()
                    && !TextUtils.equals(getClientPackageName(), session.getClientPackageName())) {
            if (!isSessionRelatedToTargetPackageName(session)) {
                return;
            }

@@ -3188,6 +3179,15 @@ public final class MediaRouter2 {
            notifyControllerUpdated(controller);
        }

        /**
         * Returns {@code true} if the session is a system session or if its client package name
         * matches the proxy router's target package name.
         */
        private boolean isSessionRelatedToTargetPackageName(@NonNull RoutingSessionInfo session) {
            return session.isSystemSession()
                    || TextUtils.equals(getClientPackageName(), session.getClientPackageName());
        }

        private void onSessionCreatedOnHandler(
                int requestId, @NonNull RoutingSessionInfo sessionInfo) {
            MediaRouter2Manager.TransferRequest matchingRequest = null;