page.title=Power-Saving Optimizations page.keywords=preview,sdk,compatibility sdk.platform.apiLevel=MNC @jd:body

In this document

  1. Doze
  2. App Standby

API Differences

  1. API level 22 to M Preview »

See Also

  1. M Developer Preview API Overview

Android M Preview helps prolong battery life by introducing new power-saving optimizations: Doze mode improves the sleep efficiency of idle devices. App Standby prevents apps from eating up power while idle.

Doze

If a user leaves a device unplugged and stationary for a period of time, with the screen off, the device enters Doze mode. Doze attempts to keep the system in a sleep state as long as the device remains undisturbed. In this mode, devices periodically resume normal operations for brief periods of time so that the system can perform app syncing and any other pending operations.

The following restrictions apply to your apps while in Doze:

When the device exits Doze mode, it executes any jobs and syncs that are pending.

Testing apps with Doze

You can test Doze mode by connecting your development host to a device running the M Preview, and calling the following commands:

$ adb shell dumpsys battery unplug
$ adb shell dumpsys deviceidle step
$ adb shell dumpsys deviceidle -h

Note: As of M Preview 3 release, Google Cloud Messaging (GCM) lets you designate high-priority messages. If your app receives a high-priority GCM message, the system grants brief network access even when the device is dozing.

See the Testing Guide for tips on how to test Doze in your apps.

App Standby

App Standby allows the system to determine that an app is idle when the user is not actively using it. The system makes this determination when the user does not touch the app for a certain period of time, and none of the following conditions applies:

When the user plugs the device into a power supply, the system releases apps from the standby state, allowing them to freely access the network and to execute any pending jobs and syncs. If the device is idle for long periods of time, the system allows idle apps network access around once a day.

Testing apps with App Standby

You can test App Standby by connecting your development host to a device running the M Preview, and calling the following commands:

$ adb shell dumpsys battery unplug
$ adb shell am set-idle <packageName> true
$ adb shell am set-idle <packageName> false
$ adb shell am get-idle <packageName>

Note: As of M Preview 3 release, Google Cloud Messaging (GCM) lets you designate high-priority messages. If your app receives high-priority GCM messages, the system grants brief network access even when the app is idle.

See the Testing Guide for tips on how to test App Standby in your apps.