From 8bc0868a12e59bc4c5662e6f844e13f381e0f200 Mon Sep 17 00:00:00 2001 From: Santiago Seifert Date: Wed, 19 Apr 2023 16:20:53 +0000 Subject: [PATCH] When logging route id, also log package name Makes it much easier to follow the logs: Saves looking at the dumpsys to map the id to an app. Also, the id can change if the app gets restarted, which means the dumpsys no longer contains the corresponding router id after the app restarts. Bug: 257039897 Test: adb logcat --buffer system | grep MR2ServiceImpl Change-Id: I4a77cc4617025fc06009e71c7d96caea9e101878 --- .../server/media/MediaRouter2ServiceImpl.java | 75 ++++++++++++------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java index aea5b1a44dfdd..5d9c19e300082 100644 --- a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +++ b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java @@ -759,7 +759,7 @@ class MediaRouter2ServiceImpl { userRecord.mHandler, routerRecord)); Slog.i(TAG, TextUtils.formatSimple( - "registerRouter2 | package: %s, uid: %d, pid: %d, router: %d", + "registerRouter2 | package: %s, uid: %d, pid: %d, router id: %d", packageName, uid, pid, routerRecord.mRouterId)); } @@ -771,10 +771,11 @@ class MediaRouter2ServiceImpl { return; } - Slog.i(TAG, TextUtils.formatSimple( - "unregisterRouter2 | package: %s, router: %d", - routerRecord.mPackageName, - routerRecord.mRouterId)); + Slog.i( + TAG, + TextUtils.formatSimple( + "unregisterRouter2 | package: %s, router id: %d", + routerRecord.mPackageName, routerRecord.mRouterId)); UserRecord userRecord = routerRecord.mUserRecord; userRecord.mRouterRecords.remove(routerRecord); @@ -801,9 +802,14 @@ class MediaRouter2ServiceImpl { return; } - Slog.i(TAG, TextUtils.formatSimple( - "setDiscoveryRequestWithRouter2 | router: %d, discovery request: %s", - routerRecord.mRouterId, discoveryRequest.toString())); + Slog.i( + TAG, + TextUtils.formatSimple( + "setDiscoveryRequestWithRouter2 | router: %s(id: %d), discovery request:" + + " %s", + routerRecord.mPackageName, + routerRecord.mRouterId, + discoveryRequest.toString())); routerRecord.mDiscoveryPreference = discoveryRequest; routerRecord.mUserRecord.mHandler.sendMessage( @@ -827,10 +833,12 @@ class MediaRouter2ServiceImpl { .collect(Collectors.joining(",")) : null; - Slog.i(TAG, TextUtils.formatSimple( - "setRouteListingPreference | router: %d, route listing preference: [%s]", - routerRecord.mRouterId, - routeListingAsString)); + Slog.i( + TAG, + TextUtils.formatSimple( + "setRouteListingPreference | router: %s(id: %d), route listing preference:" + + " [%s]", + routerRecord.mPackageName, routerRecord.mRouterId, routeListingAsString)); routerRecord.mUserRecord.mHandler.sendMessage( obtainMessage( @@ -846,9 +854,11 @@ class MediaRouter2ServiceImpl { RouterRecord routerRecord = mAllRouterRecords.get(binder); if (routerRecord != null) { - Slog.i(TAG, TextUtils.formatSimple( - "setRouteVolumeWithRouter2 | router: %d, volume: %d", - routerRecord.mRouterId, volume)); + Slog.i( + TAG, + TextUtils.formatSimple( + "setRouteVolumeWithRouter2 | router: %s(id: %d), volume: %d", + routerRecord.mPackageName, routerRecord.mRouterId, volume)); routerRecord.mUserRecord.mHandler.sendMessage( obtainMessage(UserHandler::setRouteVolumeOnHandler, @@ -930,9 +940,11 @@ class MediaRouter2ServiceImpl { return; } - Slog.i(TAG, TextUtils.formatSimple( - "selectRouteWithRouter2 | router: %d, route: %s", - routerRecord.mRouterId, route.getId())); + Slog.i( + TAG, + TextUtils.formatSimple( + "selectRouteWithRouter2 | router: %s(id: %d), route: %s", + routerRecord.mPackageName, routerRecord.mRouterId, route.getId())); routerRecord.mUserRecord.mHandler.sendMessage( obtainMessage(UserHandler::selectRouteOnHandler, @@ -949,9 +961,11 @@ class MediaRouter2ServiceImpl { return; } - Slog.i(TAG, TextUtils.formatSimple( - "deselectRouteWithRouter2 | router: %d, route: %s", - routerRecord.mRouterId, route.getId())); + Slog.i( + TAG, + TextUtils.formatSimple( + "deselectRouteWithRouter2 | router: %s(id: %d), route: %s", + routerRecord.mPackageName, routerRecord.mRouterId, route.getId())); routerRecord.mUserRecord.mHandler.sendMessage( obtainMessage(UserHandler::deselectRouteOnHandler, @@ -968,9 +982,11 @@ class MediaRouter2ServiceImpl { return; } - Slog.i(TAG, TextUtils.formatSimple( - "transferToRouteWithRouter2 | router: %d, route: %s", - routerRecord.mRouterId, route.getId())); + Slog.i( + TAG, + TextUtils.formatSimple( + "transferToRouteWithRouter2 | router: %s(id: %d), route: %s", + routerRecord.mPackageName, routerRecord.mRouterId, route.getId())); String defaultRouteId = routerRecord.mUserRecord.mHandler.mSystemProvider.getDefaultRoute().getId(); @@ -1000,8 +1016,11 @@ class MediaRouter2ServiceImpl { Slog.i( TAG, TextUtils.formatSimple( - "setSessionVolumeWithRouter2 | router: %d, session: %s, volume: %d", - routerRecord.mRouterId, uniqueSessionId, volume)); + "setSessionVolumeWithRouter2 | router: %s(id: %d), session: %s, volume: %d", + routerRecord.mPackageName, + routerRecord.mRouterId, + uniqueSessionId, + volume)); routerRecord.mUserRecord.mHandler.sendMessage( obtainMessage(UserHandler::setSessionVolumeOnHandler, @@ -1021,8 +1040,8 @@ class MediaRouter2ServiceImpl { Slog.i( TAG, TextUtils.formatSimple( - "releaseSessionWithRouter2 | router: %d, session: %s", - routerRecord.mRouterId, uniqueSessionId)); + "releaseSessionWithRouter2 | router: %s(id: %d), session: %s", + routerRecord.mPackageName, routerRecord.mRouterId, uniqueSessionId)); routerRecord.mUserRecord.mHandler.sendMessage( obtainMessage(UserHandler::releaseSessionOnHandler,