Skip to content

Commit 102c820

Browse files
committed
fix: fixed an issue where users could still exit Guided Access by long-pressing and swiping up after entering the feature.
1 parent ae4ea25 commit 102c820

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

  • library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/rules/systemui/other

library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/rules/systemui/other/UiLockApp.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package com.sevtinge.hyperceiler.libhook.rules.systemui.other;
2020

21+
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.Miui.isPad;
22+
2123
import android.content.Context;
2224
import android.database.ContentObserver;
2325
import android.os.Handler;
@@ -105,6 +107,9 @@ public Object intercept(XposedInterface.Chain chain) throws Throwable {
105107
hookTaskbarDelegateClass(className);
106108
}
107109
hookScreenPinningDialogBlock();
110+
if (isPad()) {
111+
hookLauncherProxyStopScreenPinning();
112+
}
108113
}
109114

110115
private void hookStatusBarWindowControllerClass(String className) {
@@ -270,6 +275,26 @@ public Object intercept(XposedInterface.Chain chain) throws Throwable {
270275
}
271276
}
272277

278+
private void hookLauncherProxyStopScreenPinning() {
279+
Class<?> launcherProxyClass = findClassIfExists("com.android.systemui.recents.LauncherProxyService$1");
280+
if (launcherProxyClass == null) return;
281+
282+
chainAllMethods(launcherProxyClass, "verifyCallerAndClearCallingIdentityPostMain", new XposedInterface.Hooker() {
283+
@Override
284+
public Object intercept(XposedInterface.Chain chain) throws Throwable {
285+
Object[] args = chain.getArgs().toArray();
286+
if (args.length > 0 && "stopScreenPinning".equals(args[0])) {
287+
Context context = resolveContext(chain.getThisObject());
288+
if (context != null && getLockApp(context) != -1) {
289+
XposedLog.d(TAG, "block LauncherProxyService.stopScreenPinning while locked");
290+
return null;
291+
}
292+
}
293+
return chain.proceed();
294+
}
295+
});
296+
}
297+
273298
private void startSystemLockTaskModeByTaskId(Object callbacks, int taskId) {
274299
if (taskId < 0) return;
275300
Context context = resolveContext(callbacks);
@@ -519,6 +544,13 @@ private Context resolveContext(Object target) {
519544
if (context instanceof Context) return (Context) context;
520545
} catch (Throwable ignored) {
521546
}
547+
try {
548+
Object outer = getObjectField(target, "this$0");
549+
if (outer != null && outer != target) {
550+
return resolveContext(outer);
551+
}
552+
} catch (Throwable ignored) {
553+
}
522554
return null;
523555
}
524556

0 commit comments

Comments
 (0)