Skip to content

Commit

Permalink
fix: AllowManageAllNotifications hook failed (Android 14-Android 15)
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Oct 15, 2024
1 parent 97e5fe3 commit 4a54581
Showing 1 changed file with 37 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* 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;
Expand All @@ -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<String>());
}
});
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<String>());
}
});
} catch (Throwable t) {
findAndHookMethod("com.miui.systemui.NotificationCloudData$Companion", "getFloatBlacklist", Context.class, new MethodHook() {
@Override
protected void before(MethodHookParam param) {
param.setResult(new ArrayList<String>());
}
});
}

// 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<String>());
}
});
Expand Down

0 comments on commit 4a54581

Please sign in to comment.