From 2a9722dd57a239fbf0784910b97dd2415fbd39aa Mon Sep 17 00:00:00 2001 From: kooritea <ochatokori@gmail.com> Date: Fri, 7 May 2021 14:52:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E9=99=A4=E9=80=9A=E7=9F=A5=E9=99=90?= =?UTF-8?q?=E5=88=B6=E4=BB=85=E4=BD=9C=E7=94=A8=E4=BA=8E=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- app/build.gradle | 4 ++-- .../xposed/MiuiLocalNotificationFix.java | 21 +++++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 725ba35..f9f8522 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ 使用xposed让被完全停止的应用响应fcm,让fcm送达率达到100%,不错过任何通知 - 允许fcm唤醒选中的应用来发送通知 -- 解除miui12对后台应用的通知限制(非miui系统没影响) +- 解除miui12对后台应用的通知限制(非miui系统没影响)(仅作用于在fcmfix中选中的应用) - 修复在国内网络下出现重连服务出现负数问题(貌似是miui优化的问题)(可选)(需要查看自己手机上gms的版本编辑配置文件) - 固定心跳间隔为117s(可选)(需要查看自己手机上gms的版本编辑配置文件) diff --git a/app/build.gradle b/app/build.gradle index a349d82..d244cd1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.kooritea.fcmfix" minSdkVersion 29 targetSdkVersion 30 - versionCode 7 - versionName "0.1.0" + versionCode 8 + versionName "0.1.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/kooritea/fcmfix/xposed/MiuiLocalNotificationFix.java b/app/src/main/java/com/kooritea/fcmfix/xposed/MiuiLocalNotificationFix.java index 87fc8e6..b3310ba 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/MiuiLocalNotificationFix.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/MiuiLocalNotificationFix.java @@ -7,6 +7,7 @@ import com.kooritea.fcmfix.util.ContentProviderHelper; import java.lang.reflect.Method; +import java.util.Set; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedBridge; @@ -14,8 +15,12 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage; public class MiuiLocalNotificationFix extends XposedModule { + + protected ContentProviderHelper contentProviderHelper; + public MiuiLocalNotificationFix(XC_LoadPackage.LoadPackageParam loadPackageParam) { super(loadPackageParam); + contentProviderHelper = new ContentProviderHelper(AndroidAppHelper.currentApplication().getApplicationContext(),"content://com.kooritea.fcmfix.provider/config"); this.startHook(); } @@ -33,12 +38,24 @@ protected void startHook(){ XposedBridge.hookMethod(targetMethod,new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam methodHookParam) throws Throwable { - methodHookParam.setResult(true); - printLog("Allow LocalNotification " + methodHookParam.args[3]); + if(targetIsAllow((String)methodHookParam.args[3])){ + methodHookParam.setResult(true); + printLog("Allow LocalNotification " + methodHookParam.args[3]); + } } }); }else{ printLog("Not found isAllowLocalNotification in com.android.server.notification.NotificationManagerServiceInjector"); } } + + private boolean targetIsAllow(String packageName){ + Set<String> allowList = this.contentProviderHelper.getStringSet("allowList"); + for (String item : allowList) { + if (item.equals(packageName)) { + return true; + } + } + return false; + } }