by Oscar Zhou
Version 1 (July 12, 2023)
Download (31 downloads)
root required.
Hovers battery between 75-80%.
Automatically stops itself when nothing is plugged in AND is unlocked.
There are 3 fibers.
1: controls charging.
Uses "sys/class/power_supply/battery/input_suspend" to control charge state.
2: changes unlock variable if changed.
Uses logcat, searches for "updateActivityLockScreenState(false, false)" and "updateActivityLockScreenState(true, false)" from KeyguardViewMediator.
3: main thread. Sees if device is unlocked and nothing is plugged in and stops flow if unlocked and not plugged in.
"sys/class/power_supply/usb/typec_mode" is the usb state, and "Nothing Attached" is the if condition for this to stop automatically.
This also sets cpu governor to "powersave" when flow is active, reverts to "conservative" if stopped automatically.
Change anything if it doesn't work for u