androidalarmmanagerwakelockpowermanager

If an app holds a partial wake lock and the phone is woken up, do other processes get access to the CPU too?


It's been a longtime assumption of mine that when a WakeLock is held the device's CPU is fair game for all running processes. Does this assumption hold?

As an example, suppose processes A, B, and C exist. The phone has been asleep for 4 hours and none of these processes have been able to do work. Suddenly, process A acquires a WakeLock via an AlarmManager and holds it for 3 minutes. Do B and C get to do their work, too, during that 3 minute period?


Solution

  • Does this assumption hold?

    Yes.

    Do B and C get to do their work, too, during that 3 minute period?

    Yes. In fact, this is specifically how things like SyncManager work, and specifically why Android 4.4 made it difficult for you to do an exact AlarmManager schedule. In the case of AlarmManager, the desire for inexact schedules allows Android to wake up the device once and do a bunch of work, rather than having to wake the device up lots of separate times.