summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
authorjgu21 <jinghui.gu@intel.com>2014-09-10 06:55:07 -0400
committerAndreas Gampe <agampe@google.com>2014-09-28 15:35:59 -0700
commit208678718f9f8db3bc279c7d5bd1445af2831ae3 (patch)
treeb194dd88578c4c753c3359f67d3d13c11b52d40e /core/java/com
parent8120652bb1155d762d945c1a3bf1636b6825dbd2 (diff)
downloadframeworks_base-208678718f9f8db3bc279c7d5bd1445af2831ae3.zip
frameworks_base-208678718f9f8db3bc279c7d5bd1445af2831ae3.tar.gz
frameworks_base-208678718f9f8db3bc279c7d5bd1445af2831ae3.tar.bz2
Frameworks/base: Early init native bridge
Add the app directory to the arguments for starting a process. Add a check for NeedsNativeBridge and a call to PreInitializeBridge in the native fork code. (cherry picked from commit 2eacd06bfb82b33dfcbccafbcfc0bf1218484bb5) Bug: 17671501 Change-Id: I970db5b284b0c12e2d8a45df3950c1fff2927a4e
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/os/Zygote.java7
-rw-r--r--core/java/com/android/internal/os/ZygoteConnection.java19
2 files changed, 18 insertions, 8 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index c579a15..cca340c 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -79,19 +79,20 @@ public final class Zygote {
* (and replaced by /dev/null) after forking. An integer value
* of -1 in any entry in the array means "ignore this one".
* @param instructionSet null-ok the instruction set to use.
+ * @param appDataDir null-ok the data directory of the app.
*
* @return 0 if this is the child, pid of the child
* if this is the parent, or -1 on error.
*/
public static int forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags,
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
- String instructionSet) {
+ String instructionSet, String appDataDir) {
long startTime = SystemClock.elapsedRealtime();
VM_HOOKS.preFork();
checkTime(startTime, "Zygote.preFork");
int pid = nativeForkAndSpecialize(
uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
- instructionSet);
+ instructionSet, appDataDir);
checkTime(startTime, "Zygote.nativeForkAndSpecialize");
VM_HOOKS.postForkCommon();
checkTime(startTime, "Zygote.postForkCommon");
@@ -100,7 +101,7 @@ public final class Zygote {
native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int debugFlags,
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
- String instructionSet);
+ String instructionSet, String appDataDir);
/**
* Temporary hack: check time since start time and log if over a fixed threshold.
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
index fb50b25..2ef8a20 100644
--- a/core/java/com/android/internal/os/ZygoteConnection.java
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
@@ -93,7 +93,7 @@ class ZygoteConnection {
new InputStreamReader(socket.getInputStream()), 256);
mSocket.setSoTimeout(CONNECTION_TIMEOUT_MILLIS);
-
+
try {
peer = mSocket.getPeerCredentials();
} catch (IOException ex) {
@@ -245,7 +245,8 @@ class ZygoteConnection {
checkTime(startTime, "zygoteConnection.runOnce: preForkAndSpecialize");
pid = Zygote.forkAndSpecialize(parsedArgs.uid, parsedArgs.gid, parsedArgs.gids,
parsedArgs.debugFlags, rlimits, parsedArgs.mountExternal, parsedArgs.seInfo,
- parsedArgs.niceName, fdsToClose, parsedArgs.instructionSet);
+ parsedArgs.niceName, fdsToClose, parsedArgs.instructionSet,
+ parsedArgs.appDataDir);
checkTime(startTime, "zygoteConnection.runOnce: postForkAndSpecialize");
} catch (IOException ex) {
logAndPrintError(newStderr, "Exception creating pipe", ex);
@@ -404,6 +405,12 @@ class ZygoteConnection {
String instructionSet;
/**
+ * The app data directory. May be null, e.g., for the system server. Note that this might
+ * not be reliable in the case of process-sharing apps.
+ */
+ String appDataDir;
+
+ /**
* Constructs instance and parses args
* @param args zygote command-line args
* @throws IllegalArgumentException
@@ -560,6 +567,8 @@ class ZygoteConnection {
abiListQuery = true;
} else if (arg.startsWith("--instruction-set=")) {
instructionSet = arg.substring(arg.indexOf('=') + 1);
+ } else if (arg.startsWith("--app-data-dir=")) {
+ appDataDir = arg.substring(arg.indexOf('=') + 1);
} else {
break;
}
@@ -611,7 +620,7 @@ class ZygoteConnection {
}
// See bug 1092107: large argc can be used for a DOS attack
- if (argc > MAX_ZYGOTE_ARGC) {
+ if (argc > MAX_ZYGOTE_ARGC) {
throw new IOException("max arg count exceeded");
}
@@ -628,7 +637,7 @@ class ZygoteConnection {
}
/**
- * Applies zygote security policy per bugs #875058 and #1082165.
+ * Applies zygote security policy per bugs #875058 and #1082165.
* Based on the credentials of the process issuing a zygote command:
* <ol>
* <li> uid 0 (root) may specify any uid, gid, and setgroups() list
@@ -659,7 +668,7 @@ class ZygoteConnection {
/* In normal operation, SYSTEM_UID can only specify a restricted
* set of UIDs. In factory test mode, SYSTEM_UID may specify any uid.
*/
- uidRestricted
+ uidRestricted
= !(factoryTest.equals("1") || factoryTest.equals("2"));
if (uidRestricted