[Samsung Galaxy S10 Themes, Apps, and Mods] Chainfire:
v0.40 is here

So, it was quite a journey to get to this point, and I am sad to report I am not fully satisfied with the results so far. But I have more than exhausted the time I have available for side projects, and I need to focus on work for a while now. There are further gains to be had, I'm sure, possibly someone else will figure it out while I'm doing other things :)

The past weekend I've dedicated entirely to investigating power and CPU use, how AOD functions, etc. A lot has been done on the main code-base to reduce its usage (such as replacing live animations with pre-rendered sprite sheets), but on that front we have reached the point of diminishing returns. There's not much more to be improved in that part of the code. It was a lengthy merry-go-round, as fixing things in one place would break things in another. Here's some technical mumbo jumbo for all y'all to enjoy.

First, there was the move to accessibility services. Should have been using those from the start, but I decided against it because (a) I botched up my first attempt, (b) it is frowned upon by Google (but apparently still grudgingly accepted for now), and (c) it's just unclean. On the other hand, Google has nerfed all the other ways to overlay (in favor of their upcoming "bubbles" contraption), so there's little choice left. This allowed for simplification of part of the codes and getting rid of the fake lockscreen, in favor of piggybacking on AOD. Unfortunately that itself has not brought all the improvements I had hoped. We still need to use the CPU quite a bit, and though we now have the advantage of the screen being in a lower power state and other apps being more restricted from running (both improving battery life), I've still clocked it at 3.5% (worst-case, down from 5.5%) per hour. Obviously this is only when you actually have notifications, otherwise it doesn't any battery at all.

It is my understanding right now (and this may in time prove to only be partially correct, or even completely incorrect), that AOD periodically offloads an image (the background, notifications, clockface without hands) to the display, and a separate process (sidekick? outside of Android? dedicated hardware?) updates the screen with the smaller changes (such as the clock hands). This allows the main CPU to be fully asleep while you still see a clock with a moving second hand on screen, using sub-1%/hour battery power. AOSP has supporting code for this, so it's possible. Additionally, I've experimented with hiding AOD by drawing black on top of it - and the clock's hands remain visible while everything else disappears. Interesting stuff, for sure (stay tuned for more tales of interest).

Overlays apparently are not part of this 'saved' image (I'm sure I saw a reference to how this is done somewhere in AOSP source, but I can't find it anymore, good job bookmarking that), so as the screen goes into its lowest power mode, they disappear. To counter this, we need to keep updating the screen (I had a work-around for this at some point, but it needs further investigation still). Some of you noticed the swirl didn't "time out" as the blinker did, that is because the swirl updates at a higher FPS. That high FPS keeps an internal lock deep in Android active, preventing the lowest power mode from being enabled. I've spent quite(!) some time trying to get to that lock, but to no avail. The only alternative is updating the view layout regularly, which also pokes that lock (after going through a long path of many other functions): this keeps the app's CPU usage down, but I later discovered this triggers high CPU usage in system_server, and so it was a net loss. There have been several instances of me saving 10-20% in one place just to have it pop up somewhere else, just because we don't have a direct path to the code inside Android we actually want to trigger. In the end, I've upped the FPS of the slower animations to 5-10, which seems to keep the screen happy (at least for me), as long as I don't have a better solution.

I've also done some experiments with a shell runner (code that needs to be started through adb with a PC, or through root if you have it), which had some interesting results. Though inconvenient, it does give us access to a number of permissions we can use to manipulate power states. Unfortunately, for most of it there still doesn't appear to be a way to actually do so - no path to the correct Android internals. If I have the time it any point in the future, I'll dig a bit deeper into that, but my opinion right now is that it'll probably require proper root and changing (overlaying) some system files and/or settings.

I've decompiled and analyzed a lot of Samdroid's packages, but so far haven't found the holey grail :) (See what I did there? Now I need to make a new app with that name...)

PS: This one will be going up on Play ASAP

PPS: For those reading on GitHub, the sauce is up, but I have not updated all the info yet, and that may not happen today

PPPS: I saw some translations come by, please update them to the texts from this version and re-post, thanks. GitHub pull request would be even better, but I understand if that's not your cup of tea

PPPPS: For the devs: there's some interesting stuff and comments in the code if you look closely

As always with these releases, it was probably working fine this afternoon and I botched something major up just before releasing this update, so come at me with your bugs and observations :)

Most significant changes (this includes things already in v0.26)

- Screen off + battery functionality enabled

- Migration from fake lockscreen to AOD-base

- Migration from application to accessibility overlay (Google frowns on this, though)

- Any notification can now be used for LED. The ones that don't ask for LED show up under Colors as black by default.

- Lottie renderer has been replaced by a sprite-sheet based rendered (up to 5x CPU reduction)

- Battery saving animations added (up to 3x CPU reduction), blinking and pie-chart (decided based on full or on-tap AOD)

- Several leaks and crashes have been fixed (and undoubtedly new ones created)