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

Commit d26f18a7 authored by Iván Budnik's avatar Iván Budnik
Browse files

Simplify MediaRouter2 stub unregistering logic

The change deduplicates logic I missed in ag/25932085.

This is a non-functional change.

Bug: 205124386
Test: Presubmit.
Change-Id: I881470dd39cb7327cbcb91dc7d5463878cb99d52
parent 54debd28
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;
            }