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

Commit 77678aa0 authored by Santiago Seifert's avatar Santiago Seifert Committed by Android (Google) Code Review
Browse files

Merge "Clean up remote exceptions from router operations" into main

parents f629709b 886e6efc
Loading
Loading
Loading
Loading
+23 −22
Original line number Original line Diff line number Diff line
@@ -2197,7 +2197,7 @@ class MediaRouter2ServiceImpl {
                mRouter.notifyRouterRegistered(
                mRouter.notifyRouterRegistered(
                        getVisibleRoutes(currentRoutes), currentSystemSessionInfo);
                        getVisibleRoutes(currentRoutes), currentSystemSessionInfo);
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify router registered. Router probably died.", ex);
                logRemoteException("notifyRegistered", ex);
            }
            }
        }
        }


@@ -2212,7 +2212,7 @@ class MediaRouter2ServiceImpl {
            try {
            try {
                mRouter.notifyRoutesUpdated(getVisibleRoutes(routes));
                mRouter.notifyRoutesUpdated(getVisibleRoutes(routes));
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify routes updated. Router probably died.", ex);
                logRemoteException("notifyRoutesUpdated", ex);
            }
            }
        }
        }


@@ -2221,11 +2221,7 @@ class MediaRouter2ServiceImpl {
                mRouter.notifySessionCreated(
                mRouter.notifySessionCreated(
                        requestId, maybeClearTransferInitiatorIdentity(sessionInfo));
                        requestId, maybeClearTransferInitiatorIdentity(sessionInfo));
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                Slog.w(
                logRemoteException("notifySessionCreated", ex);
                        TAG,
                        "Failed to notify router of the session creation."
                                + " Router probably died.",
                        ex);
            }
            }
        }
        }


@@ -2238,11 +2234,7 @@ class MediaRouter2ServiceImpl {
            try {
            try {
                mRouter.notifySessionCreated(requestId, /* sessionInfo= */ null);
                mRouter.notifySessionCreated(requestId, /* sessionInfo= */ null);
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                Slog.w(
                logRemoteException("notifySessionCreationFailed", ex);
                        TAG,
                        "Failed to notify router of the session creation failure."
                                + " Router probably died.",
                        ex);
            }
            }
        }
        }


@@ -2253,10 +2245,7 @@ class MediaRouter2ServiceImpl {
            try {
            try {
                mRouter.notifySessionReleased(sessionInfo);
                mRouter.notifySessionReleased(sessionInfo);
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                Slog.w(
                logRemoteException("notifySessionReleased", ex);
                        TAG,
                        "Failed to notify router of the session release. Router probably died.",
                        ex);
            }
            }
        }
        }


@@ -2284,11 +2273,7 @@ class MediaRouter2ServiceImpl {
                }
                }
                mRouter.requestCreateSessionByManager(uniqueRequestId, oldSession, route);
                mRouter.requestCreateSessionByManager(uniqueRequestId, oldSession, route);
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                Slog.w(
                logRemoteException("requestCreateSessionByManager", ex);
                        TAG,
                        "getSessionHintsForCreatingSessionOnHandler: "
                                + "Failed to request. Router probably died.",
                        ex);
                managerRecord.notifyRequestFailed(
                managerRecord.notifyRequestFailed(
                        toOriginalRequestId(uniqueRequestId), REASON_UNKNOWN_ERROR);
                        toOriginalRequestId(uniqueRequestId), REASON_UNKNOWN_ERROR);
            }
            }
@@ -2303,7 +2288,7 @@ class MediaRouter2ServiceImpl {
            try {
            try {
                mRouter.notifySessionInfoChanged(maybeClearTransferInitiatorIdentity(sessionInfo));
                mRouter.notifySessionInfoChanged(maybeClearTransferInitiatorIdentity(sessionInfo));
            } catch (RemoteException ex) {
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify session info changed. Router probably died.", ex);
                logRemoteException("notifySessionInfoChanged", ex);
            }
            }
        }
        }


@@ -2362,6 +2347,22 @@ class MediaRouter2ServiceImpl {
            }
            }
            return false;
            return false;
        }
        }

        /** Logs a {@link RemoteException} occurred during the execution of {@code operation}. */
        private void logRemoteException(String operation, RemoteException exception) {
            String message =
                    TextUtils.formatSimple(
                            "%s failed for %s due to %s",
                            operation, getDebugString(), exception.toString());
            Slog.w(TAG, message);
        }

        /** Returns a human readable representation of this router record for logging purposes. */
        private String getDebugString() {
            return TextUtils.formatSimple(
                    "Router %s (id=%d,pid=%d,userId=%d,uid=%d)",
                    mPackageName, mRouterId, mPid, mUserRecord.mUserId, mUid);
        }
    }
    }


    final class ManagerRecord implements IBinder.DeathRecipient {
    final class ManagerRecord implements IBinder.DeathRecipient {