MediaRouter2: Prevent printing same logs from different lines

This CL prevents duplicate logs which are printed from
different code locations, which makes investigating future bugs easier.
Also modifies some logs to make them clearer.

Bug: 157873330
Test: Builds successfully
Change-Id: I90ca0e6b46e2b796d069dbecef4a8000cca85b4b
This commit is contained in:
Hyundo Moon
2020-06-11 17:37:01 +09:00
parent 8a9020bb58
commit 369be956e0
4 changed files with 47 additions and 42 deletions

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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);
}
}
}