diff options
4 files changed, 19 insertions, 6 deletions
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 8cd4273ea99c..9cd1a4246a58 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -399,7 +399,8 @@ public class Process { * <var>processClass</var> to start them. * * When invokeWith is not null, the process will be started as a fresh app - * and not a zygote fork. Note that this is only allowed for uid 0. + * and not a zygote fork. Note that this is only allowed for uid 0 or when + * debugFlags contains DEBUG_ENABLE_DEBUGGER. * * @param processClass The class to use as the process's main entry * point. diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java index cd8163ceccc2..5ac33a1768c2 100644 --- a/core/java/android/os/ZygoteProcess.java +++ b/core/java/android/os/ZygoteProcess.java @@ -171,7 +171,8 @@ public class ZygoteProcess { * <var>processClass</var> to start them. * * When invokeWith is not null, the process will be started as a fresh app - * and not a zygote fork. Note that this is only allowed for uid 0. + * and not a zygote fork. Note that this is only allowed for uid 0 or when + * debugFlags contains DEBUG_ENABLE_DEBUGGER. * * @param processClass The class to use as the process's main entry * point. diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index 66b294d4e46b..44c6e8557c2c 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -697,9 +697,11 @@ class ZygoteConnection { throws ZygoteSecurityException { int peerUid = peer.getUid(); - if (args.invokeWith != null && peerUid != 0) { - throw new ZygoteSecurityException("Peer is not permitted to specify " - + "an explicit invoke-with wrapper command"); + if (args.invokeWith != null && peerUid != 0 && + (args.debugFlags & Zygote.DEBUG_ENABLE_DEBUGGER) == 0) { + throw new ZygoteSecurityException("Peer is permitted to specify an" + + "explicit invoke-with wrapper command only for debuggable" + + "applications."); } } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index c2c7b72f5e02..9e7990d27328 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -3784,6 +3784,15 @@ public final class ActivityManagerService extends ActivityManagerNative mNativeDebuggingApp = null; } + String invokeWith = null; + if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { + // Debuggable apps may include a wrapper script with their library directory. + String wrapperFileName = app.info.nativeLibraryDir + "/wrap.sh"; + if (new File(wrapperFileName).exists()) { + invokeWith = "/system/bin/logwrapper " + wrapperFileName; + } + } + String requiredAbi = (abiOverride != null) ? abiOverride : app.info.primaryCpuAbi; if (requiredAbi == null) { requiredAbi = Build.SUPPORTED_ABIS[0]; @@ -3815,7 +3824,7 @@ public final class ActivityManagerService extends ActivityManagerNative startResult = Process.start(entryPoint, app.processName, uid, uid, gids, debugFlags, mountExternal, app.info.targetSdkVersion, app.info.seinfo, requiredAbi, instructionSet, - app.info.dataDir, null, entryPointArgs); + app.info.dataDir, invokeWith, entryPointArgs); } checkTime(startTime, "startProcess: returned from zygote!"); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); |