Loading media/java/android/media/flags/media_better_together.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -186,16 +186,6 @@ flag { bug: "263520343" } flag { name: "enable_prevention_of_manager_scans_when_no_apps_scan" namespace: "media_solutions" description: "Prevents waking up route providers when no apps are scanning, even if SysUI or Settings are scanning." bug: "319604673" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "enable_privileged_routing_for_media_routing_control" is_exported: true Loading services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java +13 −15 Original line number Diff line number Diff line Loading @@ -78,7 +78,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { private Connection mActiveConnection; private boolean mConnectionReady; private boolean mIsManagerScanning; private RouteDiscoveryPreference mLastDiscoveryPreference = null; private boolean mLastDiscoveryPreferenceIncludesThisPackage = false; Loading Loading @@ -119,13 +118,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { mHandler = new Handler(looper); } public void setManagerScanning(boolean managerScanning) { if (mIsManagerScanning != managerScanning) { mIsManagerScanning = managerScanning; updateBinding(); } } @Override public void requestCreateSession( long requestId, Loading Loading @@ -328,16 +320,23 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { } } /** * Returns true if we should bind to the corresponding provider. * * <p>The reasons to bind are: * * <ul> * <li>There's an active scan and this provider supports system media routing. * <li>There's an active routing session against this provider. * <li>There's a non-empty {@link RouteDiscoveryPreference#getPreferredFeatures()} that's * relevant to this provider (that is, this provider is public, or the app that owns this * provider is one of the apps populating the active discovery preference). * </ul> */ private boolean shouldBind() { if (!mRunning) { return false; } // We bind if any manager is scanning (regardless of whether an app is scanning) to give // the opportunity for providers to publish routing sessions that were established // directly between the app and the provider (typically via AndroidX MediaRouter). See // b/176774510#comment20 for more information. boolean bindDueToManagerScan = mIsManagerScanning && !Flags.enablePreventionOfManagerScansWhenNoAppsScan(); // We also bind if this provider supports system media routing, because even if an app // doesn't have any registered discovery preference, we should still be able to route their // system media. Loading @@ -353,7 +352,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { } if (!getSessionInfos().isEmpty() || bindDueToOngoingSystemMediaRoutingSessions || bindDueToManagerScan || bindDueToSystemMediaRoutingSupport) { return true; } Loading services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +2 −15 Original line number Diff line number Diff line Loading @@ -3963,8 +3963,6 @@ class MediaRouter2ServiceImpl { activeRouterRecords = getIndividuallyActiveRouters(service, allRouterRecords); } updateManagerScanningForProviders(areManagersScanning); Set<String> activelyScanningPackages = new HashSet<>(); RouteDiscoveryPreference newPreference = buildCompositeDiscoveryPreference( Loading Loading @@ -4038,10 +4036,8 @@ class MediaRouter2ServiceImpl { preferredFeatures.addAll(preference.getPreferredFeatures()); boolean isRouterRecordActivelyScanning = Flags.enablePreventionOfManagerScansWhenNoAppsScan() ? (activeRouterRecord.isActivelyScanning() || shouldForceActiveScan) && !preference.getPreferredFeatures().isEmpty() : activeRouterRecord.isActivelyScanning(); (activeRouterRecord.isActivelyScanning() || shouldForceActiveScan) && !preference.getPreferredFeatures().isEmpty(); if (isRouterRecordActivelyScanning) { activeScan = true; Loading @@ -4053,15 +4049,6 @@ class MediaRouter2ServiceImpl { .build(); } private void updateManagerScanningForProviders(boolean isManagerScanning) { for (MediaRoute2Provider provider : mRouteProviders) { if (provider instanceof MediaRoute2ProviderServiceProxy) { ((MediaRoute2ProviderServiceProxy) provider) .setManagerScanning(isManagerScanning); } } } @NonNull private static List<RouterRecord> getIndividuallyActiveRouters( MediaRouter2ServiceImpl service, List<RouterRecord> allRouterRecords) { Loading Loading
media/java/android/media/flags/media_better_together.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -186,16 +186,6 @@ flag { bug: "263520343" } flag { name: "enable_prevention_of_manager_scans_when_no_apps_scan" namespace: "media_solutions" description: "Prevents waking up route providers when no apps are scanning, even if SysUI or Settings are scanning." bug: "319604673" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "enable_privileged_routing_for_media_routing_control" is_exported: true Loading
services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java +13 −15 Original line number Diff line number Diff line Loading @@ -78,7 +78,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { private Connection mActiveConnection; private boolean mConnectionReady; private boolean mIsManagerScanning; private RouteDiscoveryPreference mLastDiscoveryPreference = null; private boolean mLastDiscoveryPreferenceIncludesThisPackage = false; Loading Loading @@ -119,13 +118,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { mHandler = new Handler(looper); } public void setManagerScanning(boolean managerScanning) { if (mIsManagerScanning != managerScanning) { mIsManagerScanning = managerScanning; updateBinding(); } } @Override public void requestCreateSession( long requestId, Loading Loading @@ -328,16 +320,23 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { } } /** * Returns true if we should bind to the corresponding provider. * * <p>The reasons to bind are: * * <ul> * <li>There's an active scan and this provider supports system media routing. * <li>There's an active routing session against this provider. * <li>There's a non-empty {@link RouteDiscoveryPreference#getPreferredFeatures()} that's * relevant to this provider (that is, this provider is public, or the app that owns this * provider is one of the apps populating the active discovery preference). * </ul> */ private boolean shouldBind() { if (!mRunning) { return false; } // We bind if any manager is scanning (regardless of whether an app is scanning) to give // the opportunity for providers to publish routing sessions that were established // directly between the app and the provider (typically via AndroidX MediaRouter). See // b/176774510#comment20 for more information. boolean bindDueToManagerScan = mIsManagerScanning && !Flags.enablePreventionOfManagerScansWhenNoAppsScan(); // We also bind if this provider supports system media routing, because even if an app // doesn't have any registered discovery preference, we should still be able to route their // system media. Loading @@ -353,7 +352,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider { } if (!getSessionInfos().isEmpty() || bindDueToOngoingSystemMediaRoutingSessions || bindDueToManagerScan || bindDueToSystemMediaRoutingSupport) { return true; } Loading
services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +2 −15 Original line number Diff line number Diff line Loading @@ -3963,8 +3963,6 @@ class MediaRouter2ServiceImpl { activeRouterRecords = getIndividuallyActiveRouters(service, allRouterRecords); } updateManagerScanningForProviders(areManagersScanning); Set<String> activelyScanningPackages = new HashSet<>(); RouteDiscoveryPreference newPreference = buildCompositeDiscoveryPreference( Loading Loading @@ -4038,10 +4036,8 @@ class MediaRouter2ServiceImpl { preferredFeatures.addAll(preference.getPreferredFeatures()); boolean isRouterRecordActivelyScanning = Flags.enablePreventionOfManagerScansWhenNoAppsScan() ? (activeRouterRecord.isActivelyScanning() || shouldForceActiveScan) && !preference.getPreferredFeatures().isEmpty() : activeRouterRecord.isActivelyScanning(); (activeRouterRecord.isActivelyScanning() || shouldForceActiveScan) && !preference.getPreferredFeatures().isEmpty(); if (isRouterRecordActivelyScanning) { activeScan = true; Loading @@ -4053,15 +4049,6 @@ class MediaRouter2ServiceImpl { .build(); } private void updateManagerScanningForProviders(boolean isManagerScanning) { for (MediaRoute2Provider provider : mRouteProviders) { if (provider instanceof MediaRoute2ProviderServiceProxy) { ((MediaRoute2ProviderServiceProxy) provider) .setManagerScanning(isManagerScanning); } } } @NonNull private static List<RouterRecord> getIndividuallyActiveRouters( MediaRouter2ServiceImpl service, List<RouterRecord> allRouterRecords) { Loading