Skip to content

Commit

Permalink
解除通知限制仅作用于选中的应用
Browse files Browse the repository at this point in the history
  • Loading branch information
kooritea committed May 7, 2021
1 parent 3f32002 commit 2a9722d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
使用xposed让被完全停止的应用响应fcm,让fcm送达率达到100%,不错过任何通知

- 允许fcm唤醒选中的应用来发送通知
- 解除miui12对后台应用的通知限制(非miui系统没影响)
- 解除miui12对后台应用的通知限制(非miui系统没影响)(仅作用于在fcmfix中选中的应用)
- 修复在国内网络下出现重连服务出现负数问题(貌似是miui优化的问题)(可选)(需要查看自己手机上gms的版本编辑配置文件)
- 固定心跳间隔为117s(可选)(需要查看自己手机上gms的版本编辑配置文件)

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 7
versionName "0.1.0"
versionCode 8
versionName "0.1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
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;
import de.robv.android.xposed.XposedHelpers;
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();
}

Expand All @@ -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;
}
}

0 comments on commit 2a9722d

Please sign in to comment.