From e7af6cac83f333b7c4db5391d13b366663a437bf Mon Sep 17 00:00:00 2001 From: kooritea Date: Fri, 18 Sep 2020 22:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=82=B9=E5=87=BB=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E6=A1=86=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/kooritea/fcmfix/MainActivity.java | 8 ++++++++ app/src/main/java/com/kooritea/fcmfix/XposedMain.java | 2 +- .../kooritea/fcmfix/xposed/ReconnectManagerFix.java | 10 +++++++++- .../java/com/kooritea/fcmfix/xposed/XposedModule.java | 7 ++++++- app/src/main/res/layout/app_item.xml | 2 ++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/kooritea/fcmfix/MainActivity.java b/app/src/main/java/com/kooritea/fcmfix/MainActivity.java index 279f5b7..e00c0ff 100644 --- a/app/src/main/java/com/kooritea/fcmfix/MainActivity.java +++ b/app/src/main/java/com/kooritea/fcmfix/MainActivity.java @@ -161,7 +161,15 @@ public void onItemClick(AdapterView arg0, View arg1, int position, long arg3) appListAdapter.notifyDataSetChanged(); } }); + this.initHeartbeatInterval(); + } + private void initHeartbeatInterval(){ + if(this.sharedPreferences.getString("heartbeatInterval","").equals("")){ + this.sharedPreferencesEditor.putString("heartbeatInterval","117000"); + this.sharedPreferencesEditor.commit(); + this.setWorldReadable(); + } } private void addAppInAllowList(String packageName){ diff --git a/app/src/main/java/com/kooritea/fcmfix/XposedMain.java b/app/src/main/java/com/kooritea/fcmfix/XposedMain.java index bc19f94..c569605 100644 --- a/app/src/main/java/com/kooritea/fcmfix/XposedMain.java +++ b/app/src/main/java/com/kooritea/fcmfix/XposedMain.java @@ -11,7 +11,7 @@ public class XposedMain implements IXposedHookLoadPackage { public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { if(loadPackageParam.packageName.equals("android")){ - XposedBridge.log("[fcmfix] com.android.server.am.ActivityManagerService"); + XposedBridge.log("[fcmfix] start hook com.android.server.am.ActivityManagerService"); new BroadcastFix(loadPackageParam); } if(loadPackageParam.packageName.equals("com.google.android.gms")){ diff --git a/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java b/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java index 1ee42af..c35a3d8 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/ReconnectManagerFix.java @@ -7,6 +7,7 @@ import android.content.IntentFilter; import android.os.SystemClock; +import java.util.HashSet; import java.util.Timer; import java.util.TimerTask; @@ -30,7 +31,14 @@ protected void beforeHookedMethod(final MethodHookParam param) throws Throwable // 修改心跳间隔 Intent intent = (Intent) XposedHelpers.getObjectField(param.thisObject,"e"); if("com.google.android.gms.gcm.HEARTBEAT_ALARM".equals(intent.getAction())){ - param.args[0] = 117000L; + String heartbeatIntervalString = getXSharedPreferences().getString("heartbeatInterval",""); + if(heartbeatIntervalString.equals("")){ + heartbeatIntervalString = "117000"; + } + long heartbeatInterval = new Long(heartbeatIntervalString).longValue(); + if(heartbeatInterval>5000L){ + param.args[0] = heartbeatInterval; + } } } @Override 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 3e3bf1b..acc06f7 100644 --- a/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java +++ b/app/src/main/java/com/kooritea/fcmfix/xposed/XposedModule.java @@ -29,6 +29,11 @@ protected XSharedPreferences getXSharedPreferences(){ protected void printLog(String text){ Intent log = new Intent("com.kooritea.fcmfix.log"); log.putExtra("text",text); - AndroidAppHelper.currentApplication().getApplicationContext().sendBroadcast(log); + try{ + AndroidAppHelper.currentApplication().getApplicationContext().sendBroadcast(log); + }catch (Exception e){ + e.printStackTrace();; + } + } } diff --git a/app/src/main/res/layout/app_item.xml b/app/src/main/res/layout/app_item.xml index 08ec9f4..7a9b5d7 100644 --- a/app/src/main/res/layout/app_item.xml +++ b/app/src/main/res/layout/app_item.xml @@ -60,6 +60,8 @@ android:layout_height="match_parent" android:gravity="center" android:focusable="false" + android:clickable="false" + android:focusableInTouchMode="false" android:layoutDirection="rtl" /> \ No newline at end of file