Add a common call when wrapping an app.
When an application is wrapped using setprop wrap.<application>, it
doesn't set the special zygote flag, or make the mallopt call. This
means that a wrapped application will behave differently, and not
be able to track zygote native allocations versus app native allocations.
This CL adds a nativePreApplicationInit call that is used after the
Zygote is forked, and when a wrapped application is called.
Bug: 62068500
Test: Booted sailfish system. Verified that the zygote has not called
Test: the new function. Verified the function is called when a wrapper
Test: is used. Verified the function is called when the Zygote forks
Test: a process.
Change-Id: I392e1b5429be77def63f7815b072d68e9408cc7f
diff --git a/core/java/com/android/internal/os/WrapperInit.java b/core/java/com/android/internal/os/WrapperInit.java
index b245678..608bc9f 100644
--- a/core/java/com/android/internal/os/WrapperInit.java
+++ b/core/java/com/android/internal/os/WrapperInit.java
@@ -163,6 +163,8 @@
argv = removedArgs;
}
+ // Perform the same initialization that would happen after the Zygote forks.
+ Zygote.nativePreApplicationInit();
RuntimeInit.applicationInit(targetSdkVersion, argv, classLoader);
}
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 5eca496..0106b81 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -121,6 +121,11 @@
int[] fdsToIgnore, String instructionSet, String appDataDir);
/**
+ * Called to do any initialization before starting an application.
+ */
+ native static void nativePreApplicationInit();
+
+ /**
* Special method to start the system server process. In addition to the
* common actions performed in forkAndSpecialize, the pid of the child
* process is recorded such that the death of the child process will cause