Skip to content

Commit

Permalink
添加对intent.action的判空
Browse files Browse the repository at this point in the history
  • Loading branch information
kooritea committed Jun 24, 2024
1 parent d1978a7 commit a7c3d71
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
13 changes: 6 additions & 7 deletions app/src/main/java/com/kooritea/fcmfix/xposed/AutoStartFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]);
Expand All @@ -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]);
Expand All @@ -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{
Expand All @@ -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);
}
Expand All @@ -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{
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

0 comments on commit a7c3d71

Please sign in to comment.