diff --git a/app/src/main/java/com/kooritea/fcmfix/xposed/AutoStartFix.java b/app/src/main/java/com/kooritea/fcmfix/xposed/AutoStartFix.java index fdc5a61..56083c1 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/AutoStartFix.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/AutoStartFix.java @@ -9,7 +9,6 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage; public class AutoStartFix extends XposedModule { - private final String FCM_RECEIVE = ".android.c2dm.intent.RECEIVE"; public AutoStartFix(XC_LoadPackage.LoadPackageParam loadPackageParam){ super(loadPackageParam); @@ -29,7 +28,7 @@ protected void startHook(){ @Override protected void beforeHookedMethod(MethodHookParam methodHookParam) { Intent intent = (Intent) XposedHelpers.getObjectField(methodHookParam.args[2], "intent"); - if(intent.getAction().endsWith(FCM_RECEIVE)){ + if(isFCMIntent(intent)){ String target = intent.getComponent() == null ? intent.getPackage() : intent.getComponent().getPackageName(); if(targetIsAllow(target)){ XposedHelpers.callStaticMethod(BroadcastQueueInjector,"checkAbnormalBroadcastInQueueLocked", methodHookParam.args[1], methodHookParam.args[0]); @@ -49,7 +48,7 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) { @Override protected void beforeHookedMethod(MethodHookParam methodHookParam) { Intent intent = (Intent) XposedHelpers.getObjectField(methodHookParam.args[1], "intent"); - if(intent.getAction().endsWith(FCM_RECEIVE)){ + if(isFCMIntent(intent)){ String target = intent.getComponent() == null ? intent.getPackage() : intent.getComponent().getPackageName(); if(targetIsAllow(target)){ XposedHelpers.callMethod(methodHookParam.thisObject, "checkAbnormalBroadcastInQueueLocked", methodHookParam.args[0]); @@ -76,7 +75,7 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) { // 无日志,先放了 printLog("[" + intent.getAction() + "]checkApplicationAutoStart package_name: " + target, true); methodHookParam.setResult(true); -// if(intent.getAction().endsWith(FCM_RECEIVE)){ +// if(isFCMIntent(intent)){ // printLog("checkApplicationAutoStart package_name: " + target, true); // methodHookParam.setResult(true); // }else{ @@ -94,7 +93,7 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) { Intent intent = (Intent) XposedHelpers.getObjectField(methodHookParam.args[1], "intent"); String target = intent.getComponent() == null ? intent.getPackage() : intent.getComponent().getPackageName(); if(targetIsAllow(target)){ - if(intent.getAction().endsWith(FCM_RECEIVE)){ + if(isFCMIntent(intent)){ printLog("BroadcastQueueModernStubImpl.checkReceiverIfRestricted package_name: " + target, true); methodHookParam.setResult(false); } @@ -116,7 +115,7 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) { // 拿不到action,先放了 printLog("[" + intent.getAction() + "]AutoStartManagerServiceStubImpl.isAllowStartService package_name: " + target, true); methodHookParam.setResult(true); -// if(intent.getAction().endsWith(FCM_RECEIVE)){ +// if(isFCMIntent(intent)){ // printLog("AutoStartManagerServiceStubImpl.isAllowStartService package_name: " + target, true); // methodHookParam.setResult(true); // }else{ @@ -146,7 +145,7 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) { Intent intent = (Intent) XposedHelpers.getObjectField(methodHookParam.args[1], "intent"); String target = intent.getComponent() == null ? intent.getPackage() : intent.getComponent().getPackageName(); if(targetIsAllow(target)) { - if(intent.getAction().endsWith(FCM_RECEIVE)){ + if(isFCMIntent(intent)){ printLog("SmartPowerService.shouldInterceptBroadcast package_name: " + target, true); methodHookParam.setResult(false); } diff --git a/app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java b/app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java index acf68e2..73c227c 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java @@ -136,7 +136,7 @@ protected void startHook(){ @Override protected void beforeHookedMethod(MethodHookParam methodHookParam) { Intent intent = (Intent) methodHookParam.args[finalIntent_args_index]; - if(intent != null && intent.getPackage() != null && intent.getFlags() != Intent.FLAG_INCLUDE_STOPPED_PACKAGES && intent.getAction().endsWith(".android.c2dm.intent.RECEIVE")){ + if(intent != null && intent.getPackage() != null && intent.getFlags() != Intent.FLAG_INCLUDE_STOPPED_PACKAGES && isFCMIntent(intent)){ String target; if (intent.getComponent() != null) { target = intent.getComponent().getPackageName(); diff --git a/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java b/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java index bc49d86..4c05339 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java @@ -279,4 +279,13 @@ protected void createFcmfixChannel(NotificationManager notificationManager) { notificationManager.createNotificationChannel(channel); } } + + protected boolean isFCMIntent(Intent intent) { + String action = intent.getAction(); + if (action != null && action.endsWith(".android.c2dm.intent.RECEIVE")) { + return true; + } else { + return false; + } + } }