diff options
| author | 2024-02-09 14:02:48 +0000 | |
|---|---|---|
| committer | 2024-02-09 14:02:48 +0000 | |
| commit | bfad288aa326ade1c59a60594495ffb36501033d (patch) | |
| tree | 7fab829fade184bea8410365184047ff846baa32 | |
| parent | 39744f2639ceee23781263318e0e37b5890bef3c (diff) | |
| parent | 093fc5d6387446fe2fab2b910f54fd3a670c4c38 (diff) | |
Merge "Refactor out rebindIfDisconnected" into main
| -rw-r--r-- | services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java | 15 | ||||
| -rw-r--r-- | services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java | 5 |
2 files changed, 7 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java b/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java index 0ae60360883d..cec7a79cdada 100644 --- a/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java +++ b/services/core/java/com/android/server/media/MediaRoute2ProviderServiceProxy.java @@ -194,7 +194,7 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider && mComponentName.getClassName().equals(className); } - public void start() { + public void start(boolean rebindIfDisconnected) { if (!mRunning) { if (DEBUG) { Slog.d(TAG, this + ": Starting"); @@ -202,6 +202,10 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider mRunning = true; updateBinding(); } + if (rebindIfDisconnected && mActiveConnection == null && shouldBind()) { + unbind(); + bind(); + } } public void stop() { @@ -214,15 +218,6 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider } } - public void rebindIfDisconnected() { - //TODO: When we are connecting to the service, calling this will unbind and bind again. - // We'd better not unbind if we are connecting. - if (mActiveConnection == null && shouldBind()) { - unbind(); - bind(); - } - } - private void updateBinding() { if (shouldBind()) { bind(); diff --git a/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java b/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java index 3d717a871cf1..233a3ab4a4ea 100644 --- a/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java +++ b/services/core/java/com/android/server/media/MediaRoute2ProviderWatcher.java @@ -145,13 +145,12 @@ final class MediaRoute2ProviderWatcher { new ComponentName(serviceInfo.packageName, serviceInfo.name), isSelfScanOnlyProvider, mUserId); - proxy.start(); + proxy.start(/* rebindIfDisconnected= */ false); mProxies.add(targetIndex++, proxy); mCallback.onAddProviderService(proxy); } else if (sourceIndex >= targetIndex) { MediaRoute2ProviderServiceProxy proxy = mProxies.get(sourceIndex); - proxy.start(); // restart the proxy if needed - proxy.rebindIfDisconnected(); + proxy.start(/* rebindIfDisconnected= */ true); // restart the proxy if needed Collections.swap(mProxies, sourceIndex, targetIndex++); } } |