Skip to content

Commit c938e96

Browse files
Merge pull request #1 from MlgmXyysd/master
Fix samsung service crash
2 parents 8a2714e + bd0673b commit c938e96

17 files changed

Lines changed: 921 additions & 162 deletions

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
# Riru - Template
1+
# Riru - MiPushFake
22

3-
[Riru](https://github.com/RikkaApps/Riru) module template.
3+
![License GPL-3.0](https://img.shields.io/badge/license-GPLv3.0-green.svg)
44

5-
## Build
5+
Fake as a Xiaomi device by hook system_property_get.
66

7-
1. Replace all "template" to your name
8-
9-
* `module/build.gradle`: "template" in variable `moduleId`, `moduleProp`
10-
* `module/src/main/cpp/CMakeLists.txt`: "riru_template" in `set(MODULE_NAME )`
11-
* `template/magisk_module/post-fs-data.sh`: `MODULE_ID="template"`
12-
* `template/magisk_module/uninstall.sh`: `MODULE_ID="template"`
7+
Requires Riru - Core v19 or above installed.
138

14-
2. Write you codes
15-
3. Run gradle task `:module:assembleRelease` task from Android Studio or command line, zip will be saved in `out`.
9+
## What does this module do
1610

17-
## Notes
11+
By default, `__system_property_get` (`android::base::GetProperty` on Pie+) will be hooked in packages selected in
12+
MiPushFramework with value map below
1813

19-
* DO NOT overwrite `android.os.SystemProperties#native_set` in core, or your data may be wiped
20-
([Detail info](https://github.com/RikkaApps/Riru/blob/v7/riru-core/jni/main/jni_native_method.cpp#L162-L176))
21-
(If you really need to hook this, remember to clear exception)
22-
* DO NO print log (`__android_log_print`) in `nativeForkAndSpecialize(Pre/Post)` `nativeForkSystemServer(Pre/Post)` when in zygote process, or it may cause zygote not work
23-
(magic not confirmed, [Detail info](https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66))
24-
* Add `-ffixed-x18` to both compiler and linker parameter, or it will cause problems on Android Q (see template)
14+
* `ro.miui.ui.version.name` -> `V11`
15+
* `ro.miui.ui.version.code` -> `9`
16+
* `ro.miui.version.code_time` -> `1570636800`
17+
* `ro.miui.internal.storage` -> `/sdcard/`
18+
* `ro.product.manufacturer` -> `Xiaomi`
19+
* `ro.product.brand` -> `Xiaomi`
20+
* `ro.product.name` -> `Xiaomi`

gradlew

Lines changed: 20 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 1 addition & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

module.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ext {
2+
moduleId = "mipush_fake"
3+
riruApiVersion = 4
4+
5+
moduleProp = [
6+
name : "Riru - MiPushFake",
7+
version : "v13.0",
8+
versionCode: "13",
9+
author : "Timothy, MlgmXyysd",
10+
description: "Fake as a Xiaomi device by hook system_property_get. Requires Riru - Core v19 or above installed.",
11+
api : riruApiVersion
12+
]
13+
14+
magiskModuleProp = [
15+
id : "riru-${moduleId.replace('_', '-')}",
16+
name : "Riru - ${moduleProp['name']}",
17+
version : moduleProp['version'],
18+
versionCode: moduleProp['versionCode'],
19+
author : moduleProp['author'],
20+
description: moduleProp['description']
21+
]
22+
}

module/build.gradle

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
apply plugin: 'com.android.library'
2+
apply from: file(rootProject.file('module.gradle'))
23

34
android {
45
compileSdkVersion rootProject.ext.targetSdkVersion
56
defaultConfig {
67
minSdkVersion rootProject.ext.minSdkVersion
78
targetSdkVersion rootProject.ext.targetSdkVersion
9+
externalNativeBuild {
10+
cmake {
11+
arguments "-DMODULE_NAME:STRING=riru_$moduleId"
12+
}
13+
}
814
}
915
externalNativeBuild {
1016
cmake {
@@ -14,29 +20,10 @@ android {
1420
}
1521
}
1622

17-
def moduleId = "mipush_fake"
18-
def moduleProp = [
19-
name : "MiPushFake",
20-
version : "v12.0",
21-
versionCode: "12",
22-
author : "Timothy",
23-
description: "Fake as XiaoMI device by hook system_property_get. Require Riru-Core installed..",
24-
api : 4
25-
]
26-
27-
def magiskModuleProp = [
28-
id : "riru-${moduleId.replace('_', '-')}",
29-
name : "Riru - ${moduleProp['name']}",
30-
version : moduleProp['version'],
31-
versionCode: moduleProp['versionCode'],
32-
author : moduleProp['author'],
33-
description: moduleProp['description']
34-
]
35-
3623
def outDir = file("$rootDir/out")
3724
def magiskDir = file("$outDir/magisk_module")
38-
def zipName = "magisk-${magiskModuleProp['id']}-${magiskModuleProp['version']}.zip"
39-
def riruDir = "$magiskDir/data/misc/riru/modules/${moduleId}"
25+
def zipName = "magisk-${magiskModuleProp['id'].replace('_', '-')}-${magiskModuleProp['version']}.zip"
26+
def riruDir = "$magiskDir/riru"
4027

4128
import java.nio.file.Files
4229
import java.security.MessageDigest
@@ -55,6 +42,8 @@ static def renameOrFail(File from, File to) {
5542
}
5643
}
5744

45+
import org.apache.tools.ant.filters.FixCrLfFilter
46+
5847
android.libraryVariants.all { variant ->
5948
def task = variant.assembleProvider.get()
6049
task.doLast {
@@ -65,6 +54,19 @@ android.libraryVariants.all { variant ->
6554
copy {
6655
from "$rootDir/template/magisk_module"
6756
into magiskDir.path
57+
exclude 'riru.sh'
58+
}
59+
// copy riru.sh
60+
copy {
61+
from "$rootDir/template/magisk_module"
62+
into magiskDir.path
63+
include 'riru.sh'
64+
filter { line ->
65+
line.replaceAll('%%%RIRU_MODULE_ID%%%', moduleId)
66+
.replaceAll('%%%RIRU_MIN_API_VERSION%%%', riruApiVersion.toString())
67+
}
68+
filter(FixCrLfFilter.class,
69+
eol: FixCrLfFilter.CrLf.newInstance("lf"))
6870
}
6971
// copy .git files manually since gradle exclude it by default
7072
Files.copy(file("$rootDir/template/magisk_module/.gitattributes").toPath(), file("${magiskDir.path}/.gitattributes").toPath())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<manifest package="riru.template" />
1+
<manifest package="top.trumeet.mipushframework" />

module/src/main/cpp/hook.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ NEW_FUNC_DEF(int, __system_property_get, const char *key, char *value) {
3535
int res = old___system_property_get(key, value);
3636
if (key) {
3737
if (strcmp("ro.miui.ui.version.name", key) == 0) {
38-
strcpy(value, "V9");
38+
strcpy(value, "V11");
3939
//LOGI("system_property_get: %s -> %s", key, value);
4040
} else if (strcmp("ro.miui.ui.version.code", key) == 0) {
41-
strcpy(value, "7");
41+
strcpy(value, "9");
4242
//LOGI("system_property_get: %s -> %s", key, value);
4343
} else if (strcmp("ro.miui.version.code_time", key) == 0) {
44-
strcpy(value, "1527550858");
44+
strcpy(value, "1570636800");
4545
//LOGI("system_property_get: %s -> %s", key, value);
4646
} else if (strcmp("ro.miui.internal.storage", key) == 0) {
4747
strcpy(value, "/sdcard/");
@@ -65,13 +65,13 @@ NEW_FUNC_DEF(std::string, _ZN7android4base11GetPropertyERKNSt3__112basic_stringI
6565
std::string res = old__ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_(key, default_value);
6666

6767
if (strcmp("ro.miui.ui.version.name", key.c_str()) == 0) {
68-
res = "V9";
68+
res = "V11";
6969
//LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str());
7070
} else if (strcmp("ro.miui.ui.version.code", key.c_str()) == 0) {
71-
res = "7";
71+
res = "9";
7272
//LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str());
7373
} else if (strcmp("ro.miui.version.code_time", key.c_str()) == 0) {
74-
res = "1527550858";
74+
res = "1570636800";
7575
//LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str());
7676
} else if (strcmp("ro.miui.internal.storage", key.c_str()) == 0) {
7777
res = "/sdcard/";

module/src/main/cpp/main.cpp

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,44 @@
77
#include "logging.h"
88
#include "hook.h"
99

10-
#define CONFIG_PATH "/data/misc/riru/modules/mipush_fake"
11-
12-
#define FAKE_CONFIGURATION_GLOBAL "/data/misc/riru/modules/mipush_fake/packages/ALL"
10+
#if PLATFORM_SDK_VERSION >= 24
11+
#define CONFIG_PATH "/data/user_de/0/top.trumeet.mipush"
12+
#else
13+
#define CONFIG_PATH "/data/data/top.trumeet.mipush"
14+
#endif
1315

1416
// You can remove functions you don't need
1517
static char package_name[256];
1618
static bool enable_hook;
1719
static int uid;
1820

19-
static std::vector<std::string> globalPkgBlackList = {"com.google.android",
20-
"de.robv.android.xposed.installer",
21-
"com.xiaomi.xmsf",
22-
"com.tencent.mm",
23-
"top.trumeet.mipush"};
21+
static std::vector<std::string> globalPkgBlackList = {"com.xiaomi.xmsf",
22+
"top.trumeet.mipush",
23+
// Android
24+
"com.google.android",
25+
"android",
26+
"com.android",
27+
// Samsung
28+
"com.bst",
29+
"com.sec",
30+
"com.sem",
31+
"com.sgmc",
32+
"com.dsi.ant",
33+
"com.wsomacp",
34+
"com.samsung",
35+
"com.diotek.sec",
36+
"com.enhance.gameservice",
37+
// XDA
38+
"com.xda",
39+
// Wechat
40+
"com.tencent.mm",
41+
// Quickpay
42+
"com.example",
43+
// Magisk
44+
"com.topjohnwu.magisk",
45+
// Xposed
46+
"org.meowcat.edxposed.manager",
47+
"de.robv.android.xposed.installer"};
2448

2549

2650
bool isAppNeedHook(JNIEnv *pEnv, jstring pJstring);
@@ -173,7 +197,7 @@ bool isAppNeedHook(JNIEnv *env, jstring jAppDataDir) {
173197
}
174198
}
175199

176-
if (access(FAKE_CONFIGURATION_GLOBAL, F_OK) == 0) {
200+
if (access(CONFIG_PATH "/packages/ALL", F_OK) == 0) {
177201
return true;
178202
}
179203

template/magisk_module/.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ META-INF/** text eol=lf
33
*.prop text eol=lf
44
*.sh text eol=lf
55
*.md text eol=lf
6-
sepolicy.rule eol=lf
6+
sepolicy.rule text eol=lf
77

88
# Denote all files that are truly binary and should not be modified.
99
system/** binary

0 commit comments

Comments
 (0)