I am working at an app that is meant to fully take over a phone if it has root access. The application takes pictures at a set interval, and uploads them to a ftp server. The use case for it is to turn old phones into security cameras, or for timelapse photography in general. I am also trying to conserve as much power as possible, so that the phone can be used in remote locations with a solar USB charger.
Ideally, the phone should wake up every minute or so using setAndAllowWhileIdle(), take a picture, go to sleep. Once every x number of pictures are taken, it would turn off the airplane mode, connect to the internet, upload the pictures, turn on the airplane mode.
My problem is that once I force the phone to doze mode by using "dumpsys deviceidle force-idle", setAndAllowWhileIdle() becomes very inexact. An alarm set for the next 20 seconds can arrive even in 15 minutes.
I was wondering if there is any way as root to set the idle maintenance window to whatever interval I want, so that I can get my alarms at reasonable times. Or if there is any other way as root to get reliable alarms (reliable as in minute accuracy). Or if I can suspend the entire phone for a set period of time.