Skip to content

Commit

Permalink
添加国内版miui电量和性能伪装成国际版
Browse files Browse the repository at this point in the history
  • Loading branch information
kooritea committed Apr 18, 2022
1 parent ae45904 commit 7f571f5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- 解除miui12对后台应用的通知限制(非miui系统没影响)(仅作用于在fcmfix中选中的应用)
- 修复在国内网络下出现重连服务出现负数问题(貌似是miui优化的问题)
- 固定心跳间隔(默认不开启,更改需要编辑配置文件/data/data/com.google.android.gms/shared_prefs/fcmfix_config.xml,最小值为1000L)
- 国内版miui电量和性能伪装为国际版,防止锁屏fcm断线

---

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.kooritea.fcmfix"
minSdkVersion 29
targetSdkVersion 30
versionCode 25
versionName "0.4.6"
versionCode 27
versionName "0.4.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/kooritea/fcmfix/XposedMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.kooritea.fcmfix.xposed.AutoStartFix;
import com.kooritea.fcmfix.xposed.BroadcastFix;
import com.kooritea.fcmfix.xposed.MiuiLocalNotificationFix;
import com.kooritea.fcmfix.xposed.PowerkeeperFix;
import com.kooritea.fcmfix.xposed.ReconnectManagerFix;

import java.io.File;
Expand Down Expand Up @@ -32,7 +33,10 @@ public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageP
XposedBridge.log("[fcmfix] start hook com.google.android.gms");
new ReconnectManagerFix(loadPackageParam);
}

if(loadPackageParam.packageName.equals("com.miui.powerkeeper") && loadPackageParam.isFirstApplication){
XposedBridge.log("[fcmfix] start hook com.miui.powerkeeper");
new PowerkeeperFix(loadPackageParam);
}
}
private boolean fileIsExists(String strFile) {
try {
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/com/kooritea/fcmfix/xposed/PowerkeeperFix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.kooritea.fcmfix.xposed;

import android.content.Intent;

import com.kooritea.fcmfix.util.XposedUtils;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class PowerkeeperFix extends XposedModule {
public PowerkeeperFix(XC_LoadPackage.LoadPackageParam loadPackageParam) {
super(loadPackageParam);
this.startHook();
}

protected void startHook(){
try{
XposedUtils.findAndHookMethodAnyParam("android.os.SystemProperties",loadPackageParam.classLoader,"get",new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
String name = (String)param.args[0];
if("ro.product.mod_device".equals(name)){
String device = (String)XposedHelpers.callMethod(param.thisObject, "get", "ro.product.name");
String modDevice = (String)param.getResult();
if(!modDevice.endsWith("_global") && !"".equals(device) && device != null){
printLog("[powerkeeper]" + device + "_global");
param.setResult(device + "_global");
}
}
}
});
XposedHelpers.setStaticBooleanField(XposedHelpers.findClass("miui.os.Build",loadPackageParam.classLoader), "IS_INTERNATIONAL_BUILD", true);
XposedHelpers.setStaticBooleanField(XposedHelpers.findClass("miui.os.Build",loadPackageParam.classLoader), "IS_GLOBAL_BUILD", true);
}catch (XposedHelpers.ClassNotFoundError | NoSuchMethodError e){
printLog("No Such Method com.android.server.am.BroadcastQueueInjector.checkApplicationAutoStart");
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<string-array name="xposed_scope">
<item>android</item>
<item>com.google.android.gms</item>
<item>com.miui.powerkeeper</item>
</string-array>
</resources>

0 comments on commit 7f571f5

Please sign in to comment.