diff options
| author | 2023-08-02 16:03:50 -0700 | |
|---|---|---|
| committer | 2023-08-02 16:03:50 -0700 | |
| commit | 039aa7bfd0055008d3b9996bc158bddd008bf51e (patch) | |
| tree | 0108dbf2b24b9cbe706aabf06b2526df74c7267b | |
| parent | 35d5d62deb89ef8abee0b80b6a8c01ab9ee2ef21 (diff) | |
Fix problem of logd restarting.
If logd restarts, then the old logd connection is no longer valid.
In order to keep working, reset the connection when this situation is
detected.
Bug: 276934420
Test: Ran CtsGwpAsanTestCases then killed logd. Verified that
Test: running the test again displays the warning about the logd
Test: connection and all of the tests pass.
Change-Id: I375ee9a2df50b445e21ef847614644ffa2af1f36
| -rw-r--r-- | services/core/java/com/android/server/logcat/LogcatManagerService.java | 21 | 
1 files changed, 19 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/logcat/LogcatManagerService.java b/services/core/java/com/android/server/logcat/LogcatManagerService.java index 43732d473cf4..25c939ee16b4 100644 --- a/services/core/java/com/android/server/logcat/LogcatManagerService.java +++ b/services/core/java/com/android/server/logcat/LogcatManagerService.java @@ -27,6 +27,7 @@ import android.content.Context;  import android.content.Intent;  import android.content.pm.PackageManager;  import android.os.Build; +import android.os.DeadObjectException;  import android.os.Handler;  import android.os.ILogd;  import android.os.Looper; @@ -514,7 +515,15 @@ public final class LogcatManagerService extends SystemService {              Slog.d(TAG, "Approving log access: " + request);          }          try { -            getLogdService().approve(request.mUid, request.mGid, request.mPid, request.mFd); +            try { +                getLogdService().approve(request.mUid, request.mGid, request.mPid, request.mFd); +            } catch (DeadObjectException e) { +                // This can happen if logd restarts, so force getting a new connection +                // to logd and try once more. +                Slog.w(TAG, "Logd connection no longer valid while approving, trying once more."); +                mLogdService = null; +                getLogdService().approve(request.mUid, request.mGid, request.mPid, request.mFd); +            }              Integer activeCount = mActiveLogAccessCount.getOrDefault(client, 0);              mActiveLogAccessCount.put(client, activeCount + 1);          } catch (RemoteException e) { @@ -527,7 +536,15 @@ public final class LogcatManagerService extends SystemService {              Slog.d(TAG, "Declining log access: " + request);          }          try { -            getLogdService().decline(request.mUid, request.mGid, request.mPid, request.mFd); +            try { +                getLogdService().decline(request.mUid, request.mGid, request.mPid, request.mFd); +            } catch (DeadObjectException e) { +                // This can happen if logd restarts, so force getting a new connection +                // to logd and try once more. +                Slog.w(TAG, "Logd connection no longer valid while declining, trying once more."); +                mLogdService = null; +                getLogdService().decline(request.mUid, request.mGid, request.mPid, request.mFd); +            }          } catch (RemoteException e) {              Slog.e(TAG, "Fails to call remote functions", e);          }  |