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

Commit f8441fc6 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Prevent autobinding ProviderWatcher abuses

With this change, the watcher will no longer bind immediately after
(re)starting the provider proxies. Instead, binding will happen
during the first scanning request after that.

Bug: b/263520343
Test: atest MediaRouter2HostSideTest
Change-Id: I752fe0fecaef1086fcee2e6fa61e2669dd7fefc5
parent 093fc5d6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -200,8 +200,10 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider
                Slog.d(TAG, this + ": Starting");
            }
            mRunning = true;
            if (!Flags.enablePreventionOfKeepAliveRouteProviders()) {
                updateBinding();
            }
        }
        if (rebindIfDisconnected && mActiveConnection == null && shouldBind()) {
            unbind();
            bind();
+3 −1
Original line number Diff line number Diff line
@@ -150,7 +150,9 @@ final class MediaRoute2ProviderWatcher {
                    mCallback.onAddProviderService(proxy);
                } else if (sourceIndex >= targetIndex) {
                    MediaRoute2ProviderServiceProxy proxy = mProxies.get(sourceIndex);
                    proxy.start(/* rebindIfDisconnected= */ true); // restart the proxy if needed
                    proxy.start(
                            /* rebindIfDisconnected= */
                                    !Flags.enablePreventionOfKeepAliveRouteProviders());
                    Collections.swap(mProxies, sourceIndex, targetIndex++);
                }
            }