Skip to content
This repository was archived by the owner on Sep 1, 2021. It is now read-only.

Commit 3543638

Browse files
committed
* Upgrade to Riru 19.1
1 parent 3ee4d31 commit 3543638

File tree

5 files changed

+64
-28
lines changed

5 files changed

+64
-28
lines changed

app/build.gradle

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'kotlin-android-extensions'
32
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
def gitCommitCount = Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())
6+
def baseVersionName = '19.1'
47

58
android {
69
compileSdkVersion rootProject.ext.targetSdkVersion
710
defaultConfig {
811
applicationId "moe.riru.manager"
912
minSdkVersion rootProject.ext.minSdkVersion
1013
targetSdkVersion rootProject.ext.targetSdkVersion
11-
versionCode 4
12-
versionName "0.0.4"
14+
versionCode gitCommitCount
15+
versionName baseVersionName
1316
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1417
externalNativeBuild {
1518
cmake {
@@ -55,9 +58,10 @@ dependencies {
5558
androidTestImplementation 'com.android.support.test:runner:1.0.2'
5659
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
5760
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
61+
implementation "androidx.annotation:annotation:1.0.2"
5862
implementation "moe.shizuku.support:recyclerview-utils:3.0.4"
59-
implementation "moe.shizuku.support:design:3.1.0"
60-
implementation "moe.shizuku.support:support-utils:3.0.4"
63+
implementation "moe.shizuku.support:design:3.1.2"
64+
implementation "moe.shizuku.support:support-utils:3.0.5"
6165
implementation "moe.shizuku.support:htmlcompat:2.0.0"
6266
}
6367
repositories {

app/src/main/cpp/helper.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static jboolean init(JNIEnv *env, jobject thiz) {
3636
jboolean res = JNI_FALSE;
3737
procmaps_struct *maps_tmp = nullptr;
3838
while ((maps_tmp = pmparser_next(maps)) != nullptr) {
39+
//LOGI("%s", maps_tmp->pathname);
3940
if (strstr(maps_tmp->pathname, "libmemtrack_real.so")) {
4041
res = JNI_TRUE;
4142
}
@@ -94,6 +95,15 @@ static jint get_nativeForkSystemServer_calls_count(JNIEnv *env, jobject thiz) {
9495
return -1;
9596
}
9697

98+
static jint get_nativeSpecializeAppProcess_calls_count(JNIEnv *env, jobject thiz) {
99+
static void *sym;
100+
void *handle;
101+
if ((handle = get_handle()) == nullptr) return -1;
102+
if (sym == nullptr) sym = dlsym(handle, "riru_get_nativeSpecializeAppProcess_calls_count");
103+
if (sym) return static_cast<jboolean>(((int (*)()) sym)());
104+
return -1;
105+
}
106+
97107
static jstring get_nativeForkAndSpecialize_signature(JNIEnv *env, jobject thiz) {
98108
static void *sym;
99109
void *handle;
@@ -108,14 +118,14 @@ static jstring get_nativeForkAndSpecialize_signature(JNIEnv *env, jobject thiz)
108118
return nullptr;
109119
}
110120

111-
static jstring get_nativeSpecializeBlastula_signature(JNIEnv *env, jobject thiz) {
121+
static jstring get_nativeSpecializeAppProcess_signature(JNIEnv *env, jobject thiz) {
112122
static void *sym;
113123
void *handle;
114124
if ((handle = get_handle()) == nullptr) return nullptr;
115125
if (sym == nullptr) sym = dlsym(handle, "riru_get_original_native_methods");
116126
if (sym) {
117127
auto method = ((const JNINativeMethod *(*)(const char *, const char *, const char *)) sym)(
118-
"com/android/internal/os/Zygote", "nativeSpecializeBlastula", nullptr);
128+
"com/android/internal/os/Zygote", "nativeSpecializeAppProcess", nullptr);
119129
if (method != nullptr)
120130
return env->NewStringUTF(method->signature);
121131
}
@@ -137,15 +147,16 @@ static jstring get_nativeForkSystemServer_signature(JNIEnv *env, jobject thiz) {
137147
}
138148

139149
static JNINativeMethod gMethods[] = {
140-
{"init", "()Z", (void *) init},
141-
{"isRiruModuleExists", "(Ljava/lang/String;)Z", (void *) is_riru_module_exists},
142-
{"getRiruVersion", "()I", (void *) get_riru_rersion},
143-
{"isZygoteMethodsReplaced", "()Z", (void *) is_zygote_methods_replaced},
144-
{"getNativeForkAndSpecializeCallsCount", "()I", (void *) get_nativeForkAndSpecialize_calls_count},
145-
{"getNativeForkSystemServerCallsCount", "()I", (void *) get_nativeForkSystemServer_calls_count},
146-
{"getNativeForkAndSpecializeSignature", "()Ljava/lang/String;", (void *) get_nativeForkAndSpecialize_signature},
147-
{"getNativeSpecializeBlastulaSignature", "()Ljava/lang/String;", (void *) get_nativeSpecializeBlastula_signature},
148-
{"getNativeForkSystemServerSignature", "()Ljava/lang/String;", (void *) get_nativeForkSystemServer_signature},
150+
{"init", "()Z", (void *) init},
151+
{"isRiruModuleExists", "(Ljava/lang/String;)Z", (void *) is_riru_module_exists},
152+
{"getRiruVersion", "()I", (void *) get_riru_rersion},
153+
{"isZygoteMethodsReplaced", "()Z", (void *) is_zygote_methods_replaced},
154+
{"getNativeForkAndSpecializeCallsCount", "()I", (void *) get_nativeForkAndSpecialize_calls_count},
155+
{"getNativeForkSystemServerCallsCount", "()I", (void *) get_nativeForkSystemServer_calls_count},
156+
{"getNativeSpecializeAppProcessCallsCount", "()I", (void *) get_nativeSpecializeAppProcess_calls_count},
157+
{"getNativeForkAndSpecializeSignature", "()Ljava/lang/String;", (void *) get_nativeForkAndSpecialize_signature},
158+
{"getNativeSpecializeAppProcessSignature", "()Ljava/lang/String;", (void *) get_nativeSpecializeAppProcess_signature},
159+
{"getNativeForkSystemServerSignature", "()Ljava/lang/String;", (void *) get_nativeForkSystemServer_signature},
149160
};
150161

151162
static int registerNativeMethods(JNIEnv *env, const char *className,

app/src/main/java/moe/riru/manager/MainActivity.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
1818
super.onCreate(savedInstanceState);
1919

2020
boolean init, isZygoteMethodsReplaced;
21-
int version, nativeForkAndSpecializeCallsCount, nativeForkSystemServerCallsCount;
22-
String nativeForkAndSpecializeSignature, nativeSpecializeBlastulaSignature, nativeForkSystemServerSignature;
21+
int version, nativeForkAndSpecializeCallsCount, nativeForkSystemServerCallsCount, nativeSpecializeAppProcessCallsCount;
22+
String nativeForkAndSpecializeSignature, nativeSpecializeAppProcessSignature, nativeForkSystemServerSignature;
2323

2424
StringBuilder sb = new StringBuilder();
2525

@@ -32,26 +32,29 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3232
isZygoteMethodsReplaced = NativeHelper.isZygoteMethodsReplaced();
3333
nativeForkAndSpecializeCallsCount = NativeHelper.getNativeForkAndSpecializeCallsCount();
3434
nativeForkSystemServerCallsCount = NativeHelper.getNativeForkSystemServerCallsCount();
35+
nativeSpecializeAppProcessCallsCount = NativeHelper.getNativeSpecializeAppProcessCallsCount();
3536
nativeForkAndSpecializeSignature = NativeHelper.getNativeForkAndSpecializeSignature();
36-
nativeSpecializeBlastulaSignature = NativeHelper.getNativeSpecializeBlastulaSignature();
37+
nativeSpecializeAppProcessSignature = NativeHelper.getNativeSpecializeAppProcessSignature();
3738
nativeForkSystemServerSignature = NativeHelper.getNativeForkSystemServerSignature();
3839

3940
sb.append("Riru ").append(NativeHelper.versionName(this, version)).append(" found.").append("<br>");
4041

4142
if (isZygoteMethodsReplaced) {
4243
sb.append("Native methods of Zygote class replaced.").append("<br><br>")
4344
.append("nativeForkAndSpecialize calls count: ").append(nativeForkAndSpecializeCallsCount).append("<br>")
44-
.append("nativeForkSystemServer calls count: ").append(nativeForkSystemServerCallsCount).append("<br>");
45+
.append("nativeForkSystemServer calls count: ").append(nativeForkSystemServerCallsCount).append("<br>")
46+
.append("nativeSpecializeAppProcess calls count: ").append(nativeSpecializeAppProcessCallsCount).append("<br>");
4547

46-
if (nativeForkAndSpecializeCallsCount == 0) {
47-
sb.append("<br>nativeForkAndSpecialize calls count is 0, Riru is not working correctly.<br>This may because Riru's hook is overwritten by other things, please check yourself.");
48+
if (nativeForkAndSpecializeCallsCount <= 0 && nativeSpecializeAppProcessCallsCount <= 0) {
49+
sb.append("<br>nativeForkAndSpecialize/nativeSpecializeAppProcess calls count is 0, Riru is not working correctly.<br>This may because Riru's hook is overwritten by other things, please check yourself.");
4850
} else if (nativeForkSystemServerCallsCount != 0) {
4951
sb.append("<br>Everything looks fine :D");
5052
}
5153
} else {
5254
sb.append("However, native methods of Zygote class not replaced, please contact developer with the following information.").append("<br><br>")
5355
.append("nativeForkAndSpecializeSignature:<br><font face=\"monospace\">").append(nativeForkAndSpecializeSignature).append("</font><br><br>")
54-
.append("getNativeForkSystemServerSignature:<br><font face=\"monospace\">").append(nativeForkSystemServerSignature).append("</font>");
56+
.append("nativeSpecializeAppProcessSignature (from Q beta 3):<br><font face=\"monospace\">").append(nativeSpecializeAppProcessSignature).append("</font><br><br>")
57+
.append("nativeForkSystemServerSignature:<br><font face=\"monospace\">").append(nativeForkSystemServerSignature).append("</font>");
5558
}
5659
}
5760
} else {
@@ -76,7 +79,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7679
Log.i("RiruManager", "getNativeForkAndSpecializeCallsCount: " + NativeHelper.getNativeForkAndSpecializeCallsCount());
7780
Log.i("RiruManager", "getNativeForkSystemServerCallsCount: " + NativeHelper.getNativeForkSystemServerCallsCount());
7881
Log.i("RiruManager", "getNativeForkAndSpecializeSignature: " + NativeHelper.getNativeForkAndSpecializeSignature());
79-
Log.i("RiruManager", "getNativeSpecializeBlastulaSignature: " + NativeHelper.getNativeSpecializeBlastulaSignature());
82+
Log.i("RiruManager", "getNativeSpecializeAppProcessSignature: " + NativeHelper.getNativeSpecializeAppProcessSignature());
8083
Log.i("RiruManager", "getNativeForkSystemServerSignature: " + NativeHelper.getNativeForkSystemServerSignature());
8184
}
8285
}

app/src/main/java/moe/riru/manager/utils/BuildUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
public class BuildUtils {
66

77
public static boolean isQ() {
8-
return "Q".equals(Build.VERSION.RELEASE) || Build.VERSION.SDK_INT >= 29;
8+
return (Build.VERSION.SDK_INT == 28 && Build.VERSION.PREVIEW_SDK_INT > 0) || Build.VERSION.SDK_INT >= 29;
99
}
1010
}

app/src/main/java/moe/riru/manager/utils/NativeHelper.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
import android.content.Context;
44

55
import androidx.annotation.Keep;
6+
67
import moe.riru.manager.R;
78

89
@Keep
910
public class NativeHelper {
1011

11-
private static final int MAX_VERSION = 19;
12+
private static final int V19_1 = 22;
13+
private static final int V19 = 20;
1214
private static final int V18 = 19;
1315
private static final int V17_1 = 18;
16+
private static final int MAX_VERSION = V19_1;
1417

1518
static {
1619
System.loadLibrary("helper");
@@ -26,22 +29,37 @@ public static String versionName(Context context, int versionCode) {
2629
}
2730

2831
switch (versionCode) {
32+
case V19_1:
33+
return "v19.1";
34+
case V19:
35+
return "v19";
2936
case V18:
3037
return "v18";
3138
case V17_1:
3239
return "v17.1";
3340
default:
34-
return "v" + versionCode;
41+
return "unknown (version code " + versionCode + ")";
3542
}
3643
}
3744

3845
public static native boolean init();
46+
3947
public static native boolean isRiruModuleExists(String name);
48+
4049
public static native int getRiruVersion();
50+
4151
public static native boolean isZygoteMethodsReplaced();
52+
4253
public static native int getNativeForkAndSpecializeCallsCount();
54+
4355
public static native int getNativeForkSystemServerCallsCount();
56+
57+
public static native int getNativeSpecializeAppProcessCallsCount();
58+
4459
public static native String getNativeForkAndSpecializeSignature();
45-
public static native String getNativeSpecializeBlastulaSignature();
60+
4661
public static native String getNativeForkSystemServerSignature();
62+
63+
public static native String getNativeSpecializeAppProcessSignature();
64+
4765
}

0 commit comments

Comments
 (0)