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

Commit 7423573c authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Create ManagerRecord#notifyRoutesUpdated

This change is part of a series of non-functional refactors to
encapsulate binder operations in the record that corresponds to the
target binder object. The objective is to improve the logging associated
with binder failures by adding information that's available in the
record. For example: Package names and ids.

Bug: 360129098
Test: atest CtsMediaBetterTogetherTestCases MediaRouter2HostSideTest
Flag: EXEMPT refactor
Change-Id: Iba0897590d0129ffb0eaf8e152713d582be1fd1f
parent 2acae06f
Loading
Loading
Loading
Loading
+17 −21
Original line number Diff line number Diff line
@@ -1653,9 +1653,11 @@ class MediaRouter2ServiceImpl {
                            manager));
        }

        List<MediaRoute2Info> routes =
                userRecord.mHandler.mLastNotifiedRoutesToPrivilegedRouters.values().stream()
                        .toList();
        userRecord.mHandler.sendMessage(
                obtainMessage(
                        UserHandler::notifyInitialRoutesToManager, userRecord.mHandler, manager));
                obtainMessage(ManagerRecord::notifyRoutesUpdated, managerRecord, routes));
    }

    @GuardedBy("mLock")
@@ -2433,6 +2435,19 @@ class MediaRouter2ServiceImpl {
            }
        }

        /**
         * Notifies the corresponding manager of the availability of the given routes.
         *
         * @param routes The routes available to the manager that corresponds to this record.
         */
        public void notifyRoutesUpdated(List<MediaRoute2Info> routes) {
            try {
                mManager.notifyRoutesUpdated(routes);
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify routes. Manager probably died.", ex);
            }
        }

        private void updateScanningState(@ScanningState int scanningState) {
            if (mScanningState == scanningState) {
                return;
@@ -3269,25 +3284,6 @@ class MediaRouter2ServiceImpl {
            }
        }

        /**
         * Notifies {@code manager} with all known routes. This only happens once after {@code
         * manager} is registered through {@link #registerManager(IMediaRouter2Manager, String)
         * registerManager()}.
         *
         * @param manager {@link IMediaRouter2Manager} to be notified.
         */
        private void notifyInitialRoutesToManager(@NonNull IMediaRouter2Manager manager) {
            if (mLastNotifiedRoutesToPrivilegedRouters.isEmpty()) {
                return;
            }
            try {
                manager.notifyRoutesUpdated(
                        new ArrayList<>(mLastNotifiedRoutesToPrivilegedRouters.values()));
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify all routes. Manager probably died.", ex);
            }
        }

        private void notifyRoutesUpdatedToManagers(
                @NonNull List<IMediaRouter2Manager> managers,
                @NonNull List<MediaRoute2Info> routes) {