diff --git a/README.md b/README.md index 1bde0d1..eef4c82 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # fcmfix +## fcm唤醒功能适配安卓10和11,修复fcm重连问题仅适配安卓10 + 使用xposed让被完全停止的应用响应fcm,让fcm送达率达到100%,不错过任何通知 - 允许fcm唤醒选中的应用来发送通知 diff --git a/app/build.gradle b/app/build.gradle index e7779d2..1c97bd4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,10 +5,10 @@ android { defaultConfig { applicationId "com.kooritea.fcmfix" - minSdkVersion 27 - targetSdkVersion 29 - versionCode 4 - versionName "0.0.4" + minSdkVersion 29 + targetSdkVersion 30 + versionCode 6 + versionName "0.0.5" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } 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 7e59af6..5e1c0c8 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java @@ -3,6 +3,7 @@ import android.app.AndroidAppHelper; import android.content.ContextWrapper; import android.content.Intent; +import android.os.Build; import com.kooritea.fcmfix.util.ContentProviderHelper; @@ -41,7 +42,16 @@ protected void startHook(){ XposedBridge.hookMethod(targetMethod,new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam methodHookParam) throws Throwable { - Intent intent = (Intent) methodHookParam.args[2]; + int intent_args_index = 0; + int appOp_args_index = 0; + if(Build.VERSION.SDK_INT == Build.VERSION_CODES.Q){ + intent_args_index = 2; + appOp_args_index = 9; + }else if(Build.VERSION.SDK_INT > Build.VERSION_CODES.Q){ + intent_args_index = 3; + appOp_args_index = 10; + } + Intent intent = (Intent) methodHookParam.args[intent_args_index]; if(intent != null && intent.getPackage() != null && intent.getFlags() != Intent.FLAG_INCLUDE_STOPPED_PACKAGES && "com.google.android.c2dm.intent.RECEIVE".equals(intent.getAction())){ String target; if (intent.getComponent() != null) { @@ -50,9 +60,9 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) throws Throwa target = intent.getPackage(); } if(targetIsAllow(target)){ - int i = ((Integer)methodHookParam.args[9]).intValue(); + int i = ((Integer)methodHookParam.args[appOp_args_index]).intValue(); if (i == -1) { - methodHookParam.args[9] = Integer.valueOf(11); + methodHookParam.args[appOp_args_index] = Integer.valueOf(11); } intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); printLog("Send Forced Start Broadcast: " + target); 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 70870fb..41beef5 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java @@ -6,6 +6,7 @@ import com.kooritea.fcmfix.util.ContentProviderHelper; +import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.callbacks.XC_LoadPackage; public class XposedModule { @@ -17,6 +18,7 @@ protected XposedModule(final XC_LoadPackage.LoadPackageParam loadPackageParam){ } protected void printLog(String text){ + XposedBridge.log("[fcmfix] "+ text); Intent log = new Intent("com.kooritea.fcmfix.log"); log.putExtra("text",text); try{