Skip to content

Commit

Permalink
适配安卓11
Browse files Browse the repository at this point in the history
  • Loading branch information
kooritea committed May 4, 2021
1 parent 1894bd3 commit 148d2a3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# fcmfix

## fcm唤醒功能适配安卓10和11,修复fcm重连问题仅适配安卓10

使用xposed让被完全停止的应用响应fcm,让fcm送达率达到100%,不错过任何通知

- 允许fcm唤醒选中的应用来发送通知
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand Down

0 comments on commit 148d2a3

Please sign in to comment.