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

Commit 1621a7c1 authored by Hyundo Moon's avatar Hyundo Moon Committed by Automerger Merge Worker
Browse files

Merge "MediaRouter2: Prevent printing same logs from different lines" into rvc-dev am: 6d8d91dc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11835420

Change-Id: Iae8badf73d2bfb6d03e2de122c0debb89bb64b3b
parents 12bb273d 6d8d91dc
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ public abstract class MediaRoute2ProviderService extends Service {
        String sessionId = sessionInfo.getId();
        synchronized (mSessionLock) {
            if (mSessionInfo.containsKey(sessionId)) {
                Log.w(TAG, "Ignoring duplicate session id.");
                Log.w(TAG, "notifySessionCreated: Ignoring duplicate session id.");
                return;
            }
            mSessionInfo.put(sessionInfo.getId(), sessionInfo);
@@ -274,7 +274,7 @@ public abstract class MediaRoute2ProviderService extends Service {
            if (mSessionInfo.containsKey(sessionId)) {
                mSessionInfo.put(sessionId, sessionInfo);
            } else {
                Log.w(TAG, "Ignoring unknown session info.");
                Log.w(TAG, "notifySessionUpdated: Ignoring unknown session info.");
                return;
            }

@@ -304,7 +304,7 @@ public abstract class MediaRoute2ProviderService extends Service {
            sessionInfo = mSessionInfo.remove(sessionId);

            if (sessionInfo == null) {
                Log.w(TAG, "Ignoring unknown session info.");
                Log.w(TAG, "notifySessionReleased: Ignoring unknown session info.");
                return;
            }

@@ -314,7 +314,7 @@ public abstract class MediaRoute2ProviderService extends Service {
            try {
                mRemoteCallback.notifySessionReleased(sessionInfo);
            } catch (RemoteException ex) {
                Log.w(TAG, "Failed to notify session info changed.");
                Log.w(TAG, "Failed to notify session released.", ex);
            }
        }
    }
@@ -485,7 +485,7 @@ public abstract class MediaRoute2ProviderService extends Service {
        try {
            mRemoteCallback.updateState(mProviderInfo);
        } catch (RemoteException ex) {
            Log.w(TAG, "Failed to send onProviderInfoUpdated");
            Log.w(TAG, "Failed to publish provider state.", ex);
        }
    }

+13 −12
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ public final class MediaRouter2 {
                try {
                    mMediaRouterService.setDiscoveryRequestWithRouter2(mStub, mDiscoveryPreference);
                } catch (RemoteException ex) {
                    Log.e(TAG, "registerRouteCallback: Unable to set discovery request.");
                    Log.e(TAG, "registerRouteCallback: Unable to set discovery request.", ex);
                }
            }
        }
@@ -214,7 +214,7 @@ public final class MediaRouter2 {

        if (!mRouteCallbackRecords.remove(
                new RouteCallbackRecord(null, routeCallback, null))) {
            Log.w(TAG, "Ignoring unknown callback");
            Log.w(TAG, "unregisterRouteCallback: Ignoring unknown callback");
            return;
        }

@@ -227,7 +227,7 @@ public final class MediaRouter2 {
                    mMediaRouterService.setDiscoveryRequestWithRouter2(
                            mStub, mDiscoveryPreference);
                } catch (RemoteException ex) {
                    Log.e(TAG, "unregisterRouteCallback: Unable to set discovery request.");
                    Log.e(TAG, "unregisterRouteCallback: Unable to set discovery request.", ex);
                }
            }
            if (mRouteCallbackRecords.isEmpty() && mNonSystemRoutingControllers.isEmpty()) {
@@ -500,7 +500,7 @@ public final class MediaRouter2 {
            try {
                mMediaRouterService.setRouteVolumeWithRouter2(stub, route, volume);
            } catch (RemoteException ex) {
                Log.e(TAG, "Unable to send control request.", ex);
                Log.e(TAG, "Unable to set route volume.", ex);
            }
        }
    }
@@ -788,7 +788,8 @@ public final class MediaRouter2 {
                mMediaRouterService.notifySessionHintsForCreatingSession(
                        stub, uniqueRequestId, route, controllerHints);
            } catch (RemoteException ex) {
                Log.e(TAG, "getSessionHintsOnHandler: Unable to request.", ex);
                Log.e(TAG, "onGetControllerHintsForCreatingSessionOnHandler: Unable to notify "
                        + " session hints for creating session.", ex);
            }
        }
    }
