Skip to content

Commit c5175fd

Browse files
committed
v1.0
1 parent 34f540c commit c5175fd

14 files changed

+530
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties
11+
/gradle
12+
/*/release

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
compileSdk 32
8+
9+
defaultConfig {
10+
applicationId "cn.yhfcn.mipushfaker"
11+
minSdk 21
12+
targetSdk 32
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
kotlinOptions {
30+
jvmTarget = '1.8'
31+
}
32+
}
33+
34+
dependencies {
35+
compileOnly 'de.robv.android.xposed:api:82'
36+
testImplementation 'junit:junit:4.13.2'
37+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
38+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
39+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="cn.yhfcn.mipushfaker">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:label="@string/app_name"
8+
android:supportsRtl="true">
9+
<meta-data
10+
android:name="xposedmodule"
11+
android:value="true" />
12+
<meta-data
13+
android:name="xposeddescription"
14+
android:resource="@string/xp_mod_desc" />
15+
<meta-data
16+
android:name="xposedminversion"
17+
android:value="82" />
18+
<meta-data android:name="xposedscope" android:resource="@array/xposed_scope" />
19+
</application>
20+
21+
</manifest>

app/src/main/assets/xposed_init

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cn.yhfcn.mipushfaker.mod.MiPushFake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package cn.yhfcn.mipushfaker.mod
2+
3+
import android.os.Build
4+
import de.robv.android.xposed.IXposedHookLoadPackage
5+
import de.robv.android.xposed.XC_MethodHook
6+
import de.robv.android.xposed.XposedHelpers
7+
import de.robv.android.xposed.callbacks.XC_LoadPackage
8+
9+
class MiPushFake : IXposedHookLoadPackage {
10+
val props: Map<String, String> = mapOf(
11+
Pair("ro.miui.ui.version.name", "V12"),
12+
Pair("ro.miui.ui.version.code", "10"),
13+
Pair("ro.miui.version.code_time", "1592409600"),
14+
15+
Pair("product.manufacturer", "Xiaomi"),
16+
Pair("ro.product.vendor.manufacturer", "Xiaomi"),
17+
Pair("ro.product.brand", "Xiaomi"),
18+
Pair("ro.product.vendor.brand", "Xiaomi"),
19+
)
20+
21+
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
22+
// find mipush sdk
23+
val serviceExist = try {
24+
lpparam.classLoader.loadClass("com.xiaomi.push.service.XMPushService")
25+
true
26+
} catch (e: ClassNotFoundException) {
27+
false
28+
}
29+
val messageHandlerExist = try {
30+
lpparam.classLoader.loadClass("com.xiaomi.mipush.sdk.PushMessageHandler")
31+
true
32+
} catch (e: ClassNotFoundException) {
33+
false
34+
}
35+
val hasXiaomiPush = serviceExist or messageHandlerExist
36+
if (!hasXiaomiPush) {
37+
return
38+
}
39+
/**
40+
* fake miui12 hook
41+
* code from https://github.com/MiPushFramework/MiPushEnhancement
42+
* @author <a href="https://github.com/MlgmXyysd">Jaida Wu</a>
43+
* @author <a href="https://github.com/Trumeet">Yuuta Liang</a>
44+
* @see <a href="https://github.com/MiPushFramework/MiPushEnhancement/blob/master/app/src/main/java/org/meowcat/xposed/mipush/Enhancement.java">MiPushEnhancement</a>
45+
*/
46+
XposedHelpers.findAndHookMethod(XposedHelpers.findClass(
47+
"android.os.SystemProperties",
48+
lpparam.classLoader
49+
),
50+
"native_get",
51+
String::class.java,
52+
String::class.java,
53+
object : XC_MethodHook() {
54+
override fun afterHookedMethod(param: MethodHookParam) {
55+
val key = param.args[0].toString()
56+
if (props.containsKey(key)) {
57+
param.result = props[key]
58+
}
59+
}
60+
})
61+
62+
// android.os.SystemProperties.native_get_int(String,int)
63+
64+
// android.os.SystemProperties.native_get_int(String,int)
65+
XposedHelpers.findAndHookMethod(XposedHelpers.findClass(
66+
"android.os.SystemProperties",
67+
lpparam.classLoader
68+
),
69+
"native_get_int",
70+
String::class.java,
71+
Int::class.javaPrimitiveType,
72+
object : XC_MethodHook() {
73+
override fun afterHookedMethod(param: MethodHookParam) {
74+
val key = param.args[0].toString()
75+
if (props.containsKey(key)) {
76+
param.result = props[key]
77+
}
78+
}
79+
})
80+
81+
// android.os.SystemProperties.native_get_long(String,long)
82+
83+
// android.os.SystemProperties.native_get_long(String,long)
84+
XposedHelpers.findAndHookMethod(XposedHelpers.findClass(
85+
"android.os.SystemProperties",
86+
lpparam.classLoader
87+
),
88+
"native_get_long",
89+
String::class.java,
90+
Long::class.javaPrimitiveType,
91+
object : XC_MethodHook() {
92+
override fun afterHookedMethod(param: MethodHookParam) {
93+
val key = param.args[0].toString()
94+
if (props.containsKey(key)) {
95+
param.result = props[key]
96+
}
97+
}
98+
})
99+
100+
XposedHelpers.setStaticObjectField(Build::class.java, "MANUFACTURER", "Xiaomi")
101+
XposedHelpers.setStaticObjectField(Build::class.java, "BRAND", "Xiaomi")
102+
}
103+
}

app/src/main/res/values/arrays.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string-array name="xposed_scope" />
4+
</resources>

app/src/main/res/values/strings.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<resources>
2+
<string name="app_name">MiPushFaker</string>
3+
<string name="xp_mod_desc">伪装机型让普通应用能够正确识别到MiPush,搭配MiPushFramework使用</string>
4+
</resources>

build.gradle

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
plugins {
3+
id 'com.android.application' version '7.1.2' apply false
4+
id 'com.android.library' version '7.1.2' apply false
5+
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
6+
}
7+
8+
task clean(type: Delete) {
9+
delete rootProject.buildDir
10+
}

gradle.properties

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Project-wide Gradle settings.
2+
# IDE (e.g. Android Studio) users:
3+
# Gradle settings configured through the IDE *will override*
4+
# any settings specified in this file.
5+
# For more details on how to configure your build environment visit
6+
# http://www.gradle.org/docs/current/userguide/build_environment.html
7+
# Specifies the JVM arguments used for the daemon process.
8+
# The setting is particularly useful for tweaking memory settings.
9+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10+
# When configured, Gradle will run in incubating parallel mode.
11+
# This option should only be used with decoupled projects. More details, visit
12+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13+
# org.gradle.parallel=true
14+
# AndroidX package structure to make it clearer which packages are bundled with the
15+
# Android operating system, and which are packaged with your app"s APK
16+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
17+
android.useAndroidX=true
18+
# Kotlin code style for this project: "official" or "obsolete":
19+
kotlin.code.style=official
20+
# Enables namespacing of each library's R class so that its R class includes only the
21+
# resources declared in the library itself and none from the library's dependencies,
22+
# thereby reducing the size of the R class for that library
23+
android.nonTransitiveRClass=true

0 commit comments

Comments
 (0)