I have a situation where I have 3 services that do different things and all need wakelocks.
At the end of their execution I would like to release the wakelocks, however, I'm concerned that a given service releasing its wake lock would undermine the behavior of a different service. So, the scenario I'm imagining is:
service A grabs wake lock and starts doing something
service B grabs wake lock and starts doing something
service A finishes and releases wake lock
what happens to service B at this point?
So, my underlying questions are:
a) is this something to worry about or does Android automatically manage this for me behind the scenes (my assumption is it does not)?
b) what's the best way to make sure that either the wake lock persists if any of the services are not done, or to grab separate wakelocks that won't undermine one another?
what's the best way to make sure that either the wake lock persists if any of the services are not done
Call setReferenceCounted(true)
on the WakeLock
. That's already set up by default, but you could call it again if you want.