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
This commit is contained in:
Wenhao Wang
2022-02-16 11:46:42 -08:00
parent 38e0ef45e2
commit 6448d2470e

View File

@@ -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);