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

Commit 945a81b5 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Create ManagerRecord#notifySessionReleased

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: I00352a3974b6f60cbf0e75b6196375a53a7c2ed9
parent 6dd198b5
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -2448,6 +2448,22 @@ class MediaRouter2ServiceImpl {
            }
        }

        /**
         * Notifies the corresponding manager that the given session has been released.
         *
         * @param sessionInfo The released session info.
         */
        public void notifySessionReleased(RoutingSessionInfo sessionInfo) {
            try {
                mManager.notifySessionReleased(sessionInfo);
            } catch (RemoteException ex) {
                Slog.w(
                        TAG,
                        "notifySessionReleasedToManagers: Failed to notify. Manager probably died.",
                        ex);
            }
        }

        private void updateScanningState(@ScanningState int scanningState) {
            if (mScanningState == scanningState) {
                return;
@@ -3110,8 +3126,10 @@ class MediaRouter2ServiceImpl {

        private void onSessionReleasedOnHandler(@NonNull MediaRoute2Provider provider,
                @NonNull RoutingSessionInfo sessionInfo) {
            List<IMediaRouter2Manager> managers = getManagers();
            notifySessionReleasedToManagers(managers, sessionInfo);
            List<ManagerRecord> managers = getManagerRecords();
            for (ManagerRecord manager : managers) {
                manager.notifySessionReleased(sessionInfo);
            }

            RouterRecord routerRecord = mSessionToRouterMap.get(sessionInfo.getId());
            if (routerRecord == null) {
@@ -3316,19 +3334,6 @@ class MediaRouter2ServiceImpl {
            }
        }

        private void notifySessionReleasedToManagers(
                @NonNull List<IMediaRouter2Manager> managers,
                @NonNull RoutingSessionInfo sessionInfo) {
            for (IMediaRouter2Manager manager : managers) {
                try {
                    manager.notifySessionReleased(sessionInfo);
                } catch (RemoteException ex) {
                    Slog.w(TAG, "notifySessionReleasedToManagers: "
                            + "Failed to notify. Manager probably died.", ex);
                }
            }
        }

        private void notifyDiscoveryPreferenceChangedToManager(@NonNull RouterRecord routerRecord,
                @NonNull IMediaRouter2Manager manager) {
            try {