From 6448d2470e96a4e9950109ecf074b7bef6a0f1f1 Mon Sep 17 00:00:00 2001 From: Wenhao Wang Date: Wed, 16 Feb 2022 11:46:42 -0800 Subject: [PATCH] LogcatManagerService: Allow instrumentation tests This CL exempts the instrumentation tests from per-use user consent check. Bug: 193708292 Bug: 217482811 Bug: 217495147 Test: atest PlatformRuleTests -- --abi x86_64 Test: atest FrameworksServicesTests -- --abi x86_64 Ignore-AOSP-First: pending fix for logcat privacy issue Change-Id: I223ffd913918103c6d86e84f79a27bc7cda16dc0 --- .../server/logcat/LogcatManagerService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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);