Skip to content

Commit e3c376f

Browse files
support MiPushFramework 0930
1 parent 075a9e4 commit e3c376f

File tree

8 files changed

+63
-18
lines changed

8 files changed

+63
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/release
66
/magisk-module/system
77
/magisk-module/*.zip
8+
*.iml

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ A module of [Riru](https://github.com/RikkaApps/Riru). Fake as a Xiaomi Device b
44

55
## What does this module do
66

7-
By default, `__system_property_get` (`android::base::GetProperty` on Pie+) will be hooked in all packages
7+
By default, `__system_property_get` (`android::base::GetProperty` on Pie+) will be hooked in packages selected in
8+
MiPushFramework with value map below
89

910
* `ro.miui.ui.version.name` -> `V9`
1011
* `ro.miui.ui.version.code` -> `7`

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ android {
2222

2323
task zip(type: Exec) {
2424
workingDir '..'
25-
commandLine 'sh', 'build.sh', project.name, 'v3'
25+
commandLine 'sh', 'build.sh', project.name, 'v5'
2626
}

build.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@ function copy_files {
22
# /data/misc/riru/modules/template exists -> libriru_template.so will be loaded
33
# Change "template" to your module name
44
# You can also use this folder as your config folder
5-
NAME="riru_mipushfake"
5+
NAME="mipush_fake"
66
mkdir -p $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME
77
cp $MODULE_NAME/template_override/riru_module.prop $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/module.prop
88

99
cp $MODULE_NAME/template_override/config.sh $TMP_DIR_MAGISK
1010
cp $MODULE_NAME/template_override/module.prop $TMP_DIR_MAGISK
11-
12-
echo "310030" > $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/gsm.sim.operator.numeric
13-
echo "us" > $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/gsm.sim.operator.iso-country
14-
mkdir $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages
15-
touch $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages/com.google.android.gms
16-
touch $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages/com.google.android.gsf
17-
touch $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages/com.google.android.apps.map
1811
}

jni/main/main.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,49 @@
1616
#include "hook.h"
1717
#include "misc.h"
1818

19+
20+
#define CONFIG_PATH "/data/misc/riru/modules/mipush_fake"
21+
22+
1923
static char package_name[256];
2024
static int uid;
21-
static int enable_hook = true;
25+
static int enable_hook;
26+
static std::vector<std::string> packages = {};
27+
28+
int is_app_need_hook(JNIEnv *env, jstring appDataDir) {
29+
if (!appDataDir)
30+
return 0;
31+
32+
33+
const char *app_data_dir = env->GetStringUTFChars(appDataDir, NULL);
34+
35+
int user = 0;
36+
if (sscanf(app_data_dir, "/data/%*[^/]/%d/%s", &user, package_name) != 2) {
37+
if (sscanf(app_data_dir, "/data/%*[^/]/%s", package_name) != 1) {
38+
package_name[0] = '\0';
39+
LOGW("can't parse %s", app_data_dir);
40+
return 0;
41+
}
42+
}
43+
44+
env->ReleaseStringUTFChars(appDataDir, app_data_dir);
45+
46+
if (access(CONFIG_PATH "/packages", R_OK) != 0) {
47+
for (auto &s : packages) {
48+
if (strcmp(s.c_str(), package_name) == 0)
49+
return 1;
50+
}
51+
} else {
52+
char path[PATH_MAX];
53+
snprintf(path, PATH_MAX, CONFIG_PATH "/packages/%s", package_name);
54+
return access(path, F_OK) == 0;
55+
}
56+
return 0;
57+
}
58+
59+
void load_config() {
60+
//empty
61+
}
2262

2363
void nativeForkAndSpecialize(int res, int enable_hook, const char *package_name, jint uid) {
2464
if (res == 0 && enable_hook) {
@@ -41,6 +81,10 @@ __attribute__((visibility("default"))) void nativeForkAndSpecializePre(JNIEnv *e
4181
jstring instructionSet,
4282
jstring appDataDir) {
4383
uid = _uid;
84+
enable_hook = is_app_need_hook(env, appDataDir);
85+
86+
if (enable_hook)
87+
load_config();
4488
}
4589

4690
__attribute__((visibility("default"))) int nativeForkAndSpecializePost(JNIEnv *env, jclass clazz,

template_override/config.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ check_architecture() {
111111
}
112112

113113
copy_files() {
114+
if [ $IS64BIT = false ]; then
115+
ui_print "- Removing unnecessary files"
116+
rm -rf "$MODPATH/system/lib64"
117+
fi
118+
119+
114120
ui_print "- Extracting extra files"
115121
unzip -o "$ZIP" 'data/*' -d $MODPATH >&2
116122

template_override/module.prop

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
id=riru_mipushfake
1+
id=mipush_fake
22
name=Riru - MiPushFakeModule
3-
version=v3
4-
versionCode=3
3+
version=v5
4+
versionCode=5
55
author=Timothy
66
description=Fake as XiaoMI device by hook system_property_get. Require Riru - Core installed.
77
minMagisk=1500

template_override/riru_module.prop

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name=Module template
2-
version=v3
3-
versionCode=3
1+
name=Riru - MiPushFakeModule
2+
version=v5
3+
versionCode=5
44
author=Timothy
5-
description=Module template
5+
description=Fake as XiaoMI device by hook system_property_get. Require Riru - Core installed.

0 commit comments

Comments
 (0)