diff options
| author | 2023-09-12 17:41:17 +0000 | |
|---|---|---|
| committer | 2023-09-12 17:41:17 +0000 | |
| commit | 03e15bc43268da9d00a6d8939a70ed07186b83d2 (patch) | |
| tree | bc83b41cbc649188766e27d214d8dba8ae9befc4 | |
| parent | de446e71cc7b8145ce8bbbcaf215ee1c7c7dd37b (diff) | |
| parent | 22853f266b45079a56210ee3afd0ac8f8a683084 (diff) | |
Merge "Change naming in dispatchUpdates to reflect Bluetooth permissions" into main
| -rw-r--r-- | services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java index e53835548e12..4892c22449cb 100644 --- a/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +++ b/services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java @@ -2100,34 +2100,36 @@ class MediaRouter2ServiceImpl { if (!hasAddedOrModifiedRoutes && !hasRemovedRoutes) { return; } - List<RouterRecord> routerRecordsWithModifyAudioRoutingPermission = - getRouterRecords(true); - List<RouterRecord> routerRecordsWithoutModifyAudioRoutingPermission = - getRouterRecords(false); + List<RouterRecord> routerRecordsWithSystemRoutingPermission = + getRouterRecords(/* hasSystemRoutingPermission= */ true); + List<RouterRecord> routerRecordsWithoutSystemRoutingPermission = + getRouterRecords(/* hasSystemRoutingPermission= */ false); List<IMediaRouter2Manager> managers = getManagers(); // Managers receive all provider updates with all routes. notifyRoutesUpdatedToManagers( managers, new ArrayList<>(mLastNotifiedRoutesToPrivilegedRouters.values())); - // Routers with modify audio permission (usually system routers) receive all provider - // updates with all routes. + // Routers with system routing access (either via {@link MODIFY_AUDIO_ROUTING} or + // {@link BLUETOOTH_CONNECT} + {@link BLUETOOTH_SCAN}) receive all provider updates + // with all routes. notifyRoutesUpdatedToRouterRecords( - routerRecordsWithModifyAudioRoutingPermission, + routerRecordsWithSystemRoutingPermission, new ArrayList<>(mLastNotifiedRoutesToPrivilegedRouters.values())); if (!isSystemProvider) { // Regular routers receive updates from all non-system providers with all non-system // routes. notifyRoutesUpdatedToRouterRecords( - routerRecordsWithoutModifyAudioRoutingPermission, + routerRecordsWithoutSystemRoutingPermission, new ArrayList<>(mLastNotifiedRoutesToNonPrivilegedRouters.values())); } else if (hasAddedOrModifiedRoutes) { - // On system provider updates, regular routers receive the updated default route. - // This is the only system route they should receive. + // On system provider updates, routers without system routing access + // receive the updated default route. This is the only system route they should + // receive. mLastNotifiedRoutesToNonPrivilegedRouters.put(defaultRoute.getId(), defaultRoute); notifyRoutesUpdatedToRouterRecords( - routerRecordsWithoutModifyAudioRoutingPermission, + routerRecordsWithoutSystemRoutingPermission, new ArrayList<>(mLastNotifiedRoutesToNonPrivilegedRouters.values())); } } @@ -2533,7 +2535,7 @@ class MediaRouter2ServiceImpl { } } - private List<RouterRecord> getRouterRecords(boolean hasModifyAudioRoutingPermission) { + private List<RouterRecord> getRouterRecords(boolean hasSystemRoutingPermission) { MediaRouter2ServiceImpl service = mServiceRef.get(); List<RouterRecord> routerRecords = new ArrayList<>(); if (service == null) { @@ -2541,7 +2543,7 @@ class MediaRouter2ServiceImpl { } synchronized (service.mLock) { for (RouterRecord routerRecord : mUserRecord.mRouterRecords) { - if (hasModifyAudioRoutingPermission + if (hasSystemRoutingPermission == routerRecord.hasSystemRoutingPermission()) { routerRecords.add(routerRecord); } |