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

Commit 8860603b authored by Iván Budnik's avatar Iván Budnik Committed by Android (Google) Code Review
Browse files

Merge "Simplify MediaRouter2 stub unregistering logic" into main

parents e21c60f2 d26f18a7
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -3109,9 +3109,8 @@ public final class MediaRouter2 {
                                mStub, mDiscoveryPreference);
                    }

                    if (mRouteCallbackRecords.isEmpty() && mNonSystemRoutingControllers.isEmpty()) {
                        unregisterRouterStubLocked();
                    }
                    unregisterRouterStubIfNeededLocked();

                } catch (RemoteException ex) {
                    Log.e(TAG, "unregisterRouteCallback: Unable to set discovery request.", ex);
                }
@@ -3319,13 +3318,12 @@ public final class MediaRouter2 {
                            obtainMessage(MediaRouter2::notifyStop, MediaRouter2.this, controller));
                }

                if (mRouteCallbackRecords.isEmpty() && mNonSystemRoutingControllers.isEmpty()) {
                try {
                        unregisterRouterStubLocked();
                    unregisterRouterStubIfNeededLocked();
                } catch (RemoteException ex) {
                    ex.rethrowFromSystemServer();
                }
                }

            }
        }

@@ -3339,8 +3337,10 @@ public final class MediaRouter2 {
        }

        @GuardedBy("mLock")
        private void unregisterRouterStubLocked() throws RemoteException {
            if (mStub != null) {
        private void unregisterRouterStubIfNeededLocked() throws RemoteException {
            if (mStub != null
                    && mRouteCallbackRecords.isEmpty()
                    && mNonSystemRoutingControllers.isEmpty()) {
                mMediaRouterService.unregisterRouter2(mStub);
                mStub = null;
            }