From 5fb1beda4ee9ea8e73de4b90d03d3ef32fef2891 Mon Sep 17 00:00:00 2001 From: RikkaW Date: Fri, 8 May 2020 23:38:25 +0800 Subject: [PATCH] support Android R DP4 --- module/build.gradle | 6 +- module/src/main/cpp/jni_native_method.cpp | 137 +++++++++++++++++----- module/src/main/cpp/jni_native_method.h | 43 +++++-- module/src/main/cpp/main.cpp | 6 + module/src/main/cpp/module.h | 10 ++ 5 files changed, 163 insertions(+), 39 deletions(-) diff --git a/module/build.gradle b/module/build.gradle index 49bd428e..361b31ff 100644 --- a/module/build.gradle +++ b/module/build.gradle @@ -5,12 +5,12 @@ import java.security.MessageDigest apply plugin: 'com.android.library' -def apiVersion = 6 +def apiVersion = 7 def moduleProp = [ id : "riru-core", name : "Riru (Riru - Core)", - version : "v21.1", - versionCode: "34", + version : "v21.2", + versionCode: "35", author : "Rikka", description: "Inject zygote process by replace libmemtrack.so, provide interface to other Riru modules." ] diff --git a/module/src/main/cpp/jni_native_method.cpp b/module/src/main/cpp/jni_native_method.cpp index a46a7892..38c669e1 100644 --- a/module/src/main/cpp/jni_native_method.cpp +++ b/module/src/main/cpp/jni_native_method.cpp @@ -65,7 +65,7 @@ static void nativeForkAndSpecialize_pre( 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, - jboolean &bindMountAppStorageDirs) { + jobjectArray &whitelistedDataInfoList, jboolean &bindMountAppDataDirs, jboolean &bindMountAppStorageDirs) { nativeForkAndSpecialize_calls_count++; @@ -79,7 +79,13 @@ static void nativeForkAndSpecialize_pre( if (!module->shouldSkipUid && shouldSkipUid(uid)) continue; - if (module->apiVersion >= 6) { + if (module->apiVersion >= 7) { + ((nativeForkAndSpecialize_pre_v7_t *) module->forkAndSpecializePre)( + 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); + } else if (module->apiVersion == 6) { ((nativeForkAndSpecialize_pre_v6_t *) module->forkAndSpecializePre)( env, clazz, &uid, &gid, &gids, &runtime_flags, &rlimits, &mount_external, &se_info, &se_name, &fdsToClose, &fdsToIgnore, &is_child_zygote, @@ -148,7 +154,8 @@ static void nativeSpecializeAppProcess_pre( 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, jboolean &bindMountAppStorageDirs) { + jboolean &isTopApp, jobjectArray &pkgDataInfoList, jobjectArray &whitelistedDataInfoList, + jboolean &bindMountAppDataDirs, jboolean &bindMountAppStorageDirs) { nativeSpecializeAppProcess_calls_count++; @@ -156,7 +163,12 @@ static void nativeSpecializeAppProcess_pre( if (!module->specializeAppProcessPre) continue; - if (module->apiVersion >= 6) { + if (module->apiVersion >= 7) { + ((nativeSpecializeAppProcess_pre_v7_t *) module->specializeAppProcessPre)( + env, clazz, &uid, &gid, &gids, &runtimeFlags, &rlimits, &mountExternal, &seInfo, + &niceName, &startChildZygote, &instructionSet, &appDataDir, &isTopApp, + &pkgDataInfoList, &whitelistedDataInfoList, &bindMountAppDataDirs, &bindMountAppStorageDirs); + } else if (module->apiVersion >= 6) { ((nativeSpecializeAppProcess_pre_v6_t *) module->specializeAppProcessPre)( env, clazz, &uid, &gid, &gids, &runtimeFlags, &rlimits, &mountExternal, &seInfo, &niceName, &startChildZygote, &instructionSet, &appDataDir, &isTopApp, @@ -239,12 +251,14 @@ jint nativeForkAndSpecialize_marshmallow( jboolean is_child_zygote = JNI_FALSE; jboolean isTopApp = JNI_FALSE; jobjectArray pkgDataInfoList = nullptr; + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; jboolean bindMountAppStorageDirs = JNI_FALSE; nativeForkAndSpecialize_pre(env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote, - instructionSet, appDataDir, isTopApp, pkgDataInfoList, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_marshmallow_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, se_name, @@ -262,12 +276,14 @@ jint nativeForkAndSpecialize_oreo( jboolean is_child_zygote = JNI_FALSE; jboolean isTopApp = JNI_FALSE; jobjectArray pkgDataInfoList = nullptr; + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; jboolean bindMountAppStorageDirs = JNI_FALSE; nativeForkAndSpecialize_pre(env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote, - instructionSet, appDataDir, isTopApp, pkgDataInfoList, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_oreo_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, se_name, @@ -285,12 +301,14 @@ jint nativeForkAndSpecialize_p( jboolean isTopApp = JNI_FALSE; 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, - bindMountAppStorageDirs); + 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, @@ -305,14 +323,38 @@ jint nativeForkAndSpecialize_r( 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, - jboolean bindMountAppStorageDirs) { + jobjectArray whitelistedDataInfoList, jboolean bindMountAppDataDirs, jboolean bindMountAppStorageDirs) { 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, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_r_t *) _nativeForkAndSpecialize)( + 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); + + nativeForkAndSpecialize_post(env, clazz, uid, res); + return res; +} + +jint nativeForkAndSpecialize_r_dp3( + 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, + jboolean bindMountAppStorageDirs) { + + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = 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_r_dp3_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList, bindMountAppStorageDirs); @@ -327,12 +369,14 @@ jint nativeForkAndSpecialize_r_dp2( jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote, jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList) { + 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, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_r_dp2_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, se_name, @@ -350,12 +394,14 @@ jint nativeForkAndSpecialize_samsung_p( jboolean isTopApp = JNI_FALSE; 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, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_samsung_p_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, category, @@ -375,12 +421,14 @@ jint nativeForkAndSpecialize_samsung_o( jboolean is_child_zygote = JNI_FALSE; jboolean isTopApp = JNI_FALSE; jobjectArray pkgDataInfoList = nullptr; + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; jboolean bindMountAppStorageDirs = JNI_FALSE; nativeForkAndSpecialize_pre(env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote, - instructionSet, appDataDir, isTopApp, pkgDataInfoList, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_samsung_o_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, category, @@ -400,12 +448,14 @@ jint nativeForkAndSpecialize_samsung_n( jboolean is_child_zygote = JNI_FALSE; jboolean isTopApp = JNI_FALSE; jobjectArray pkgDataInfoList = nullptr; + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; jboolean bindMountAppStorageDirs = JNI_FALSE; nativeForkAndSpecialize_pre(env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote, - instructionSet, appDataDir, isTopApp, pkgDataInfoList, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_samsung_n_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, category, @@ -424,12 +474,14 @@ jint nativeForkAndSpecialize_samsung_m( jboolean is_child_zygote = JNI_FALSE; jboolean isTopApp = JNI_FALSE; jobjectArray pkgDataInfoList = nullptr; + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; jboolean bindMountAppStorageDirs = JNI_FALSE; nativeForkAndSpecialize_pre(env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote, - instructionSet, appDataDir, isTopApp, pkgDataInfoList, - bindMountAppStorageDirs); + instructionSet, appDataDir, isTopApp, pkgDataInfoList, whitelistedDataInfoList, + bindMountAppDataDirs, bindMountAppStorageDirs); jint res = ((nativeForkAndSpecialize_samsung_m_t *) _nativeForkAndSpecialize)( env, clazz, uid, gid, gids, debug_flags, rlimits, mount_external, se_info, category, @@ -448,12 +500,14 @@ void nativeSpecializeAppProcess_q( jboolean isTopApp = JNI_FALSE; 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, - bindMountAppStorageDirs); + whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs); ((nativeSpecializeAppProcess_q_t *) _nativeSpecializeAppProcess)( env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, @@ -466,14 +520,37 @@ void nativeSpecializeAppProcess_r( 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, jboolean bindMountAppStorageDirs) { + jboolean isTopApp, jobjectArray pkgDataInfoList, jobjectArray whitelistedDataInfoList, + jboolean bindMountAppDataDirs, jboolean bindMountAppStorageDirs) { nativeSpecializeAppProcess_pre( env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList, - bindMountAppStorageDirs); + whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs); ((nativeSpecializeAppProcess_r_t *) _nativeSpecializeAppProcess)( + env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, + startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList, + whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs); + + nativeSpecializeAppProcess_post(env, clazz); +} + +void nativeSpecializeAppProcess_r_dp3( + 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, jboolean bindMountAppStorageDirs) { + + jobjectArray whitelistedDataInfoList = nullptr; + jboolean bindMountAppDataDirs = JNI_FALSE; + + nativeSpecializeAppProcess_pre( + env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, + startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList, + whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs); + + ((nativeSpecializeAppProcess_r_dp3_t *) _nativeSpecializeAppProcess)( env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList, bindMountAppStorageDirs); @@ -487,12 +564,14 @@ void nativeSpecializeAppProcess_r_dp2( jboolean startChildZygote, jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList) { + 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, - bindMountAppStorageDirs); + whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs); ((nativeSpecializeAppProcess_r_dp2_t *) _nativeSpecializeAppProcess)( env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, @@ -509,12 +588,14 @@ void nativeSpecializeAppProcess_samsung_q( jboolean isTopApp = JNI_FALSE; 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, - bindMountAppStorageDirs); + whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs); ((nativeSpecializeAppProcess_samsung_t *) _nativeSpecializeAppProcess)( env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, space, diff --git a/module/src/main/cpp/jni_native_method.h b/module/src/main/cpp/jni_native_method.h index 4784c84b..4d220e46 100644 --- a/module/src/main/cpp/jni_native_method.h +++ b/module/src/main/cpp/jni_native_method.h @@ -45,20 +45,21 @@ jint nativeForkAndSpecialize_p( jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote, jstring instructionSet, jstring appDataDir); -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;Z)I"; +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( JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring, - jintArray, jintArray, jboolean, jstring, jstring, jboolean, jobjectArray, jboolean); + jintArray, jintArray, jboolean, jstring, jstring, jboolean, jobjectArray, jobjectArray, + jboolean, jboolean); 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, jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote, jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList, - jboolean bindMountAppStorageDirs); + jobjectArray whitelistedDataInfoList, jboolean bindMountAppDataDirs, jboolean bindMountAppStorageDirs); -const static char *nativeForkAndSpecialize_r_dp2_sig ="(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;)I"; +const static char *nativeForkAndSpecialize_r_dp2_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;)I"; using nativeForkAndSpecialize_r_dp2_t = jint( JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring, @@ -70,6 +71,19 @@ jint nativeForkAndSpecialize_r_dp2( jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote, jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList); +const static char *nativeForkAndSpecialize_r_dp3_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;Z)I"; + +using nativeForkAndSpecialize_r_dp3_t = jint( + JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring, + jintArray, jintArray, jboolean, jstring, jstring, jboolean, jobjectArray, jboolean); + +jint nativeForkAndSpecialize_r_dp3( + 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, + jboolean bindMountAppStorageDirs); + const static char *nativeForkAndSpecialize_samsung_p_sig = "(II[II[[IILjava/lang/String;IILjava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;)I"; using nativeForkAndSpecialize_samsung_p_t = jint( @@ -129,17 +143,18 @@ void nativeSpecializeAppProcess_q( jobjectArray rlimits, jint mountExternal, jstring seInfo, jstring niceName, jboolean startChildZygote, jstring instructionSet, jstring appDataDir); -const static char *nativeSpecializeAppProcess_r_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;Z)V"; +const static char *nativeSpecializeAppProcess_r_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;[Ljava/lang/String;ZZ)V"; using nativeSpecializeAppProcess_r_t = void( JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring, - jboolean, jstring, jstring, jboolean, jobjectArray, jboolean); + jboolean, jstring, jstring, jboolean, jobjectArray, jobjectArray, jboolean, jboolean); void nativeSpecializeAppProcess_r( 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, jboolean bindMountAppStorageDirs); + jboolean isTopApp, jobjectArray pkgDataInfoList, jobjectArray whitelistedDataInfoList, + jboolean bindMountAppDataDirs, jboolean bindMountAppStorageDirs); const static char *nativeSpecializeAppProcess_r_dp2_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;)V"; @@ -153,7 +168,19 @@ void nativeSpecializeAppProcess_r_dp2( jboolean startChildZygote, jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList); -const static char *nativeSpecializeAppProcess_sig_samsung_q ="(II[II[[IILjava/lang/String;IILjava/lang/String;ZLjava/lang/String;Ljava/lang/String;)V"; +const static char *nativeSpecializeAppProcess_r_dp3_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;Z)V"; + +using nativeSpecializeAppProcess_r_dp3_t = void( + JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring, + jboolean, jstring, jstring, jboolean, jobjectArray, jboolean); + +void nativeSpecializeAppProcess_r_dp3( + 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, jboolean bindMountAppStorageDirs); + +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( JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jint, diff --git a/module/src/main/cpp/main.cpp b/module/src/main/cpp/main.cpp index f44a6aa8..4cc9a05f 100644 --- a/module/src/main/cpp/main.cpp +++ b/module/src/main/cpp/main.cpp @@ -170,6 +170,8 @@ static JNINativeMethod *onRegisterZygote(JNIEnv *env, const char *className, else if (strcmp(nativeForkAndSpecialize_marshmallow_sig, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_marshmallow; + else if (strcmp(nativeForkAndSpecialize_r_dp3_sig, method.signature) == 0) + newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_r_dp3; else if (strcmp(nativeForkAndSpecialize_r_dp2_sig, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_r_dp2; @@ -181,6 +183,7 @@ static JNINativeMethod *onRegisterZygote(JNIEnv *env, const char *className, newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_samsung_n; else if (strcmp(nativeForkAndSpecialize_samsung_m_sig, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_samsung_m; + else LOGW("found nativeForkAndSpecialize but signature %s mismatch", method.signature); @@ -201,8 +204,11 @@ static JNINativeMethod *onRegisterZygote(JNIEnv *env, const char *className, else if (strcmp(nativeSpecializeAppProcess_sig_samsung_q, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_samsung_q; + else if (strcmp(nativeSpecializeAppProcess_r_dp3_sig, method.signature) == 0) + newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_r_dp3; else if (strcmp(nativeSpecializeAppProcess_r_dp2_sig, method.signature) == 0) newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_r_dp2; + else LOGW("found nativeSpecializeAppProcess but signature %s mismatch", method.signature); diff --git a/module/src/main/cpp/module.h b/module/src/main/cpp/module.h index d314b4cb..87b4fe42 100644 --- a/module/src/main/cpp/module.h +++ b/module/src/main/cpp/module.h @@ -34,6 +34,11 @@ using nativeForkAndSpecialize_pre_v6_t = void( jstring *, jintArray *, jintArray *, jboolean *, jstring *, jstring *, jboolean *, jobjectArray *, jboolean *); +using nativeForkAndSpecialize_pre_v7_t = void( + JNIEnv *, jclass, jint *, jint *, jintArray *, jint *, jobjectArray *, jint *, jstring *, + jstring *, jintArray *, jintArray *, jboolean *, jstring *, jstring *, jboolean *, + jobjectArray *,jobjectArray *, jboolean *, jboolean *); + using nativeForkAndSpecialize_post_t = int( JNIEnv *, jclass, jint); @@ -61,6 +66,11 @@ using nativeSpecializeAppProcess_pre_v6_t = void( JNIEnv *, jclass, jint *, jint *, jintArray *, jint *, jobjectArray *, jint *, jstring *, jstring *, jboolean *, jstring *, jstring *, jboolean *, jobjectArray *, jboolean *); +using nativeSpecializeAppProcess_pre_v7_t = void( + JNIEnv *, jclass, jint *, jint *, jintArray *, jint *, jobjectArray *, jint *, jstring *, + jstring *, jboolean *, jstring *, jstring *, jboolean *, jobjectArray *, jobjectArray *, + jboolean *, jboolean *); + using nativeSpecializeAppProcess_post_t = int(JNIEnv *, jclass); using shouldSkipUid_t = int(int);