From 3a247363c42018fa6121a8a02bce07c6b418d0cb Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Thu, 4 Apr 2019 14:30:21 -0700 Subject: [PATCH] Enable am profiling for apps profileable by shell This change allows apps that are marked as profileable by shell to be profiled with am profile. Note that debuggable forces isProfileableByShell to true. Fixes: 118835065 Test: atest cts/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAmProfileTests.java Note, tested on user build Change-Id: I174115dd9a3635ca4df3600eec994d06739d6ff8 --- .../java/com/android/server/am/ActivityManagerService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 3b6b404170c50..e0550f535abc2 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -7892,8 +7892,9 @@ public class ActivityManagerService extends IActivityManager.Stub synchronized (this) { boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0")); if (!isDebuggable) { - if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) { - throw new SecurityException("Process not debuggable: " + app.packageName); + if (!app.isProfileableByShell()) { + throw new SecurityException("Process not debuggable, " + + "and not profileable by shell: " + app.packageName); } } mProfileData.setProfileApp(processName);