summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-05-15 13:41:12 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-15 13:41:12 +0000
commit35b884f88e39c97056e71f329e73812a142103b5 (patch)
tree1285ffe30aa976f7bb8abde83214689e2049a4e2 /core/java/com
parent5d5f19a339bc4a8f10f75b51625d8d50ee0729e0 (diff)
parentbe3dc5754fd081f54a86df9894763c0da915eed3 (diff)
downloadframeworks_base-35b884f88e39c97056e71f329e73812a142103b5.zip
frameworks_base-35b884f88e39c97056e71f329e73812a142103b5.tar.gz
frameworks_base-35b884f88e39c97056e71f329e73812a142103b5.tar.bz2
am be3dc575: am 402120a2: Merge "Wait for secondary zygote before bringing up the system_server."
* commit 'be3dc5754fd081f54a86df9894763c0da915eed3': Wait for secondary zygote before bringing up the system_server.
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/os/ZygoteInit.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 3ea749e..5ce658b 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -23,6 +23,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.net.LocalServerSocket;
import android.opengl.EGL14;
+import android.os.Build;
import android.os.Debug;
import android.os.Process;
import android.os.SystemClock;
@@ -505,7 +506,7 @@ public class ZygoteInit {
/**
* Prepare the arguments and fork for the system server process.
*/
- private static boolean startSystemServer()
+ private static boolean startSystemServer(String abiList, String socketName)
throws MethodAndArgsCaller, RuntimeException {
long capabilities = posixCapabilitiesAsBits(
OsConstants.CAP_BLOCK_SUSPEND,
@@ -553,6 +554,10 @@ public class ZygoteInit {
/* For child process */
if (pid == 0) {
+ if (hasSecondZygote(abiList)) {
+ waitForSecondaryZygote(socketName);
+ }
+
handleSystemServerProcess(parsedArgs);
}
@@ -615,7 +620,7 @@ public class ZygoteInit {
Trace.setTracingEnabled(false);
if (startSystemServer) {
- startSystemServer();
+ startSystemServer(abiList, socketName);
}
Log.i(TAG, "Accepting command socket connections");
@@ -632,6 +637,36 @@ public class ZygoteInit {
}
/**
+ * Return {@code true} if this device configuration has another zygote.
+ *
+ * We determine this by comparing the device ABI list with this zygotes
+ * list. If this zygote supports all ABIs this device supports, there won't
+ * be another zygote.
+ */
+ private static boolean hasSecondZygote(String abiList) {
+ return !SystemProperties.get("ro.product.cpu.abilist").equals(abiList);
+ }
+
+ private static void waitForSecondaryZygote(String socketName) {
+ String otherZygoteName = Process.ZYGOTE_SOCKET.equals(socketName) ?
+ Process.SECONDARY_ZYGOTE_SOCKET : Process.ZYGOTE_SOCKET;
+ while (true) {
+ try {
+ final Process.ZygoteState zs = Process.ZygoteState.connect(otherZygoteName);
+ zs.close();
+ break;
+ } catch (IOException ioe) {
+ Log.w(TAG, "Got error connecting to zygote, retrying. msg= " + ioe.getMessage());
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+ }
+ }
+ }
+
+ /**
* Runs the zygote process's select loop. Accepts new connections as
* they happen, and reads commands from connections one spawn-request's
* worth at a time.