简体   繁体   中英

Android Doze Mode - Bluetooth

My question is fairly simple. I would like to know what it is the best practice for my app so that it can be "Doze-proof". This is getting even more relevant as Android N will be applying Doze in more case scenario.

While reading Doze Documentation there is a part mentioning network access :

In Doze mode, the system attempts to conserve battery by restricting apps' access to network and CPU-intensive services. It also prevents apps from accessing the network and defers their jobs, syncs, and standard alarms.

I believe Buetooth falls under Network Access , is that correct?

Since I do not own a Marshmallow (or Android N) enabled-device and since Emulator does not allow Bluetooth interaction I cannot really test my app behavior in Doze Mode.

Will Doze Mode kill any ongoing Bluetooth connexion ? Does the same apply either for Bluetooth Classic and LE ? What about headsets with Bluetooth A2DP ?

My app must maintain this connection or else the core functionality will be broken.

Surely there is some kind of exceptions for such case where your device needs to be connected to a Bluetooth remote device for as long the user whishes too.

I know there exists a Doze Whitelist but it would seem it might not, in some cases, let the app behave as it would on a device below API 23.

Thank you for your help!

Looks like doze doesn't have any restriction on bluetooth per se but to do anything meaningful, you would need to keep the cpu on and wake locks are ignored in deeper doze.

If it's a core functionality of your app, you can try to ask users to whitelist your app. This can grant partial wake locks and keep the cpu on.

Foreground services are also exempted from any doze restrictions so that's another transparent way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM