diff options
| author | 2024-01-02 14:54:40 +0000 | |
|---|---|---|
| committer | 2024-01-03 17:07:28 +0000 | |
| commit | dfe107df94c8a558cb82fc66d12eab6d0ce4784a (patch) | |
| tree | 86b838c1d7842b0e8c793970573e055cff9c4370 | |
| parent | 7799b5d9caa79f46a8225c01651daada9b4477d9 (diff) | |
Simplify MediaRoute2ProviderServiceProxy#shouldBind
In preparation for changes in the conditions that would
introduce further nesting.
Bug: b/263520343
Test: presubmit. This is a non-functional change.
Change-Id: I1271c39e8bfd65836f6cff4a4216d5d293a0308f
| -rw-r--r-- | services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java b/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java index ae889d8255c6..21e7befc1b89 100644 --- a/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java +++ b/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java @@ -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; - } - shouldBind |= mIsManagerScanning; - shouldBind |= !getSessionInfos().isEmpty(); - return shouldBind; + if (!mRunning) { + return false; } - return false; + 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; + } + boolean anAppIsScanning = + mLastDiscoveryPreference != null + && !mLastDiscoveryPreference.getPreferredFeatures().isEmpty(); + return anAppIsScanning + && (mLastDiscoveryPreferenceIncludesThisPackage || !mIsSelfScanOnlyProvider); } private void bind() { |