@@ -1120,7 +1121,7 @@ public final class MediaRouter2 {
            Objects.requireNonNull(route, "route must not be null");
            synchronized (mControllerLock) {
                if (mIsReleased) {
                    Log.w(TAG, "selectRoute() called on released controller. Ignoring.");
                    Log.w(TAG, "selectRoute: Called on released controller. Ignoring.");
                    return;
                }
            }
@@ -1169,7 +1170,7 @@ public final class MediaRouter2 {
            Objects.requireNonNull(route, "route must not be null");
            synchronized (mControllerLock) {
                if (mIsReleased) {
                    Log.w(TAG, "deselectRoute() called on released controller. Ignoring.");
                    Log.w(TAG, "deselectRoute: called on released controller. Ignoring.");
                    return;
                }
            }
@@ -1216,7 +1217,7 @@ public final class MediaRouter2 {
            Objects.requireNonNull(route, "route must not be null");
            synchronized (mControllerLock) {
                if (mIsReleased) {
                    Log.w(TAG, "transferToRoute() called on released controller. Ignoring.");
                    Log.w(TAG, "transferToRoute: Called on released controller. Ignoring.");
                    return;
                }

@@ -1254,17 +1255,17 @@ public final class MediaRouter2 {
         */
        public void setVolume(int volume) {
            if (getVolumeHandling() == MediaRoute2Info.PLAYBACK_VOLUME_FIXED) {
                Log.w(TAG, "setVolume: the routing session has fixed volume. Ignoring.");
                Log.w(TAG, "setVolume: The routing session has fixed volume. Ignoring.");
                return;
            }
            if (volume < 0 || volume > getVolumeMax()) {
                Log.w(TAG, "setVolume: the target volume is out of range. Ignoring");
                Log.w(TAG, "setVolume: The target volume is out of range. Ignoring");
                return;
            }

            synchronized (mControllerLock) {
                if (mIsReleased) {
                    Log.w(TAG, "setVolume is called on released controller. Ignoring.");
                    Log.w(TAG, "setVolume: Called on released controller. Ignoring.");
                    return;
                }
            }
@@ -1298,7 +1299,7 @@ public final class MediaRouter2 {
        boolean releaseInternal(boolean shouldReleaseSession, boolean shouldNotifyStop) {
            synchronized (mControllerLock) {
                if (mIsReleased) {
                    Log.w(TAG, "releaseInternal() called on released controller. Ignoring.");
                    Log.w(TAG, "releaseInternal: Called on released controller. Ignoring.");
                    return false;
                }
                mIsReleased = true;
+3 −3
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public final class MediaRouter2Manager {

        CallbackRecord callbackRecord = new CallbackRecord(executor, callback);
        if (!mCallbackRecords.addIfAbsent(callbackRecord)) {
            Log.w(TAG, "Ignoring to add the same callback twice.");
            Log.w(TAG, "Ignoring to register the same callback twice.");
            return;
        }
    }
@@ -384,7 +384,7 @@ public final class MediaRouter2Manager {
                int requestId = mNextRequestId.getAndIncrement();
                mMediaRouterService.setRouteVolumeWithManager(client, requestId, route, volume);
            } catch (RemoteException ex) {
                Log.e(TAG, "Unable to send control request.", ex);
                Log.e(TAG, "Unable to set route volume.", ex);
            }
        }
    }
@@ -414,7 +414,7 @@ public final class MediaRouter2Manager {
                mMediaRouterService.setSessionVolumeWithManager(
                        client, requestId, sessionInfo.getId(), volume);
            } catch (RemoteException ex) {
                Log.e(TAG, "Unable to send control request.", ex);
                Log.e(TAG, "Unable to set session volume.", ex);
            }
        }
    }
+26 −22
Original line number Diff line number Diff line
@@ -567,7 +567,8 @@ class MediaRouter2ServiceImpl {
            boolean hasModifyAudioRoutingPermission) {
        final IBinder binder = router.asBinder();
        if (mAllRouterRecords.get(binder) != null) {
            Slog.w(TAG, "Same router already exists. packageName=" + packageName);
            Slog.w(TAG, "registerRouter2Locked: Same router already exists. packageName="
                    + packageName);
            return;
        }

@@ -665,8 +666,7 @@ class MediaRouter2ServiceImpl {
        final RouterRecord routerRecord = mAllRouterRecords.get(binder);

        if (routerRecord == null) {
            Slog.w(TAG, "requestCreateSessionWithRouter2ByManagerRequestLocked: "
                    + "Ignoring unknown router.");
            Slog.w(TAG, "notifySessionHintsForCreatingSessionLocked: Ignoring unknown router.");
            return;
        }

@@ -789,7 +789,8 @@ class MediaRouter2ServiceImpl {
        ManagerRecord managerRecord = mAllManagerRecords.get(binder);

        if (managerRecord != null) {
            Slog.w(TAG, "Same manager already exists. packageName=" + packageName);
            Slog.w(TAG, "registerManagerLocked: Same manager already exists. packageName="
                    + packageName);
            return;
        }

@@ -854,7 +855,8 @@ class MediaRouter2ServiceImpl {

        RouterRecord routerRecord = managerRecord.mUserRecord.findRouterRecordLocked(packageName);
        if (routerRecord == null) {
            Slog.w(TAG, "Ignoring session creation for unknown router.");
            Slog.w(TAG, "requestCreateSessionWithManagerLocked: Ignoring session creation for "
                    + "unknown router.");
            return;
        }

@@ -1231,7 +1233,8 @@ class MediaRouter2ServiceImpl {

                for (MediaRoute2Info route : currentRoutes) {
                    if (!route.isValid()) {
                        Slog.w(TAG, "Ignoring invalid route : " + route);
                        Slog.w(TAG, "onProviderStateChangedOnHandler: Ignoring invalid route : "
                                + route);
                        continue;
                    }
                    MediaRoute2Info prevRoute = prevInfo.getRoute(route.getOriginalId());
@@ -1309,8 +1312,8 @@ class MediaRouter2ServiceImpl {
            try {
                routerRecord.mRouter.getSessionHintsForCreatingSession(uniqueRequestId, route);
            } catch (RemoteException ex) {
                Slog.w(TAG, "requestGetSessionHintsOnHandler: "
                        + "Failed to request. Router probably died.");
                Slog.w(TAG, "getSessionHintsForCreatingSessionOnHandler: "
                        + "Failed to request. Router probably died.", ex);
                mSessionCreationRequests.remove(request);
                notifyRequestFailedToManager(managerRecord.mManager,
                        toOriginalRequestId(uniqueRequestId), REASON_UNKNOWN_ERROR);
@@ -1323,8 +1326,8 @@ class MediaRouter2ServiceImpl {

            final MediaRoute2Provider provider = findProvider(route.getProviderId());
            if (provider == null) {
                Slog.w(TAG, "Ignoring session creation request since no provider found for"
                        + " given route=" + route);
                Slog.w(TAG, "requestCreateSessionWithRouter2OnHandler: Ignoring session "
                        + "creation request since no provider found for given route=" + route);
                notifySessionCreationFailedToRouter(routerRecord,
                        toOriginalRequestId(uniqueRequestId));
                return;
@@ -1349,22 +1352,21 @@ class MediaRouter2ServiceImpl {
                }
            }
            if (matchingRequest == null) {
                Slog.w(TAG, "requestCreateSessionWithKnownRequestOnHandler: "
                        + "Ignoring an unknown request.");
                Slog.w(TAG, "requestCreateSessionWithManagerOnHandler: "
                        + "Ignoring an unknown session creation request.");
                return;
            }

            if (!TextUtils.equals(matchingRequest.mRoute.getId(), route.getId())) {
                Slog.w(TAG, "requestCreateSessionWithKnownRequestOnHandler: "
                Slog.w(TAG, "requestCreateSessionWithManagerOnHandler: "
                        + "The given route is different from the requested route.");
                return;
            }

            final MediaRoute2Provider provider = findProvider(route.getProviderId());
            if (provider == null) {
                Slog.w(TAG, "Ignoring session creation request since no provider found for"
                        + " given route=" + route);

                Slog.w(TAG, "requestCreateSessionWithManagerOnHandler: Ignoring session "
                        + "creation request since no provider found for given route=" + route);
                mSessionCreationRequests.remove(matchingRequest);
                notifyRequestFailedToManager(matchingRequest.mRequestedManagerRecord.mManager,
                        toOriginalRequestId(uniqueRequestId), REASON_ROUTE_NOT_AVAILABLE);
@@ -1468,7 +1470,7 @@ class MediaRouter2ServiceImpl {
                int volume) {
            final MediaRoute2Provider provider = findProvider(route.getProviderId());
            if (provider == null) {
                Slog.w(TAG, "setRouteVolume: couldn't find provider for route=" + route);
                Slog.w(TAG, "setRouteVolumeOnHandler: Couldn't find provider for route=" + route);
                return;
            }
            provider.setRouteVolume(uniqueRequestId, route.getOriginalId(), volume);
@@ -1478,8 +1480,8 @@ class MediaRouter2ServiceImpl {
                @NonNull String uniqueSessionId, int volume) {
            final MediaRoute2Provider provider = findProvider(getProviderId(uniqueSessionId));
            if (provider == null) {
                Slog.w(TAG, "setSessionVolume: couldn't find provider for session "
                        + "id=" + uniqueSessionId);
                Slog.w(TAG, "setSessionVolumeOnHandler: Couldn't find provider for session id="
                        + uniqueSessionId);
                return;
            }
            provider.setSessionVolume(uniqueRequestId, getOriginalId(uniqueSessionId), volume);
@@ -1599,7 +1601,8 @@ class MediaRouter2ServiceImpl {

            RouterRecord routerRecord = mSessionToRouterMap.get(sessionInfo.getId());
            if (routerRecord == null) {
                Slog.w(TAG, "No matching router found for session=" + sessionInfo);
                Slog.w(TAG, "onSessionInfoChangedOnHandler: No matching router found for session="
                        + sessionInfo);
                return;
            }
            notifySessionInfoChangedToRouter(routerRecord, sessionInfo);
@@ -1612,7 +1615,8 @@ class MediaRouter2ServiceImpl {

            RouterRecord routerRecord = mSessionToRouterMap.get(sessionInfo.getId());
            if (routerRecord == null) {
                Slog.w(TAG, "No matching router found for session=" + sessionInfo);
                Slog.w(TAG, "onSessionReleasedOnHandler: No matching router found for session="
                        + sessionInfo);
                return;
            }
            notifySessionReleasedToRouter(routerRecord, sessionInfo);
@@ -1789,7 +1793,7 @@ class MediaRouter2ServiceImpl {
                    currentRoutes.addAll(systemProviderInfo.getRoutes());
                } else {
                    // This shouldn't happen.
                    Slog.w(TAG, "notifyRoutesToRouter: System route provider not found.");
                    Slog.wtf(TAG, "System route provider not found.");
                }
                currentSystemSessionInfo = mSystemProvider.getSessionInfos().get(0);
            } else {