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

Commit 1c18753d authored by Christopher Ferris's avatar Christopher Ferris Committed by Automerger Merge Worker
Browse files

Merge "Fix problem of logd restarting." into main am: 5a3f2ab2

parents 0e64ba22 5a3f2ab2
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -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 {
            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 {
            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);
        }