Skip to content

Commit da62601

Browse files
committed
feat: system ui - lock screen - Disable show unlock by bluetooth toast
1 parent 30d6e32 commit da62601

5 files changed

Lines changed: 80 additions & 0 deletions

File tree

app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import com.sevtinge.hyperceiler.module.hook.systemui.lockscreen.BlurButton;
8484
import com.sevtinge.hyperceiler.module.hook.systemui.lockscreen.ChargingCVP;
8585
import com.sevtinge.hyperceiler.module.hook.systemui.lockscreen.ClockDisplaySeconds;
86+
import com.sevtinge.hyperceiler.module.hook.systemui.lockscreen.DisableUnlockByBleToast;
8687
import com.sevtinge.hyperceiler.module.hook.systemui.lockscreen.ForceClockUseSystemFontsHook;
8788
import com.sevtinge.hyperceiler.module.hook.systemui.lockscreen.HideLockScreenHint;
8889
import com.sevtinge.hyperceiler.module.hook.systemui.lockscreen.HideLockScreenStatusBar;
@@ -349,6 +350,7 @@ public void handleLoadPackage() {
349350
initHook(HideLockScreenStatusBar.INSTANCE, mPrefsMap.getBoolean("system_ui_lock_screen_hide_status_bar"));
350351
initHook(new BlockEditor(), mPrefsMap.getBoolean("system_ui_lock_screen_block_editor"));
351352
initHook(new AllowThirdLockScreenUseFace(), mPrefsMap.getBoolean("system_ui_lock_screen_allow_third_face"));
353+
initHook(new DisableUnlockByBleToast(), mPrefsMap.getBoolean("system_ui_lock_screen_disable_unlock_by_ble_toast"));
352354

353355
if (!isAndroidVersion(30)) {
354356
initHook(AddBlurEffectToLockScreen.INSTANCE, mPrefsMap.getBoolean("system_ui_lock_screen_blur_button"));
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
}

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@
588588
<string name="system_ui_lock_screen_block_editor_title">禁用长按进入锁屏编辑</string>
589589
<string name="system_ui_lock_screen_allow_third_face">允许三方锁屏界面唤醒系统验证识别</string>
590590
<string name="system_ui_lock_screen_allow_third_face_desc">允许在第三方应用显示的锁屏界面时,正常使用人脸及指纹识别</string>
591+
<string name="system_ui_lock_screen_disable_unlock_by_ble_toast">禁止显示 \"已通过蓝牙设备解锁\" Toast</string>
591592

592593
<string name="system_ui_navigation_title">导航栏</string>
593594
<string name="system_ui_navigation_handle_title">手势提示线</string>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@
581581
<string name="system_ui_lock_screen_block_editor_title">Disable long press to access lock screen editing</string>
582582
<string name="system_ui_lock_screen_allow_third_face">Allows the system to be woken up to verify recognition on a third-party lock screen</string>
583583
<string name="system_ui_lock_screen_allow_third_face_desc">Allows face and fingerprint recognition to be used normally on the lock screen displayed by third-party apps</string>
584+
<string name="system_ui_lock_screen_disable_unlock_by_ble_toast">Disable show unlock by bluetooth toast</string>
584585
<string name="system_ui_navigation_title">Navigation</string>
585586
<string name="system_ui_navigation_handle_title">Handle line</string>
586587
<string name="system_ui_hide_navigation_bar">Hide Navigation Bar</string>

app/src/main/res/xml/system_ui_lock_screen.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
android:summary="@string/system_ui_lock_screen_password_free_desc"
111111
android:title="@string/system_ui_lock_screen_password_free" />
112112

113+
<SwitchPreference
114+
android:defaultValue="false"
115+
android:key="prefs_key_system_ui_lock_screen_disable_unlock_by_ble_toast"
116+
android:title="@string/system_ui_lock_screen_disable_unlock_by_ble_toast" />
117+
113118
</PreferenceCategory>
114119

115120
<PreferenceCategory android:title="@string/system_ui_other_title">

0 commit comments

Comments
 (0)