From 7c0eb755cabce9e19291945e8e356d60f8112f4b Mon Sep 17 00:00:00 2001 From: mkx173 Date: Wed, 13 Mar 2024 01:27:08 -0700 Subject: [PATCH] feat: disable notification status check --- .../java/gm/tieba/tabswitch/XposedInit.java | 4 ++- .../tieba/tabswitch/hooker/TSPreference.java | 1 + .../hooker/auto/NotificationDetect.java | 26 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/gm/tieba/tabswitch/hooker/auto/NotificationDetect.java diff --git a/app/src/main/java/gm/tieba/tabswitch/XposedInit.java b/app/src/main/java/gm/tieba/tabswitch/XposedInit.java index b0cfcead..24208703 100644 --- a/app/src/main/java/gm/tieba/tabswitch/XposedInit.java +++ b/app/src/main/java/gm/tieba/tabswitch/XposedInit.java @@ -36,6 +36,7 @@ import gm.tieba.tabswitch.hooker.auto.AutoSign; import gm.tieba.tabswitch.hooker.auto.FrsTab; import gm.tieba.tabswitch.hooker.auto.MsgCenterTab; +import gm.tieba.tabswitch.hooker.auto.NotificationDetect; import gm.tieba.tabswitch.hooker.auto.OpenSign; import gm.tieba.tabswitch.hooker.auto.OriginSrc; import gm.tieba.tabswitch.hooker.deobfuscation.DeobfuscationHelper; @@ -150,7 +151,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { new StackTrace(), new RemoveUpdate(), new FoldTopCardView(), - new MsgCenterTab() + new MsgCenterTab(), + new NotificationDetect() ); final var matchers = new ArrayList(hookers.size() + 2); matchers.add(new TbDialog()); diff --git a/app/src/main/java/gm/tieba/tabswitch/hooker/TSPreference.java b/app/src/main/java/gm/tieba/tabswitch/hooker/TSPreference.java index 03a97757..7bd8b667 100644 --- a/app/src/main/java/gm/tieba/tabswitch/hooker/TSPreference.java +++ b/app/src/main/java/gm/tieba/tabswitch/hooker/TSPreference.java @@ -239,6 +239,7 @@ private LinearLayout createRootPreference(final Activity activity) { preferenceLayout.addView(TSPreferenceHelper.createTextView(isPurgeEnabled ? "奇怪怪" : "其它")); preferenceLayout.addView(new SwitchButtonHolder(activity, "禁用帖子手势", "forbid_gesture", SwitchButtonHolder.TYPE_SWITCH)); preferenceLayout.addView(new SwitchButtonHolder(activity, "用赞踩差数代替赞数", "agree_num", SwitchButtonHolder.TYPE_SWITCH)); + preferenceLayout.addView(new SwitchButtonHolder(activity, "禁止检测通知开启状态", "notification_detect", SwitchButtonHolder.TYPE_SWITCH)); preferenceLayout.addView(TSPreferenceHelper.createButton(TRACE, "希望有一天不再需要贴吧TS", true, v -> { final Intent intent = new Intent().setClassName(activity, PROXY_ACTIVITY); intent.putExtra("proxyPage", TRACE); diff --git a/app/src/main/java/gm/tieba/tabswitch/hooker/auto/NotificationDetect.java b/app/src/main/java/gm/tieba/tabswitch/hooker/auto/NotificationDetect.java new file mode 100644 index 00000000..5e9bcb28 --- /dev/null +++ b/app/src/main/java/gm/tieba/tabswitch/hooker/auto/NotificationDetect.java @@ -0,0 +1,26 @@ +package gm.tieba.tabswitch.hooker.auto; + +import androidx.annotation.NonNull; + +import de.robv.android.xposed.XC_MethodReplacement; +import de.robv.android.xposed.XposedHelpers; +import gm.tieba.tabswitch.XposedContext; +import gm.tieba.tabswitch.hooker.IHooker; + +public class NotificationDetect extends XposedContext implements IHooker { + @NonNull + @Override + public String key() { + return "notification_detect"; + } + + public void hook() throws Throwable { + // 禁止检测通知开启状态 + XposedHelpers.findAndHookMethod( + "androidx.core.app.NotificationManagerCompat", + sClassLoader, + "areNotificationsEnabled", + XC_MethodReplacement.returnConstant(true) + ); + } +}