This is less of an imx8 issue and more of a generic Android/Linux issue, but were using the imx8m so I'll ask here and see if someone perhaps has dealt with this issue.
Our device is battery powered. We are using Android. After the screen timeout for inactivity occurs, the kernel will go into a sleep state. Battery load during this time is pretty minimal but it is enough to drain the battery over a couple days. It would be desirable if the user does not wake the device after an hour or so, to go ahead and shut down.
I haven't found any luck finding hooks in Android to do this. The PowerManagerService has some callbacks to set the wakefulness state, but it seems those are only called if the device actually wakes up from sleep. At the Linux level though, the device does come out of sleep periodically due to the RTC interrupt. I see the battery health is checked and then the device immediately goes back to sleep and no powermanager service hooks are called.
Can anyone suggest where I might put a hook to detect this state so that I might a check the time since the device was awake and just shut down if it's been longer than the desired timeout?