Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Support custom ROMs with isTopApp changes backported (#106)
Browse files Browse the repository at this point in the history
* Commit I9601b66e7cc0855fd7c2b573ded31fcf8d0711ae in fw/base.
  • Loading branch information
aviraxp authored Jul 1, 2020
1 parent c3d9ebb commit 222491e
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
47 changes: 47 additions & 0 deletions module/src/main/cpp/jni_native_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions module/src/main/cpp/jni_native_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions module/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand Down

0 comments on commit 222491e

Please sign in to comment.