Skip to content

Commit

Permalink
适配12L
Browse files Browse the repository at this point in the history
  • Loading branch information
kooritea committed Apr 18, 2022
1 parent 40bcb20 commit 428811e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 53 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# fcmfix(Android 10 & 11 & 12)
# fcmfix(Android 10 & 11 & 12 & 12L )

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

Expand Down Expand Up @@ -45,6 +45,7 @@ SafetyNet不通过请检查有没有科学上网
> 一般是你用了mt管理器那个编辑器的问题,可以尝试修改完后删除那个.bak后缀的文件,或者在设置中关闭生成bak文件,或者换一个编辑器 https://play.google.com/store/apps/details?id=in.mfile
### 2、遇到国内版锁屏后连接自动断开的问题请尝试使用针对国内版开发的版本
[https://blog.minamigo.moe/archives/747](https://blog.minamigo.moe/archives/747)

> 请用0.4.7或以上版本

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.kooritea.fcmfix"
minSdkVersion 29
targetSdkVersion 30
versionCode 27
versionName "0.4.7"
versionCode 28
versionName "0.4.8"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/kooritea/fcmfix/xposed/BroadcastFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class BroadcastFix extends XposedModule {

public BroadcastFix(XC_LoadPackage.LoadPackageParam loadPackageParam) {
super(loadPackageParam);
}

@Override
protected void onCanReadConfig() {
this.startHook();
}

Expand Down Expand Up @@ -41,6 +45,12 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) throws Throwa
}else if(Build.VERSION.SDK_INT == 31){
intent_args_index = 3;
appOp_args_index = 11;
}else if(Build.VERSION.SDK_INT == 32){
intent_args_index = 3;
appOp_args_index = 11;
}else{
sendUpdateNotification("未适配的安卓版本: " + Build.VERSION.SDK_INT, "fcmfix将不会工作");
return;
}
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())){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
package com.kooritea.fcmfix.xposed;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.SystemClock;
import androidx.core.app.NotificationCompat;
import com.kooritea.fcmfix.R;
import com.kooritea.fcmfix.util.XposedUtils;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static android.content.Context.NOTIFICATION_SERVICE;

public class ReconnectManagerFix extends XposedModule {

Expand Down Expand Up @@ -202,44 +191,6 @@ public void run() {
});
}

private void sendUpdateNotification(String title) {
sendUpdateNotification(title,null);
}

private void sendUpdateNotification(String title, String content) {
printLog(title);
title = "[fcmfix]" + title;
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
this.createFcmfixChannel(notificationManager);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "fcmfix");
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setAutoCancel(true);
builder.setContentTitle(title);
if(content != null){
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(content));
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.google.android.gms","com.google.android.gms.gcm.GcmDiagnostics");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
builder.setContentIntent(PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_IMMUTABLE));
notificationManager.notify((int) System.currentTimeMillis(), builder.build());
}

private void createFcmfixChannel(NotificationManager notificationManager) {
List<NotificationChannel> channelList = notificationManager.getNotificationChannels();
for (NotificationChannel item : channelList) {
if (item.getId() == "fcmfix") {
item.setName("fcmfix");
item.setImportance(NotificationManager.IMPORTANCE_HIGH);
item.setDescription("fcmfix");
return;
}
}
NotificationChannel channel = new NotificationChannel("fcmfix", "fcmfix", NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("[xposed] fcmfix更新通知");
notificationManager.createNotificationChannel(channel);
}

private BroadcastReceiver logBroadcastReceive = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
package com.kooritea.fcmfix.xposed;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.UserManager;

import androidx.core.app.NotificationCompat;

import com.kooritea.fcmfix.R;
import com.kooritea.fcmfix.util.ContentProviderHelper;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static android.content.Context.NOTIFICATION_SERVICE;

public abstract class XposedModule {

protected XC_LoadPackage.LoadPackageParam loadPackageParam;
Expand Down Expand Up @@ -159,4 +167,38 @@ public void onReceive(Context context, Intent intent) {
}

}

protected void sendUpdateNotification(String title) {
sendUpdateNotification(title,null);
}

protected void sendUpdateNotification(String title, String content) {
printLog(title);
title = "[fcmfix]" + title;
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
this.createFcmfixChannel(notificationManager);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "fcmfix");
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setAutoCancel(true);
builder.setContentTitle(title);
if(content != null){
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(content));
}
notificationManager.notify((int) System.currentTimeMillis(), builder.build());
}

protected void createFcmfixChannel(NotificationManager notificationManager) {
List<NotificationChannel> channelList = notificationManager.getNotificationChannels();
for (NotificationChannel item : channelList) {
if (item.getId() == "fcmfix") {
item.setName("fcmfix");
item.setImportance(NotificationManager.IMPORTANCE_HIGH);
item.setDescription("fcmfix");
return;
}
}
NotificationChannel channel = new NotificationChannel("fcmfix", "fcmfix", NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("[xposed] fcmfix更新通知");
notificationManager.createNotificationChannel(channel);
}
}

0 comments on commit 428811e

Please sign in to comment.