|
18 | 18 | */ |
19 | 19 | package com.sevtinge.hyperceiler.libhook.rules.systemui.other; |
20 | 20 |
|
| 21 | +import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.Miui.isPad; |
| 22 | + |
21 | 23 | import android.content.Context; |
22 | 24 | import android.database.ContentObserver; |
23 | 25 | import android.os.Handler; |
@@ -105,6 +107,9 @@ public Object intercept(XposedInterface.Chain chain) throws Throwable { |
105 | 107 | hookTaskbarDelegateClass(className); |
106 | 108 | } |
107 | 109 | hookScreenPinningDialogBlock(); |
| 110 | + if (isPad()) { |
| 111 | + hookLauncherProxyStopScreenPinning(); |
| 112 | + } |
108 | 113 | } |
109 | 114 |
|
110 | 115 | private void hookStatusBarWindowControllerClass(String className) { |
@@ -270,6 +275,26 @@ public Object intercept(XposedInterface.Chain chain) throws Throwable { |
270 | 275 | } |
271 | 276 | } |
272 | 277 |
|
| 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 | + |
273 | 298 | private void startSystemLockTaskModeByTaskId(Object callbacks, int taskId) { |
274 | 299 | if (taskId < 0) return; |
275 | 300 | Context context = resolveContext(callbacks); |
@@ -519,6 +544,13 @@ private Context resolveContext(Object target) { |
519 | 544 | if (context instanceof Context) return (Context) context; |
520 | 545 | } catch (Throwable ignored) { |
521 | 546 | } |
| 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 | + } |
522 | 554 | return null; |
523 | 555 | } |
524 | 556 |
|
|
0 commit comments