跳到主要内容
KernelSU 模块

HyperOS Accessibility Fix

不可变 Release 已同步

Stop HyperOS from randomly disabling accessibillity services

介绍

hyperos-accessibility-fix

Stop HyperOS from randomly disabling accessibility services

What's happening

On Android, when an accessibility app is force-stopped via ActivityManager, the accessibility permission of the app is stripped.

boolean onPackagesForceStoppedLocked(String[] packages, AccessibilityUserState userState) {
    final Set<String> packageSet = Set.of(packages);
    
    final ArrayList<ComponentName> continuousServices = userState.mInstalledServices.stream()
            .filter(s -> (s.flags & FLAG_REQUEST_ACCESSIBILITY_BUTTON) == FLAG_REQUEST_ACCESSIBILITY_BUTTON)
            .map(AccessibilityServiceInfo::getComponentName)
            .filter(name -> packageSet.contains(name.getPackageName()))
            .collect(Collectors.toCollection(ArrayList::new));

    final boolean enabledServicesChanged = userState.mEnabledServices.removeIf(comp -> {
        if (packageSet.contains(comp.getPackageName())) {
            userState.getBindingServicesLocked().remove(comp);
            userState.getCrashedServicesLocked().remove(comp);
            return true;
        }
        return false;
    });

    if (enabledServicesChanged) {
        persistComponentNamesToSettingLocked(
            Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
            userState.mEnabledServices, userState.mUserId);
    }
}
    ...

And HyperOS is hardcoded to trigger a force-stop (not a kill) on certain events like when the user is entering Ultra Battery Saver (LockScreenClean), and others:

<ultra battery saver was enabled>
I ActivityManager: Force stopping com.urbandroid.lux appid=10415 user=0: LockScreenClean
D ActivityManager: Force removing proc 8855:com.urbandroid.lux:background/u0a415 (com.urbandroid.lux:background/10415)

How it works

  • This module installs a background script that monitors the logcat stream for accessibility update events with minimal system overhead.

  • On boot, it checks what accessibility services are enabled, and writes them to a11y_watchlist.txt. It also listens for signs of manual configuration changes (done by user in settings) and updates the watchlist automatically.

  • When an accessibility update event is detected, the background script first checks if the device is in the Settings app (as mentioned above). If not, the background script performs a verification of enabled accessibility services against the local a11y_watchlist.txt. And if the list doesn't match up, the changes are reverted instantly.

  • This background script also runs at OOM score -800 to prevent LMKD from killing it in the background. And if it still gets killed under memory pressure, another (monitor) script (that runs at -900) is running in background to restart it (provided it didn't get killed aswell lol)

Note

  • When Ultra Battery Saver is turned on, the accessibility services will still keep running in the background
  • Force stopping an app via App Manager will not (permanently) remove it's accessibility permission anymore. So be careful at what you enable
  • You may ask why did i use background scripts and not zygisk/xposed. That's because these two frameworks cause a range of problems for me, so i decided to follow this no-requirement approach instead.

How do i build this from source?

Just run the build script at the root of the repo. The minimum requirement for this is ~python3.10:

python build.py
# Created /home/user/module/build/hyperos-accessibility-fix-x.x.x.zip
# Created /home/user/module/build/hyperos-accessibility-fix.zip (for permalink purposes)

Installation:

Requirements

  • HyperOS 1.0+ (or any A14+ system)
  • KernelSU 1.0.2+ or Magisk 28.0+

历史版本

1.0.6

最新

版本代码 106 1.0.6

下载

Changelog:

  • Moved the missing command check higher and added more commands to prevent silent errors
  • Minor changes to the README
  • Added module.yaml for the KernelSU development portal

Installation:

Download hint:

✅ hyperos-accessibility-fix-1.0.6.zip ✅
❌ xx source code.zip ❌


Donate GitHub Releases SourceForge Downloads

文件 1

hyperos-accessibility-fix-1.0.6.zip 23.2 KiB

SHA-256 6dd6d0dd02ada973ae51845cd1abbea985e531bad7baf2ff6fab64889dadfce1 · Attestation

透明度

Tag
1.0.6 不可变 Release
Tag commit
f9f92a4ffaf4
内容 commit
9fc47bd22593
SHA-256
6dd6d0dd02ada973ae51845cd1abbea985e531bad7baf2ff6fab64889dadfce1
最近同步到变更

自行复核

KernelSU 模块不对模块签名,也不审计模块代码。SHA-256 只证明下载内容与本索引一致。可使用 GitHub CLI 自行复核:

gh release verify 1.0.6 -R chkndrp/hyperos-accessibility-fix
gh release verify-asset 1.0.6 hyperos-accessibility-fix-1.0.6.zip -R chkndrp/hyperos-accessibility-fix