[Android Q&A, Help & Troubleshooting] damianmqr:
Big Update on my A9 Accessibility Service (Automatic Patching)

After a lot of trial and error I was able to create a script that automatically patches any phh-treble GSI system.img to enable refresh mode support. (Thanks to @vbhai for describing how he repackaged his version a few days ago)

What's more, this version utilizes a native daemon and Unix Sockets so it doesn't need Magisk, compilation nor messing with SELinux!

All of the code used is available under: https://github.com/damianmqr/a9_accessibility_service

To run the script on linux and patch your own system.img you simply have to:

Download the system.img you want to use (for example from Andy Yan's GSI builds https://sourceforge.net/projects/andyyan-gsi/files/)

Download and extract a9_system_patcher.zip from https://github.com/damianmqr/a9_accessibility_service/releases/tag/v1.1.1

Go in terminal to the folder containing unzipped files

Run sudo bash patch_system_img.sh /path/to/system.img

system_patched.img will be saved in the same directory, ready to be flashed

Flashing the resulting file is done the same as any other system.img (make sure your bootloader is unlocked!)

reboot to fastbootd using adb reboot fastboot (or any other method)

run fastboot flash system system_patched.img

after that's done, run fastboot -w

run fastboot reboot and give it a few minutes

This version does NOT support disabling HW overlays before boot so you won't see a logo. This shouldn't affect everyday usage too much.

Attached is an image of the new redesign of the service showing that Magisk is not installed, root users can also find this improved UI on the same release page as an APK with filename ending in "-ROOT" if they don't want to switch OS to the patched one.

You can now also pin a tile for managing night/day mode as you would any other tile in the status bar.

Usage:

All the features should work after install without having to set any new permissions.

Single Press E-Ink Button - Refresh Screen

Double Press E-Ink Button - Open EInk Menu with settings for Per-App refresh modes.

I have only tested the script on Lineage 21-td from Andy Yan's GSI builds with Google Apps support built in.

If you don't want to patch yourself, even though it only takes a few moments to run, I attach the patched and xz compressed (use 7zip on windows or unxz on linux to unpack) image I successfully flashed on my device here:

1.09 GB file on MEGA

mega.nz

This release is experimental and I did not have a lot of time to test and only run it on one GSI so I appreciate any feedback I might receive. It works pretty well for me so far.

BUT

Use this software and code at your own risk, I do not take any responsibility for bricked devices or any other issues you may encounter as a result of using them.

EDIT: One issue I identified is that on reboot the hw overlay does not get disabled IF you have setup a screen lock. The ROM works fine once you unlock it for the first time after each reboot, but the display doesn't get updated properly until then so unlocking it after a reboot can be a bit tricky as you have to input the code/pattern without screen updates. Not sure how this could be fixed yet because accessibility service is not allowed to run before the first unlock but I will try to address this issue by next release.

EDIT2: This has been addressed in the latest release