4

The new Doze mode on Android 6 disables nearly every useful background activity. I have an app, which regularly woke up the device (even if no lock screen), kept a partial wake lock, did some scans and reported that to the Internet. It is not a spy app - this operation is on purpose and known to users of the app.

Right now with Android 6 it doesn't work anymore, because the Doze mode prevents the final communication with my servers.

I found a new setting under "Battery", which did allow me to put my app on a list of those app, which did not support "battery optimization". In the first tests it seemed, that this was making my app run again.

After some additional tests I found, that even my app was not supporting Doze, it didn't work anymore in background.

Isn't this setting supposed to disable Doze for particular apps?

Details to Doze here http://www.androidpolice.com/2015/06/01/android-m-feature-spotlight-this-is-exactly-how-doze-reduces-battery-drain/

6
  • 2
    Just making sure you've seen the new guidance from Google on Doze mode: developer.android.com/training/monitoring-device-state/… Oct 10, 2015 at 7:08
  • Thanks, no have not seen that yet. Got the Android 6 update just a couple of days ago
    – decades
    Oct 11, 2015 at 7:55
  • 2
    "For a narrow set of use cases, this might not be sufficient. For such cases, the system provides a configurable whitelist of apps that are partially exempt from Doze and App Standby optimizations. An app that is whitelisted can use the network and hold partial wake locks during Doze and App Standby. " This is definitely not true. I have put my app on the whitelist for test. However, network access is prevented.
    – decades
    Oct 11, 2015 at 13:18
  • As Doze is a system-wide mode, there can't be a per-app whitelist. The device enters a deep sleep mode when Doze is active, so it wouldn't make sense to have exceptions.
    – Daveoc64
    Oct 17, 2015 at 17:12
  • 1
    Well... thanks for the comment, but I quoted an official Google doc. According to this an app can opt out partially from being dozed and completely disabled. Or how would you understand that? The key is "partially exempt". Your claim is wrong.
    – decades
    Oct 18, 2015 at 18:19

2 Answers 2

1

I encountered this exact issue with an app that requires the accelerometer, gyro, and magnetometer to operate in the background and when the screen is off. Android 6.0 Doze prohibits an application from using the sensors in realtime when the screen is off. Adding the app to the battery optimization whitelist did not fix the problem for the app. Making a PARTIAL_WAKE_LOCK did fix the issue with the sensors.

2
  • Right, PARTIAL_WAKE_LOCK helps. But I already had that wake lock before. These are the experiences I have made so far: 1) You will not get any alarm through in order to wake up a device to do things, if the device is in Doze mode. It will wake up during the next so called "Maintenence" period. 2) Even if you manage to get a GCM message (which works with high priority messages well, even in Doze mode) you will definitely not be able to get a fresh wifi scan, because the stack just replays the last scan seen. I cannot comment on sensors. The whitelist doesn't help at all, IMHO
    – decades
    Nov 11, 2015 at 21:46
  • From what I know, any wake locks that we may have, will exit once the system decides to enter the doze mode. That's the whole idea i guess, to prolong battery life. They just want to do it transparently, so may be a foreground service or an AlarmManager api like setAndAllowWhileIdle Mar 17, 2017 at 7:27
1

Up to my understanding of the Doze Restrictions:

  • Standard AlarmManager alarms [...] are deferred to the next maintenance window.
  • The system does not perform Wi-Fi scans.

I'm afraid white-listing your app will not be sufficient to make it work again. As you mentioned in your comments, exemption is only partial.

1
  • Yes, point 1 is confirmed. And you can do Wifi scans, if you use GCM high prio message in order to trigger these kind of actions.
    – decades
    Nov 18, 2015 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.