Skip to content

Commit 47f16b5

Browse files
committed
fix: 修复增强屏蔽对某些手势未拦截的问题
- 本次由于需要对系统桌面的弹窗和手势拦截需要处理,所以要多勾选一个 “系统桌面” 作用域 - 本次更新需要重启才能生效
1 parent ffc4047 commit 47f16b5

17 files changed

Lines changed: 666 additions & 314 deletions

File tree

library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePad.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import com.sevtinge.hyperceiler.libhook.rules.home.recent.CardTextColor;
6060
import com.sevtinge.hyperceiler.libhook.rules.home.recent.CardTextSize;
6161
import com.sevtinge.hyperceiler.libhook.rules.home.recent.FreeformCardBackgroundColor;
62+
import com.sevtinge.hyperceiler.libhook.rules.home.recent.GuidedAccessHome;
6263
import com.sevtinge.hyperceiler.libhook.rules.home.recent.HideRecentCard;
6364
import com.sevtinge.hyperceiler.libhook.rules.home.recent.HideStatusBarWhenEnterRecent;
6465
import com.sevtinge.hyperceiler.libhook.rules.home.recent.MemInfoShow;
@@ -166,6 +167,9 @@ public void onPackageLoaded() {
166167
initHook(CardTextSize.INSTANCE, PrefsBridge.getInt("home_recent_text_size", -1) != -1);
167168
initHook(CardTextColor.INSTANCE, PrefsBridge.getInt("home_recent_text_color", -1) != -1);
168169
initHook(FreeformCardBackgroundColor.INSTANCE, true);
170+
initHook(new GuidedAccessHome(),
171+
PrefsBridge.getBoolean("system_framework_guided_access")
172+
&& PrefsBridge.getBoolean("system_framework_guided_access_status"));
169173

170174
// 图标
171175
initHook(new IconSize(), PrefsBridge.getBoolean("home_title_icon_size_enable"));

library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/app/Home/os3/HomePhone.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import com.sevtinge.hyperceiler.libhook.rules.home.recent.CardTextColor;
6464
import com.sevtinge.hyperceiler.libhook.rules.home.recent.CardTextSize;
6565
import com.sevtinge.hyperceiler.libhook.rules.home.recent.FreeformCardBackgroundColor;
66+
import com.sevtinge.hyperceiler.libhook.rules.home.recent.GuidedAccessHome;
6667
import com.sevtinge.hyperceiler.libhook.rules.home.recent.HideRecentCard;
6768
import com.sevtinge.hyperceiler.libhook.rules.home.recent.HideStatusBarWhenEnterRecent;
6869
import com.sevtinge.hyperceiler.libhook.rules.home.recent.RealMemory;
@@ -179,7 +180,9 @@ public void onPackageLoaded() {
179180
initHook(CardTextSize.INSTANCE, PrefsBridge.getInt("home_recent_text_size", -1) != -1);
180181
initHook(CardTextColor.INSTANCE, PrefsBridge.getInt("home_recent_text_color", -1) != -1);
181182
initHook(FreeformCardBackgroundColor.INSTANCE, true);
182-
183+
initHook(new GuidedAccessHome(),
184+
PrefsBridge.getBoolean("system_framework_guided_access")
185+
&& PrefsBridge.getBoolean("system_framework_guided_access_status"));
183186
// 图标
184187
initHook(new IconSize(), PrefsBridge.getBoolean("home_title_icon_size_enable"));
185188
initHook(BigIconCorner.INSTANCE, PrefsBridge.getBoolean("home_title_big_icon_corner"));
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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-2026 HyperCeiler Contributions
18+
*/
19+
package com.sevtinge.hyperceiler.libhook.rules.home.recent;
20+
21+
import android.content.Context;
22+
import android.provider.Settings;
23+
import android.view.MotionEvent;
24+
import android.view.View;
25+
26+
import com.sevtinge.hyperceiler.common.log.XposedLog;
27+
import com.sevtinge.hyperceiler.common.utils.PrefsBridge;
28+
import com.sevtinge.hyperceiler.libhook.base.BaseHook;
29+
30+
public class GuidedAccessHome extends BaseHook {
31+
private static final String SETTING_KEY_LOCK_APP = "key_lock_app";
32+
33+
@Override
34+
public void init() {
35+
hookPointerEvent();
36+
hookIsMistakeTouch();
37+
hookScreenPinTouchResolution();
38+
hookLandscapeOverviewGestureView();
39+
hookScreenPinnedHelperStartDirectly();
40+
hookHomeStartScreenPinningDirectly();
41+
}
42+
43+
private void hookPointerEvent() {
44+
findAndChainMethod("com.miui.home.recents.NavStubView",
45+
"onPointerEvent",
46+
chain -> {
47+
Context context = resolveContext(chain.getThisObject());
48+
if (getLockApp(context) == -1) return chain.proceed();
49+
return false;
50+
},
51+
MotionEvent.class
52+
);
53+
}
54+
55+
private void hookIsMistakeTouch() {
56+
findAndChainMethod("com.miui.home.recents.NavStubView", "isMistakeTouch", chain -> {
57+
Context context = resolveContext(chain.getThisObject());
58+
if (getLockApp(context) == -1) return chain.proceed();
59+
return true;
60+
});
61+
}
62+
63+
private void hookScreenPinTouchResolution() {
64+
try {
65+
findAndChainMethod("com.miui.home.recents.NavStubView",
66+
"screenPinTouchResolution",
67+
chain -> {
68+
Context context = resolveContext(chain.getThisObject());
69+
if (getLockApp(context) == -1) return chain.proceed();
70+
return null;
71+
},
72+
MotionEvent.class
73+
);
74+
} catch (Throwable e) {
75+
// Pad variant may not include this method; keep other hooks alive.
76+
}
77+
}
78+
79+
private void hookLandscapeOverviewGestureView() {
80+
findAndChainMethod("com.miui.home.recents.views.RecentsContainer",
81+
"showLandscapeOverviewGestureView",
82+
chain -> {
83+
Context context = resolveContext(chain.getThisObject());
84+
if (getLockApp(context) == -1) return chain.proceed();
85+
return null;
86+
},
87+
boolean.class
88+
);
89+
}
90+
91+
private void hookHomeStartScreenPinningDirectly() {
92+
findAndChainMethod("com.miui.home.recents.SystemUiProxyWrapper",
93+
"startScreenPinning",
94+
chain -> {
95+
if (!PrefsBridge.getBoolean("system_framework_guided_access", false)) {
96+
return chain.proceed();
97+
}
98+
int taskId = (int) chain.getArg(0);
99+
if (taskId < 0) return chain.proceed();
100+
try {
101+
Class<?> activityTaskManager = findClassIfExists("android.app.ActivityTaskManager");
102+
if (activityTaskManager == null) return chain.proceed();
103+
Object service = callStaticMethod(activityTaskManager, "getService");
104+
callMethod(service, "startSystemLockTaskMode", taskId);
105+
return true;
106+
} catch (Throwable e) {
107+
XposedLog.w(TAG, "home direct startSystemLockTaskMode E: " + e);
108+
return chain.proceed();
109+
}
110+
},
111+
int.class
112+
);
113+
}
114+
115+
private void hookScreenPinnedHelperStartDirectly() {
116+
findAndChainMethod("com.miui.home.recents.ScreenPinnedHelper",
117+
"startScreenPinning",
118+
chain -> {
119+
if (!PrefsBridge.getBoolean("system_framework_guided_access", false)) {
120+
return chain.proceed();
121+
}
122+
int taskId = (int) chain.getArg(0);
123+
if (taskId < 0) return chain.proceed();
124+
try {
125+
Class<?> activityTaskManager = findClassIfExists("android.app.ActivityTaskManager");
126+
if (activityTaskManager == null) return chain.proceed();
127+
Object service = callStaticMethod(activityTaskManager, "getService");
128+
callMethod(service, "startSystemLockTaskMode", taskId);
129+
XposedLog.d(TAG, "home helper direct startSystemLockTaskMode taskId=" + taskId);
130+
return null;
131+
} catch (Throwable e) {
132+
XposedLog.w(TAG, "home helper direct startSystemLockTaskMode E: " + e);
133+
return chain.proceed();
134+
}
135+
},
136+
int.class
137+
);
138+
}
139+
140+
private Context resolveContext(Object target) {
141+
if (target instanceof Context) return (Context) target;
142+
if (target instanceof View) return ((View) target).getContext();
143+
if (target == null) return null;
144+
try {
145+
Object context = getObjectField(target, "mContext");
146+
if (context instanceof Context) return (Context) context;
147+
} catch (Throwable ignored) {
148+
}
149+
return null;
150+
}
151+
152+
private int getLockApp(Context context) {
153+
if (context == null) return -1;
154+
try {
155+
return Settings.Global.getInt(context.getContentResolver(), SETTING_KEY_LOCK_APP);
156+
} catch (Throwable ignored) {
157+
return -1;
158+
}
159+
}
160+
}

0 commit comments

Comments
 (0)