summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christopher Ferris <cferris@google.com> 2023-08-10 22:36:10 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-08-10 22:36:10 +0000
commitd7ab422d1b3c979bbd31a1a5215ff49528f8d4c0 (patch)
treea7ec7eca4b8505f04c0a6ddddbaca9e6a76aaa8a
parentc358f7fb23988bff588cbdb3f8cdb284a5867f6a (diff)
parent9f007535c579ca20e8bfe5009053fa6cd5f1241e (diff)
Merge "Fix problem of logd restarting." into udc-qpr-dev
-rw-r--r--services/core/java/com/android/server/logcat/LogcatManagerService.java21
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 497ed0346d97..fee54f5ed337 100644
--- a/services/core/java/com/android/server/logcat/LogcatManagerService.java
+++ b/services/core/java/com/android/server/logcat/LogcatManagerService.java
@@ -28,6 +28,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;
@@ -518,7 +519,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) {
@@ -531,7 +540,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);
}