Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62d60d74 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Clean up enable_prevention_of_manager_scans_when_no_apps_scan

Test: Build platform and relevant tests
Flag: EXEMPT flag cleanup
Bug: b/409605944
Change-Id: I44df2fda06d60216cbc24e016620978b19bdf069
parent 1418b9e4
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -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
+13 −15
Original line number Diff line number Diff line
@@ -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;

@@ -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,
@@ -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.
@@ -353,7 +352,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider {
        }
        if (!getSessionInfos().isEmpty()
                || bindDueToOngoingSystemMediaRoutingSessions
                || bindDueToManagerScan
                || bindDueToSystemMediaRoutingSupport) {
            return true;
        }
+2 −15
Original line number Diff line number Diff line
@@ -3899,8 +3899,6 @@ class MediaRouter2ServiceImpl {
                activeRouterRecords = getIndividuallyActiveRouters(service, allRouterRecords);
            }

            updateManagerScanningForProviders(areManagersScanning);

            Set<String> activelyScanningPackages = new HashSet<>();
            RouteDiscoveryPreference newPreference =
                    buildCompositeDiscoveryPreference(
@@ -3974,10 +3972,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;
@@ -3989,15 +3985,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) {