In my Android app, I use AlarmManager to wake up my service every 3 seconds. When the service is run, it checks for some condition and then plays a sound if the condition is met.
What I have found is that if I leave my device in sleep mode for 24 hours and then do something that causes the event to trigger, the service does appear to work and the sound is played. But if I leave it for a much longer period of time, like 2 days, the event does get noticed but the sound is not played right away. It can take a minute before the sound comes on.
This tells me that the service is still running although I am not sure that it is running every 3 seconds. If it is running every 3 seconds, then maybe the sleep mode is preventing the sound system from activating right away and needs time to wakeup, even though their is a partial wakelock on both the service and part of code that plays the sound.
My question is whether Android slows the CPU down in sleep mode. I do have a cable attached, so it is constantly powered. But I am wondering if slower CPU cycles explains why the sound takes much longer to kick in.
Another possibility is that there might be a memory leak that is slowing down the system. I'll have to run the app in sleep mode for probably 4 days to see whether the time increases to know whether that is true.