diff options
| author | 2024-01-22 12:53:50 +0000 | |
|---|---|---|
| committer | 2024-01-22 12:53:50 +0000 | |
| commit | 2f6258bbbf92ace01c896732f70fcd7ed8ca701e (patch) | |
| tree | cea1bc82686e830c1d5f8305e01360cab2073706 | |
| parent | b82529c9e04432c6fa52a6eb687a1d52da3cfaa8 (diff) | |
| parent | 526804c7e6e3f20b1d0b9a8bdc1d68dc7c31d62f (diff) | |
Merge "Fix NPE in MR2ServiceImpl#checkArgumentsForSessionControl" into main
| -rw-r--r-- | services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java index 28a1c7ad0540..85a131579497 100644 --- a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +++ b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java @@ -2336,6 +2336,11 @@ class MediaRouter2ServiceImpl { mSystemProvider.getDefaultRoute()); } + private static String getPackageNameFromNullableRecord( + @Nullable RouterRecord routerRecord) { + return routerRecord != null ? routerRecord.mPackageName : "<null router record>"; + } + private static String toLoggingMessage( String source, String providerId, ArrayList<MediaRoute2Info> routes) { String routesString = @@ -2573,8 +2578,17 @@ class MediaRouter2ServiceImpl { RouterRecord matchingRecord = mSessionToRouterMap.get(uniqueSessionId); if (matchingRecord != routerRecord) { - Slog.w(TAG, "Ignoring " + description + " route from non-matching router. " - + "packageName=" + routerRecord.mPackageName + " route=" + route); + Slog.w( + TAG, + "Ignoring " + + description + + " route from non-matching router." + + " routerRecordPackageName=" + + getPackageNameFromNullableRecord(routerRecord) + + " matchingRecordPackageName=" + + getPackageNameFromNullableRecord(matchingRecord) + + " route=" + + route); return false; } @@ -2613,9 +2627,15 @@ class MediaRouter2ServiceImpl { @Nullable RouterRecord routerRecord, @NonNull String uniqueSessionId) { final RouterRecord matchingRecord = mSessionToRouterMap.get(uniqueSessionId); if (matchingRecord != routerRecord) { - Slog.w(TAG, "Ignoring releasing session from non-matching router. packageName=" - + (routerRecord == null ? null : routerRecord.mPackageName) - + " uniqueSessionId=" + uniqueSessionId); + Slog.w( + TAG, + "Ignoring releasing session from non-matching router." + + " routerRecordPackageName=" + + getPackageNameFromNullableRecord(routerRecord) + + " matchingRecordPackageName=" + + getPackageNameFromNullableRecord(matchingRecord) + + " uniqueSessionId=" + + uniqueSessionId); return; } |