diff --git a/README.md b/README.md index cc1fc14..ead252f 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ 使用xposed让被完全停止的应用响应fcm,让fcm送达率达到100%,不错过任何通知 - 允许fcm唤醒选中的应用来发送通知 +- 解除miui12对后台应用的通知限制(非miui系统没影响) - 修复在国内网络下出现重连服务出现负数问题(貌似是miui优化的问题)(可选)(需要查看自己手机上gms的版本编辑配置文件) - 固定心跳间隔为117s(可选)(需要查看自己手机上gms的版本编辑配置文件) @@ -34,6 +35,8 @@ ``` +注: heartbeatInterval 设置为0的话则不固定心跳间隔时间,使用原本的自适应 + - 9. 最后将配置文件的enable修改true,保存,重启手机 - 10. 一般来说gms更新改变的只有类名也就是timer_class diff --git a/app/build.gradle b/app/build.gradle index 1c97bd4..a349d82 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.kooritea.fcmfix" minSdkVersion 29 targetSdkVersion 30 - versionCode 6 - versionName "0.0.5" + versionCode 7 + versionName "0.1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/kooritea/fcmfix/XposedMain.java b/app/src/main/java/com/kooritea/fcmfix/XposedMain.java index 7e15205..ca5a79e 100644 --- a/app/src/main/java/com/kooritea/fcmfix/XposedMain.java +++ b/app/src/main/java/com/kooritea/fcmfix/XposedMain.java @@ -1,17 +1,8 @@ package com.kooritea.fcmfix; -import android.app.AndroidAppHelper; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; - import com.kooritea.fcmfix.xposed.BroadcastFix; +import com.kooritea.fcmfix.xposed.MiuiLocalNotificationFix; import com.kooritea.fcmfix.xposed.ReconnectManagerFix; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; - import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.callbacks.XC_LoadPackage; @@ -22,11 +13,13 @@ public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageP if(loadPackageParam.packageName.equals("android")){ XposedBridge.log("[fcmfix] start hook com.android.server.am.ActivityManagerService"); new BroadcastFix(loadPackageParam); + + XposedBridge.log("[fcmfix] start hook com.android.server.notification.NotificationManagerServiceInjector"); + new MiuiLocalNotificationFix(loadPackageParam); } if(loadPackageParam.packageName.equals("com.google.android.gms")){ XposedBridge.log("[fcmfix] start hook com.google.android.gms"); new ReconnectManagerFix(loadPackageParam); - } } diff --git a/app/src/main/java/com/kooritea/fcmfix/xposed/MiuiLocalNotificationFix.java b/app/src/main/java/com/kooritea/fcmfix/xposed/MiuiLocalNotificationFix.java new file mode 100644 index 0000000..87fc8e6 --- /dev/null +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/MiuiLocalNotificationFix.java @@ -0,0 +1,44 @@ +package com.kooritea.fcmfix.xposed; + +import android.app.AndroidAppHelper; +import android.content.Intent; +import android.os.Build; + +import com.kooritea.fcmfix.util.ContentProviderHelper; + +import java.lang.reflect.Method; + +import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.callbacks.XC_LoadPackage; + +public class MiuiLocalNotificationFix extends XposedModule { + public MiuiLocalNotificationFix(XC_LoadPackage.LoadPackageParam loadPackageParam) { + super(loadPackageParam); + this.startHook(); + } + + protected void startHook(){ + Class clazz = XposedHelpers.findClass("com.android.server.notification.NotificationManagerServiceInjector",loadPackageParam.classLoader); + final Method[] declareMethods = clazz.getDeclaredMethods(); + Method targetMethod = null; + for(Method method : declareMethods){ + if(method.getName().equals("isAllowLocalNotification")){ + targetMethod = method; + break; + } + } + if(targetMethod != null){ + XposedBridge.hookMethod(targetMethod,new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam methodHookParam) throws Throwable { + methodHookParam.setResult(true); + printLog("Allow LocalNotification " + methodHookParam.args[3]); + } + }); + }else{ + printLog("Not found isAllowLocalNotification in com.android.server.notification.NotificationManagerServiceInjector"); + } + } +} diff --git a/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java b/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java index 635a3c9..5c2358f 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java @@ -140,7 +140,10 @@ protected void beforeHookedMethod(final MethodHookParam param) throws Throwable // 修改心跳间隔 Intent intent = (Intent) XposedHelpers.getObjectField(param.thisObject, sharedPreferences.getString("timer_intent_property", "")); if ("com.google.android.gms.gcm.HEARTBEAT_ALARM".equals(intent.getAction())) { - param.args[0] = sharedPreferences.getLong("heartbeatInterval", 117000L); + long interval = sharedPreferences.getLong("heartbeatInterval", 0L); + if(interval != 0L){ + param.args[0] = interval; + } } }