In addition to checking for GET_APP_OPS_STATS permission,

require running in the same process or being instrumented
to access stack trace collection API.

Test: atest android.app.appops.cts.RuntimeMesageCollectionTest
Bug: 175193187
Change-Id: I5bbaea48f4d4b59b0a3b276525291787fefcb9d5
This commit is contained in:
Stanislav Zholnin
2020-12-09 17:14:18 +00:00
parent 7810e62094
commit a01eaf571a

View File

@@ -6143,6 +6143,12 @@ public class AppOpsService extends IAppOpsService.Stub {
/** Pulls current AppOps access report and resamples package and app op to watch */
@Override
public @Nullable RuntimeAppOpAccessMessage collectRuntimeAppOpAccessMessage() {
ActivityManagerInternal ami = LocalServices.getService(ActivityManagerInternal.class);
boolean isCallerInstrumented = ami.isUidCurrentlyInstrumented(Binder.getCallingUid());
boolean isCallerSystem = Binder.getCallingPid() == Process.myPid();
if (!isCallerSystem && !isCallerInstrumented) {
return null;
}
mContext.enforcePermission(android.Manifest.permission.GET_APP_OPS_STATS,
Binder.getCallingPid(), Binder.getCallingUid(), null);
RuntimeAppOpAccessMessage result;