From 4a54581150dbad249dc9602ec3faa750841fe449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=83=E6=9F=92=E6=9F=92?= Date: Tue, 15 Oct 2024 15:05:41 +0800 Subject: [PATCH] fix: AllowManageAllNotifications hook failed (Android 14-Android 15) --- .../systemui/AllowManageAllNotifications.java | 59 ++++++++++++------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/AllowManageAllNotifications.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/AllowManageAllNotifications.java index 1f9a4771f3..fb764d4042 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/AllowManageAllNotifications.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/AllowManageAllNotifications.java @@ -1,23 +1,25 @@ /* - * This file is part of HyperCeiler. + * This file is part of HyperCeiler. - * HyperCeiler is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License. + * HyperCeiler is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . - * Copyright (C) 2023-2024 HyperCeiler Contributions -*/ + * Copyright (C) 2023-2024 HyperCeiler Contributions + */ package com.sevtinge.hyperceiler.module.hook.systemui; +import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion; + import android.content.Context; import com.sevtinge.hyperceiler.module.base.BaseHook; @@ -30,23 +32,36 @@ public class AllowManageAllNotifications extends BaseHook { @Override public void init() throws NoSuchMethodException { + Class mNotifyManagerCls = isMoreAndroidVersion(35) ? + findClassIfExists("com.miui.systemui.notification.NotificationSettingsManager", lpparam.classLoader) : + findClassIfExists("com.android.systemui.statusbar.notification.NotificationSettingsManager", lpparam.classLoader); + XposedHelpers.setStaticBooleanField(mNotifyManagerCls, "USE_WHITE_LISTS", false); - Class NotifyManagerCls = findClassIfExists("com.android.systemui.statusbar.notification.NotificationSettingsManager"); - XposedHelpers.setStaticBooleanField(NotifyManagerCls, "USE_WHITE_LISTS", false); - findAndHookMethod("com.miui.systemui.NotificationCloudData$Companion", "getFloatBlacklist", Context.class, new MethodHook() { - @Override - protected void before(MethodHookParam param) throws Throwable { - param.setResult(new ArrayList()); - } - }); + try { + // Android 14 中期开始变化为 getCloudDataString 方法 + findAndHookMethod("com.miui.systemui.NotificationCloudData$Companion", "getCloudDataString", Context.class, String.class, String.class, new MethodHook() { + @Override + protected void before(MethodHookParam param) { + param.setResult(new ArrayList()); + } + }); + } catch (Throwable t) { + findAndHookMethod("com.miui.systemui.NotificationCloudData$Companion", "getFloatBlacklist", Context.class, new MethodHook() { + @Override + protected void before(MethodHookParam param) { + param.setResult(new ArrayList()); + } + }); + } + // miui-framework.jar hookAllMethods("miui.util.NotificationFilterHelper", "isNotificationForcedEnabled", MethodHook.returnConstant(false)); findAndHookMethod("miui.util.NotificationFilterHelper", "isNotificationForcedFor", Context.class, String.class, MethodHook.returnConstant(false)); findAndHookMethod("miui.util.NotificationFilterHelper", "canSystemNotificationBeBlocked", String.class, MethodHook.returnConstant(true)); findAndHookMethod("miui.util.NotificationFilterHelper", "containNonBlockableChannel", String.class, MethodHook.returnConstant(false)); findAndHookMethod("miui.util.NotificationFilterHelper", "getNotificationForcedEnabledList", new MethodHook() { @Override - protected void before(MethodHookParam param) throws Throwable { + protected void before(MethodHookParam param) { param.setResult(new HashSet()); } });