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

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

Merge "Clean up manager record logs for binder exceptions" into main

parents b0d339f5 18f2caa2
Loading
Loading
Loading
Loading
+24 −25
Original line number Diff line number Diff line
@@ -1112,19 +1112,12 @@ class MediaRouter2ServiceImpl {
                continue;
            }

            Log.w(
                    TAG,
                    TextUtils.formatSimple(
                            "Revoking access to manager record id: %d, package: %s, userId:"
                                    + " %d",
                            manager.mManagerId, manager.mOwnerPackageName, userRecord.mUserId));

            Slog.w(TAG, "Revoking access for " + manager.getDebugString());
            unregisterManagerLocked(manager.mManager, /* died */ false);

            try {
                manager.mManager.invalidateInstance();
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify manager= " + manager + " of permission revocation.");
                manager.logRemoteException("invalidateInstance", ex);
            }
        }
    }
@@ -2428,10 +2421,7 @@ class MediaRouter2ServiceImpl {
            try {
                mManager.notifyRequestFailed(requestId, reason);
            } catch (RemoteException ex) {
                Slog.w(
                        TAG,
                        "Failed to notify manager of the request failure. Manager probably died.",
                        ex);
                logRemoteException("notifyRequestFailed", ex);
            }
        }

@@ -2444,7 +2434,7 @@ class MediaRouter2ServiceImpl {
            try {
                mManager.notifyRoutesUpdated(routes);
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify routes. Manager probably died.", ex);
                logRemoteException("notifyRoutesUpdated", ex);
            }
        }

@@ -2457,10 +2447,7 @@ class MediaRouter2ServiceImpl {
            try {
                mManager.notifySessionUpdated(sessionInfo);
            } catch (RemoteException ex) {
                Slog.w(
                        TAG,
                        "notifySessionUpdatedToManagers: Failed to notify. Manager probably died.",
                        ex);
                logRemoteException("notifySessionUpdated", ex);
            }
        }

@@ -2473,13 +2460,18 @@ class MediaRouter2ServiceImpl {
            try {
                mManager.notifySessionReleased(sessionInfo);
            } catch (RemoteException ex) {
                Slog.w(
                        TAG,
                        "notifySessionReleasedToManagers: Failed to notify. Manager probably died.",
                        ex);
                logRemoteException("notifySessionReleased", ex);
            }
        }

        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);
        }

        private void updateScanningState(@ScanningState int scanningState) {
            if (mScanningState == scanningState) {
                return;
@@ -2492,9 +2484,16 @@ class MediaRouter2ServiceImpl {
                            UserHandler::updateDiscoveryPreferenceOnHandler, mUserRecord.mHandler));
        }

        @Override
        public String toString() {
            return "Manager " + mOwnerPackageName + " (pid " + mOwnerPid + ")";
        /** Returns a human readable representation of this manager record for logging purposes. */
        public String getDebugString() {
            return TextUtils.formatSimple(
                    "Manager %s (id=%d,pid=%d,userId=%d,uid=%d,targetPkg=%s)",
                    mOwnerPackageName,
                    mManagerId,
                    mOwnerPid,
                    mUserRecord.mUserId,
                    mOwnerUid,
                    mTargetPackageName);
        }
    }