Last week I've found out that the battery in my phone didn't last a day and according to the phone power estimations, a fully charged battery provided a little less than 9 hours of idle time.
Bummer.
My phone is an old Android terminal, it has already passed his manufacturer support life at least two times, but I'm really appalled by the current offer in the market. There's exactly one manufacturer that still produces a high-end Android model with a display under 5 inches1, I really hate the current trend of phones with ginourmous displays that can't fit in a trouser pocket. And nope, I'm not so keen to adopt Apple's ecosystem.
A reboot didn't solve the issue and at that moment I wasn't yet sure if it was a hardware or a software problem. Considering the age of the phone, I was leaning for a dying battery.
Turned out instead, the OS had stopped entering deep sleep state at all, a.k.a. the lowest power mode. So diagnosis was easy, at least one process was not releasing a "wakelock", a function in the Android power management stack where a process can keep the OS "awake", as the name suggests. Thorough analysis2 pointed specifically to the suspend_backoff
wakelock, but trying to find the guilty program was fruitless, as disabling first and then removing a bunch of applications installed with the last update was fruitless.
Before proceeding with a factory reset, a process that I dread, I tried to clean the Dalvik cache as a last attempt. How do you clean a cache? Oh my, you delete its content! I always have trouble recalling the button sequence for boot in recovery mode: is it power and volume up or is it power and volume down? Anyway, the recovery image I installed didn't have that option, or at least I couldn't find it.
Well, if one has access to the root user on the phone, cleaning the Dalvik cache it's a matter of seconds:
$ adb shell
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
$ su
# cd /data/dalvik-cache/
# ls -l
drwx--x--x root root 2016-12-23 19:08 arm
drwx--x--x system system 2016-12-23 19:08 profiles
# rm -r arm profiles
# reboot
Faster than saying suspend_backoff
wakelock!
After the reboot I've verified that the OS could finally transition to deep sleep state again. Brilliant, it looks like I don't have an excuse to buy a new one.
Bummer.