Skip to content

Commit

Permalink
修复安卓14部分版本阻止应用停止时自动清除通知遗功能异常
Browse files Browse the repository at this point in the history
  • Loading branch information
kooritea committed Apr 12, 2024
1 parent adf1947 commit b5a0c25
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions app/src/main/java/com/kooritea/fcmfix/xposed/KeepNotification.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kooritea.fcmfix.xposed;

import android.os.Build;
import java.lang.reflect.Method;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
Expand Down Expand Up @@ -33,12 +34,46 @@ protected void startHook() throws NoSuchMethodError, XposedHelpers.ClassNotFound
}
}
if(targetMethod != null){
int pkg_args_index = 2;
int reason_args_index = 8;
int pkg_args_index = 0;
int reason_args_index = 0;
if(Build.VERSION.SDK_INT == 30){
pkg_args_index = 2;
reason_args_index = 8;
}
if(Build.VERSION.SDK_INT == 31){
pkg_args_index = 2;
reason_args_index = 8;
}
if(Build.VERSION.SDK_INT == 32){
pkg_args_index = 2;
reason_args_index = 8;
}
if(Build.VERSION.SDK_INT == 33){
pkg_args_index = 2;
reason_args_index = 8;
}
if(Build.VERSION.SDK_INT == 34){
if(targetMethod.getParameterTypes().length == 10){
pkg_args_index = 2;
reason_args_index = 8;
}else if(targetMethod.getParameterTypes().length == 8){
pkg_args_index = 2;
reason_args_index = 7;
}
}
if(Build.VERSION.SDK_INT > 34){
pkg_args_index = 2;
reason_args_index = 7;
}
if(pkg_args_index == 0 || reason_args_index == 0){
throw new NoSuchMethodError();
}
int finalPkg_args_index = pkg_args_index;
int finalReason_args_index = reason_args_index;
XposedBridge.hookMethod(targetMethod,new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) {
if(isDisableAutoCleanNotification() && targetIsAllow((String) param.args[pkg_args_index]) && (int)param.args[reason_args_index] == 5){
if(isDisableAutoCleanNotification() && targetIsAllow((String) param.args[finalPkg_args_index]) && (int)param.args[finalReason_args_index] == 5){
param.setResult(null);
}
}
Expand Down

0 comments on commit b5a0c25

Please sign in to comment.