How does doze mode affect background/foreground services, with/without partial/full wakelocks?

删除回忆录丶 提交于 2019-11-26 12:44:20

问题


This is a simple question, seeing that there is a huge post about this on G+ (here), and lack of information on official docs (here ):

What happens to the app\'s services when the device goes to \"doze\" mode?

What does it do to background/foreground services (bound/unbound, started/not-started), with/without partial/full wakelocks?

What would you do, for example, in order to create a service that plays an audio stream while the device\'s screen is turned off? What if the audio stream is not from a local file, but from the network?

Seeing that there was a claim by Google developer:

Apps that have been running foreground services (with the associated notification) are not restricted by doze.

-yet a lot of discussion after that, claiming this is not entirely true, I think it\'s quite confusing to know what special background-operations apps should do.


回答1:


Processes which have a current running foreground service are supposed to be unaffected by Doze. Bound/unbound, started/not-started, and wakelocks do not affect this whitelisting process.

However, there is an issue on Android M devices where foreground services are not properly whitelisted when the foreground service is the in the same process as the top activity and improperly dozed.

The fix is available on AOSP and will be included in builds of Android N. It would be up to OEMs to integrate that patch into any Android M builds they produce.



来源:https://stackoverflow.com/questions/37869201/how-does-doze-mode-affect-background-foreground-services-with-without-partial-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!