4

Background

Android 6 has introduced a built in mechanism called "Doze" for better handling the battery while the device sleeps.

The problem

Problem is, I don't see how it really works, and how should apps change to handle this new mechanism, if at all.

Obviously, it depends on what you have in the code, but what should I look for?

What I've found

I've found 2 web pages talking about this :

But they mostly talk about alarms:

To help with scheduling alarms, Android 6.0 (API level 23) introduces two new AlarmManager methods: setAndAllowWhileIdle() and setExactAndAllowWhileIdle(). With these methods, you can set alarms that will fire even if the device is in Doze.

The questions

What should apps developer do in order to handle this new mechanism? Would scheduling APIs work differently because of it? How about changes needed for :

  1. Alarms

  2. Background/foreground service

  3. Wakelocks

  4. JobScheduler and GcmTaskService

Are there any adjustments that need to be done to handle Android 6 and above in this matter?

Floern
  • 33,559
  • 24
  • 104
  • 119
android developer
  • 114,585
  • 152
  • 739
  • 1,270

1 Answers1

0

One of the most important behavior changes is the lack of network connectivity while in idle mode due to Doze. However, there are a whole host of changes to behavior—including wakelocks and JobScheduler jobs.

The developer docs are fairly clear with what won't work while in Doze: http://developer.android.com/training/monitoring-device-state/doze-standby.html#restrictions

If you're looking for specifics, feel free to check out this Gist I've written up about some of my observations of Doze and idle mode behavior: https://gist.github.com/ccpmark/430d4ddf3a46a02672c1

ccpmark
  • 1,005
  • 1
  • 10
  • 11
  • Is it possible that the whitelist will help for network? – android developer Oct 16 '15 at 20:13
  • As far as I know, the whitelist is only for App Standby mode, not Doze. https://code.google.com/p/android-developer-preview/issues/detail?id=2225 – ccpmark Oct 19 '15 at 17:37
  • I don't know. They speak there about Alarms, but the docs say "An app that is whitelisted can use the network and hold partial wake locks during Doze and App Standby" . source: http://developer.android.com/training/monitoring-device-state/doze-standby.html#support_for_other_use_cases – android developer Oct 19 '15 at 20:59
  • I'm sorry - I was mistaken. It seems like the whitelist allows you to circumvent Doze. – ccpmark Oct 23 '15 at 14:20
  • But only for specific things, like partial wakelocks, right? – android developer Oct 23 '15 at 18:20