|
| 1 | +/* |
| 2 | + * This file is part of HyperCeiler. |
| 3 | +
|
| 4 | + * HyperCeiler is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU Affero General Public License as |
| 6 | + * published by the Free Software Foundation, either version 3 of the |
| 7 | + * License. |
| 8 | +
|
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU Affero General Public License for more details. |
| 13 | +
|
| 14 | + * You should have received a copy of the GNU Affero General Public License |
| 15 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | +
|
| 17 | + * Copyright (C) 2023-2024 HyperCeiler Contributions |
| 18 | + */ |
| 19 | +package com.sevtinge.hyperceiler.module.hook.systemui.lockscreen; |
| 20 | + |
| 21 | +import android.content.Context; |
| 22 | +import android.widget.Toast; |
| 23 | + |
| 24 | +import com.sevtinge.hyperceiler.module.base.BaseHook; |
| 25 | + |
| 26 | +import java.util.Objects; |
| 27 | + |
| 28 | +public class DisableUnlockByBleToast extends BaseHook { |
| 29 | + @Override |
| 30 | + public void init() throws NoSuchMethodException { |
| 31 | + findAndHookMethod("com.android.keyguard.KeyguardSecurityContainerController$2", "dismiss", boolean.class, int.class, boolean.class, "com.android.keyguard.KeyguardSecurityModel$SecurityMode", new MethodHook() { |
| 32 | + @Override |
| 33 | + protected void before(MethodHookParam param) throws Throwable { |
| 34 | + findAndHookMethod(Toast.class, "makeText", Context.class, int.class, int.class, new MethodHook() { |
| 35 | + @Override |
| 36 | + protected void before(MethodHookParam param) throws Throwable { |
| 37 | + String resName = ((Context) param.args[0]).getResources().getResourceName((int) param.args[1]); |
| 38 | + logD(TAG, lpparam.packageName, resName); |
| 39 | + if (Objects.equals(resName, "com.android.systemui:string/miui_keyguard_ble_unlock_succeed_msg")) |
| 40 | + findAndHookMethod(Toast.class, "show", new MethodHook() { |
| 41 | + @Override |
| 42 | + protected void before(MethodHookParam param) throws Throwable { |
| 43 | + param.setResult(null); |
| 44 | + } |
| 45 | + }); |
| 46 | + } |
| 47 | + }); |
| 48 | + } |
| 49 | + }); |
| 50 | + findAndHookMethod("com.android.keyguard.MiuiBleUnlockHelper", "tryUnlockByBle", new MethodHook(){ |
| 51 | + @Override |
| 52 | + protected void before(MethodHookParam param) throws Throwable { |
| 53 | + findAndHookMethod(Toast.class, "makeText", Context.class, int.class, int.class, new MethodHook(){ |
| 54 | + @Override |
| 55 | + protected void before(MethodHookParam param) throws Throwable { |
| 56 | + String resName = ((Context) param.args[0]).getResources().getResourceName((int) param.args[1]); |
| 57 | + logD(TAG, lpparam.packageName, resName); |
| 58 | + if (Objects.equals(resName, "com.android.systemui:string/miui_keyguard_ble_unlock_succeed_msg")) |
| 59 | + findAndHookMethod(Toast.class, "show", new MethodHook() { |
| 60 | + @Override |
| 61 | + protected void before(MethodHookParam param) throws Throwable { |
| 62 | + param.setResult(null); |
| 63 | + } |
| 64 | + }); |
| 65 | + } |
| 66 | + }); |
| 67 | + } |
| 68 | + }); |
| 69 | + |
| 70 | + } |
| 71 | +} |
0 commit comments