diff --git a/services/core/java/com/android/server/logcat/LogcatManagerService.java b/services/core/java/com/android/server/logcat/LogcatManagerService.java index 34614d50c0286..490e00e70f26d 100644 --- a/services/core/java/com/android/server/logcat/LogcatManagerService.java +++ b/services/core/java/com/android/server/logcat/LogcatManagerService.java @@ -329,6 +329,20 @@ public final class LogcatManagerService extends SystemService { if (mStart) { + ActivityManagerInternal ami = LocalServices.getService( + ActivityManagerInternal.class); + boolean isCallerInstrumented = ami.isUidCurrentlyInstrumented(mUid); + + // The instrumented apks only run for testing, so we don't check user permission. + if (isCallerInstrumented) { + try { + getLogdService().approve(mUid, mGid, mPid, mFd); + } catch (RemoteException e) { + e.printStackTrace(); + } + return; + } + // TODO Temporarily approve all the requests to unblock testing failures. try { getLogdService().approve(mUid, mGid, mPid, mFd);