diff --git a/module/src/main/cpp/jni_native_method.cpp b/module/src/main/cpp/jni_native_method.cpp index 38c669e1..0d48c149 100644 --- a/module/src/main/cpp/jni_native_method.cpp +++ b/module/src/main/cpp/jni_native_method.cpp @@ -318,6 +318,30 @@ jint nativeForkAndSpecialize_p( return res; } +jint nativeForkAndSpecialize_q_alternative( + JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, + jobjectArray rlimits, jint mount_external, jstring se_info, jstring se_name, + jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote, + jstring instructionSet, jstring appDataDir, jboolean isTopApp) { + + jobjectArray pkgDataInfoList = nullptr; + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; + jboolean bindMountAppStorageDirs = JNI_FALSE; + + nativeForkAndSpecialize_pre(env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, + se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote, + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); + + jint res = ((nativeForkAndSpecialize_p_t *) _nativeForkAndSpecialize)( + env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, se_name, + fdsToClose, fdsToIgnore, is_child_zygote, instructionSet, appDataDir, isTopApp); + + nativeForkAndSpecialize_post(env, clazz, uid, res); + return res; +} + jint nativeForkAndSpecialize_r( JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jstring se_name, @@ -516,6 +540,29 @@ void nativeSpecializeAppProcess_q( nativeSpecializeAppProcess_post(env, clazz); } +void nativeSpecializeAppProcess_q_alternative( + JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtimeFlags, + jobjectArray rlimits, jint mountExternal, jstring seInfo, jstring niceName, + jboolean startChildZygote, jstring instructionSet, jstring appDataDir, + jboolean isTopApp) { + + jobjectArray pkgDataInfoList = nullptr; + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; + jboolean bindMountAppStorageDirs = JNI_FALSE; + + nativeSpecializeAppProcess_pre( + env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, + startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList, + whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs); + + ((nativeSpecializeAppProcess_q_t *) _nativeSpecializeAppProcess)( + env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, + startChildZygote, instructionSet, appDataDir, isTopApp); + + nativeSpecializeAppProcess_post(env, clazz); +} + void nativeSpecializeAppProcess_r( JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtimeFlags, jobjectArray rlimits, jint mountExternal, jstring seInfo, jstring niceName, diff --git a/module/src/main/cpp/jni_native_method.h b/module/src/main/cpp/jni_native_method.h index 4d220e46..4fbc530c 100644 --- a/module/src/main/cpp/jni_native_method.h +++ b/module/src/main/cpp/jni_native_method.h @@ -45,6 +45,18 @@ jint nativeForkAndSpecialize_p( jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote, jstring instructionSet, jstring appDataDir); +const static char *nativeForkAndSpecialize_q_alternative_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z)I"; + +using nativeForkAndSpecialize_q_alternative_t = jint( + JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring, + jintArray, jintArray, jboolean, jstring, jstring, jboolean); + +jint nativeForkAndSpecialize_q_alternative( + JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, + jobjectArray rlimits, jint mount_external, jstring se_info, jstring se_name, + jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote, + jstring instructionSet, jstring appDataDir, jboolean isTopApp); + const static char *nativeForkAndSpecialize_r_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;[Ljava/lang/String;ZZ)I"; using nativeForkAndSpecialize_r_t = jint( @@ -180,6 +192,18 @@ void nativeSpecializeAppProcess_r_dp3( jboolean startChildZygote, jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList, jboolean bindMountAppStorageDirs); +const static char *nativeSpecializeAppProcess_q_alternative_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z)V"; + +using nativeSpecializeAppProcess_q_alternative_t = void( + JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring, + jboolean, jstring, jstring, jboolean); + +void nativeSpecializeAppProcess_q_alternative( + JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtimeFlags, + jobjectArray rlimits, jint mountExternal, jstring seInfo, jstring niceName, + jboolean startChildZygote, jstring instructionSet, jstring appDataDir, + jboolean isTopApp); + const static char *nativeSpecializeAppProcess_sig_samsung_q = "(II[II[[IILjava/lang/String;IILjava/lang/String;ZLjava/lang/String;Ljava/lang/String;)V"; using nativeSpecializeAppProcess_samsung_t = void( diff --git a/module/src/main/cpp/main.cpp b/module/src/main/cpp/main.cpp index 4cc9a05f..b164a77c 100644 --- a/module/src/main/cpp/main.cpp +++ b/module/src/main/cpp/main.cpp @@ -175,6 +175,9 @@ static JNINativeMethod *onRegisterZygote(JNIEnv *env, const char *className, else if (strcmp(nativeForkAndSpecialize_r_dp2_sig, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_r_dp2; + else if (strcmp(nativeForkAndSpecialize_q_alternative_sig, method.signature) == 0) + newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_q_alternative; + else if (strcmp(nativeForkAndSpecialize_samsung_p_sig, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_samsung_p; else if (strcmp(nativeForkAndSpecialize_samsung_o_sig, method.signature) == 0) @@ -201,6 +204,8 @@ static JNINativeMethod *onRegisterZygote(JNIEnv *env, const char *className, newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_r; else if (strcmp(nativeSpecializeAppProcess_q_sig, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_q; + else if (strcmp(nativeSpecializeAppProcess_q_alternative_sig, method.signature) == 0) + newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_q_alternative; else if (strcmp(nativeSpecializeAppProcess_sig_samsung_q, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_samsung_q;