summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2016-12-16 19:24:12 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-12-16 19:24:13 +0000
commit733d007279018036b36ddd1df66d5db0dd10b24c (patch)
treeda9db38dcbc4d88668adc416b587566d2f1058c9
parentc1536f0d105b2526f4cc083fa14154e934f7c4dc (diff)
parent0ca16fa58454b1685afcf8cf49c4b67b59221349 (diff)
Merge changes Ia4bec085,I59095f2a
* changes: Enable logwrapper functionality on user builds Zygote: Add invoke-with to zygote protocol
-rw-r--r--core/java/android/os/Process.java11
-rw-r--r--core/java/android/os/ZygoteProcess.java14
-rw-r--r--core/java/com/android/internal/os/ZygoteConnection.java8
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java13
4 files changed, 38 insertions, 8 deletions
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index 4eee8541f3bb..9cd1a4246a58 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -398,6 +398,10 @@ public class Process {
* make easily identifyable processes even if you are using the same base
* <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 or when
+ * debugFlags contains DEBUG_ENABLE_DEBUGGER.
+ *
* @param processClass The class to use as the process's main entry
* point.
* @param niceName A more readable name to use for the process.
@@ -410,6 +414,7 @@ public class Process {
* @param abi non-null the ABI this app should be started with.
* @param instructionSet null-ok the instruction set to use.
* @param appDataDir null-ok the data directory of the app.
+ * @param invokeWith null-ok the command to invoke with.
* @param zygoteArgs Additional arguments to supply to the zygote process.
*
* @return An object that describes the result of the attempt to start the process.
@@ -426,10 +431,11 @@ public class Process {
String abi,
String instructionSet,
String appDataDir,
+ String invokeWith,
String[] zygoteArgs) {
return zygoteProcess.start(processClass, niceName, uid, gid, gids,
debugFlags, mountExternal, targetSdkVersion, seInfo,
- abi, instructionSet, appDataDir, zygoteArgs);
+ abi, instructionSet, appDataDir, invokeWith, zygoteArgs);
}
/** @hide */
@@ -442,10 +448,11 @@ public class Process {
String abi,
String instructionSet,
String appDataDir,
+ String invokeWith,
String[] zygoteArgs) {
return WebViewZygote.getProcess().start(processClass, niceName, uid, gid, gids,
debugFlags, mountExternal, targetSdkVersion, seInfo,
- abi, instructionSet, appDataDir, zygoteArgs);
+ abi, instructionSet, appDataDir, invokeWith, zygoteArgs);
}
/**
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java
index c45fe5a61852..5ac33a1768c2 100644
--- a/core/java/android/os/ZygoteProcess.java
+++ b/core/java/android/os/ZygoteProcess.java
@@ -170,6 +170,10 @@ public class ZygoteProcess {
* make easily identifyable processes even if you are using the same base
* <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 or when
+ * debugFlags contains DEBUG_ENABLE_DEBUGGER.
+ *
* @param processClass The class to use as the process's main entry
* point.
* @param niceName A more readable name to use for the process.
@@ -182,6 +186,7 @@ public class ZygoteProcess {
* @param abi non-null the ABI this app should be started with.
* @param instructionSet null-ok the instruction set to use.
* @param appDataDir null-ok the data directory of the app.
+ * @param invokeWith null-ok the command to invoke with.
* @param zygoteArgs Additional arguments to supply to the zygote process.
*
* @return An object that describes the result of the attempt to start the process.
@@ -196,11 +201,12 @@ public class ZygoteProcess {
String abi,
String instructionSet,
String appDataDir,
+ String invokeWith,
String[] zygoteArgs) {
try {
return startViaZygote(processClass, niceName, uid, gid, gids,
debugFlags, mountExternal, targetSdkVersion, seInfo,
- abi, instructionSet, appDataDir, zygoteArgs);
+ abi, instructionSet, appDataDir, invokeWith, zygoteArgs);
} catch (ZygoteStartFailedEx ex) {
Log.e(LOG_TAG,
"Starting VM process through Zygote failed");
@@ -330,6 +336,7 @@ public class ZygoteProcess {
String abi,
String instructionSet,
String appDataDir,
+ String invokeWith,
String[] extraArgs)
throws ZygoteStartFailedEx {
ArrayList<String> argsForZygote = new ArrayList<String>();
@@ -407,6 +414,11 @@ public class ZygoteProcess {
argsForZygote.add("--app-data-dir=" + appDataDir);
}
+ if (invokeWith != null) {
+ argsForZygote.add("--invoke-with");
+ argsForZygote.add(invokeWith);
+ }
+
argsForZygote.add(processClass);
if (extraArgs != null) {
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 fa54a6117ae3..5b02c7916354 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3783,6 +3783,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];
@@ -3809,12 +3818,12 @@ public final class ActivityManagerService extends ActivityManagerNative
startResult = Process.startWebView(entryPoint,
app.processName, uid, uid, gids, debugFlags, mountExternal,
app.info.targetSdkVersion, app.info.seinfo, requiredAbi, instructionSet,
- app.info.dataDir, entryPointArgs);
+ app.info.dataDir, null, entryPointArgs);
} else {
startResult = Process.start(entryPoint,
app.processName, uid, uid, gids, debugFlags, mountExternal,
app.info.targetSdkVersion, app.info.seinfo, requiredAbi, instructionSet,
- app.info.dataDir, entryPointArgs);
+ app.info.dataDir, invokeWith, entryPointArgs);
}
checkTime(startTime, "startProcess: returned from zygote!");
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);