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

Commit c29a0598 authored by Santiago Seifert's avatar Santiago Seifert Committed by Android (Google) Code Review
Browse files

Merge "Simplify MediaRoute2ProviderServiceProxy#shouldBind" into main

parents 79b8a00c dfe107df
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -231,18 +231,21 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider
    }

    private boolean shouldBind() {
        if (mRunning) {
            boolean shouldBind =
                    mLastDiscoveryPreference != null
                            && !mLastDiscoveryPreference.getPreferredFeatures().isEmpty();
            if (mIsSelfScanOnlyProvider) {
                shouldBind &= mLastDiscoveryPreferenceIncludesThisPackage;
        if (!mRunning) {
            return false;
        }
            shouldBind |= mIsManagerScanning;
            shouldBind |= !getSessionInfos().isEmpty();
            return shouldBind;
        if (!getSessionInfos().isEmpty() || mIsManagerScanning) {
            // 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.
            return true;
        }
        return false;
        boolean anAppIsScanning =
                mLastDiscoveryPreference != null
                        && !mLastDiscoveryPreference.getPreferredFeatures().isEmpty();
        return anAppIsScanning
                && (mLastDiscoveryPreferenceIncludesThisPackage || !mIsSelfScanOnlyProvider);
    }

    private void bind() {