Libcore: Flag to fail thread creation
Add methods to set and reset a flag to mark when the zygote is not
allowed to create threads.
Bug: 27248115
Bug: 28149511
(cherry picked from commit c99008805238d8a292fc27e2efbf3fc83ae74634)
Change-Id: I1dc3620d9e7d0054c672b993d89459fc4b353dfc
diff --git a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
index 48f1fe2..b29b895 100644
--- a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
+++ b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
@@ -28,6 +28,18 @@
private long token;
/**
+ * Called by the zygote when starting up. It marks the point when any thread
+ * start should be an error, as only internal daemon threads are allowed there.
+ */
+ public static native void startZygoteNoThreadCreation();
+
+ /**
+ * Called by the zygote when startup is finished. It marks the point when it is
+ * conceivable that threads would be started again, e.g., restarting daemons.
+ */
+ public static native void stopZygoteNoThreadCreation();
+
+ /**
* Called by the zygote prior to every fork. Each call to {@code preFork}
* is followed by a matching call to {@link #postForkChild(int, String)} on the child
* process and {@link #postForkCommon()} on both the parent and the child