Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a5ac2db authored by Dirk Dougherty's avatar Dirk Dougherty
Browse files

Add guidelines for Doze and Standby.

Change-Id: Ib0f0d388be104b763c49341229edc6c8faa7c699
parent a14c3042
Loading
Loading
Loading
Loading
+70 −2
Original line number Diff line number Diff line
@@ -592,6 +592,23 @@ data-sortorder="-timestamp" data-cardsizes="6x3" data-maxresults="6">
  </td>
  </tr>

  <tr id="PS-B1">
  <td>
    Battery
  </td>
  <td>
    PS-B1
  </td>
  <td>
    App supports power management features in Android 6.0+ (Doze and App Standby)
    properly. In the case where core functionality is disrupted by power management,
    only qualified apps may request an exemption.
  </td>
  <td>
    <a href="#BA-1">BA-1</a>
  </td>
  </tr>

  <tr id="PS-M1">
  <td>
    Media
@@ -702,7 +719,7 @@ data-cardsizes="6x3" data-maxresults="6">
  </tr>

  <tr id="GP-P1">
  <td rowspan="2">
  <td rowspan="3">
    Policies
  </td>
  <td>
@@ -740,6 +757,25 @@ data-cardsizes="6x3" data-maxresults="6">
  </td>
  </tr>

  <tr id="GP-P2">
  <td>
    GP-P3
  </td>
  <td>
    <p style="margin-bottom:.5em;">
    App supports power management features in Android 6.0+ (Doze and App Standby)
    properly. In the case where core functionality is disrupted by power management,
    only qualified apps may request an exemption.
    See <a
    href="{@docRoot}training/monitoring-device-state/doze-standby.html#other_use_cases">Support
    for other use cases</a> in Doze and App Standby.</p>
    </p>
  </td>
  <td>
    <a href="#gp">GP-4</a>
  </td>
  </tr>

  <tr id="GP-D1">
  <td rowspan="3">
    App&nbsp;Details Page
@@ -1088,8 +1124,29 @@ data-cardsizes="6x3,6x3,6x3,6x3,6x3,6x3" data-maxresults="6">
  </td>
  </tr>

  <tr id="BA-1">
  <td>
    Battery
  </td>
  <td>
    BA-1
  </td>
  <td>
    <p style="margin-bottom:.5em;">
    Repeat <em>Core Suite</em> across Doze and App Standby cycles.
    </p>

    <p style="margin-bottom:.25em;">
    Pay close attention to alarms, timers, notifications, syncs, and so on.
    See <a
    href="{@docRoot}training/monitoring-device-state/doze-standby.html#testing_doze_and_app_standby">Testing
    with Doze and App Standby</a>.
    </p>
  </td>
  </tr>

  <tr id="gp">
  <td rowspan="3">
  <td rowspan="4">
    Google Play
  </td>
  <td>
@@ -1123,6 +1180,17 @@ data-cardsizes="6x3,6x3,6x3,6x3,6x3,6x3" data-maxresults="6">
  </td>
  </tr>

  <tr id="GP-4">
  <td>
    GP-4
  </td>
  <td>
  Review <a
  href="{@docRoot}training/monitoring-device-state/doze-standby.html#other_use_cases">Support
  for other use cases</a> in Doze and App Standby.
  </td>
  </tr>

  <tr id="GP-4">
  <td>
    Payments
+61 −80
Original line number Diff line number Diff line
page.title=Optimizing for Doze and App Standby
page.metaDescription=Test and optimize your app for the power-saving features in Android 6.0.
page.tags="doze", "app standby", "marshmallow", "alarms"
page.tags=doze, app standby, marshmallow, alarms
meta.tags="battery", "marshmallow", "alarms"
page.image=images/cards/card-doze_16-9_2x.png
page.article=true
@@ -20,10 +20,10 @@ next.link=battery-monitoring.html
        <li><a href="#restrictions">Doze Restrictions</a></li>
        <li><a href="#assessing_your_app">Assessing Your App</a></li>
        <li><a href="#using_gcm">Using GCM to Interact with Your App</a></li>
        <li><a href="#support_for_other_use-cases">Support for Other Use-Cases</a></li>
      </ol>
      </li>
      <li><a href="#understand_app_standby">Understanding App Standby</a></li>
      <li><a href="#other_use_cases">Support for Other Use-Cases</a></li>
      <li><a href="#testing_doze_and_app_standby">Testing</a>
      <ol>
        <li><a href="#testing_your_app_with_doze">With Doze</a></li>
@@ -110,7 +110,7 @@ next.link=battery-monitoring.html
  <li>Standard {@link android.app.AlarmManager} alarms (including {@link
  android.app.AlarmManager#setExact(int, long, android.app.PendingIntent) setExact()} and
  {@link android.app.AlarmManager#setWindow(int, long, long,
  android.app.PendingIntent) setWindow()} are deferred to the next mainenance window.
  android.app.PendingIntent) setWindow()}) are deferred to the next maintenance window.
  </li>

  <li style="list-style: none; display: inline">
@@ -133,7 +133,7 @@ next.link=battery-monitoring.html
  <li>The system does not perform Wi-Fi scans.
  </li>

  <li>The system does not permit syncs or jobs for your sync adapters.
  <li>The system does not allow {@link android.content.AbstractThreadedSyncAdapter sync adapters} to run.
  </li>

  <li>The system does not allow {@link android.app.job.JobScheduler} to run.
@@ -156,10 +156,9 @@ next.link=battery-monitoring.html
  high priority message</a>.
  </li>

  <li>Place enough information in the <a href=
  <li>Provide sufficient information within the initial <a href=
  "https://developers.google.com/cloud-messaging/concept-options#payload">message
  payload</a> to show in the notification; do not rely on subsequent network
  access.
  payload</a>, so subsequent network access is unnecessary.
  </li>

  <li>Set critical alarms with {@link
@@ -170,7 +169,7 @@ next.link=battery-monitoring.html
  </li>

  <li>
    <a href="#testing_with_doze">Test your app in Doze</a>
    <a href="#testing_your_app_with_doze">Test your app in Doze</a>
  </li>
</ul>
</ol>
@@ -181,8 +180,8 @@ next.link=battery-monitoring.html

<p>
  To assess your app in Doze, you can use adb commands to force the system to
  enter and exit Doze and observe your app’s behavior. See the Testing section
  for details.
  enter and exit Doze and observe your app’s behavior. See <a
  href="#testing_your_app_with_doze">Testing with Doze</a> for details.
</p>

<p>
@@ -226,7 +225,7 @@ next.link=battery-monitoring.html

<p>
  The Doze restriction on network access is also likely to affect your app,
  especially if the app relies on realtime messages such as tickles or
  especially if the app relies on real-time messages such as tickles or
  notifications. If your app requires a persistent connection to the network to
  receive messages, you should use Google Cloud Messaging (GCM) if possible,
  <a href="#using_gcm">as described below</a>.
@@ -238,16 +237,16 @@ next.link=battery-monitoring.html
<p>
  <a href="https://developers.google.com/cloud-messaging/">Google Cloud
  Messaging (GCM)</a> is a cloud-to-device service that lets you support
  realtime downstream messaging between backend messaging services and apps on
  real-time downstream messaging between backend services and apps on
  Android devices. GCM provides a single persistent connection to the cloud
  that can be shared among all apps needing realtime messaging. This shared
  that can be shared among all apps needing real-time messaging. This shared
  connection significantly optimizes battery by making it unnecessary for
  multiple apps to each maintain a separate persistent connection, which can
  deplete the battery rapidly.
</p>

<p>
  If your app requires realtime integration with a backend service, it’s highly
  If your app requires messaging integration with a backend service, it’s highly
  recommended that you <strong>use GCM if possible</strong>, rather than
  maintaining your own persistent network connection. Also, GCM is optimized to
  work with Doze and App Standby idle modes by means of <a href=
@@ -258,7 +257,7 @@ next.link=battery-monitoring.html
<p>
  GCM high-priority messages let you reliably wake your app to access the
  network, even if the user’s device is in Doze or the app is in App Standby.
  In Doze or App Standby mode, the system delivers the message and gives the
  In Doze or App Standby, the system delivers the message and gives the
  app temporary access to network services and partial wakelocks, then returns
  to idle state.
</p>
@@ -277,14 +276,43 @@ next.link=battery-monitoring.html
  wake apps even when the device is in Doze.
</p>

<h3 id="support_for_other_use-cases">Support for other use-cases</h3>
<h2 id="understand_app_standby">Understanding App Standby</h2>

<p>
  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:
</p>

<ul>
  <li>The user explicitly launches the app.
  </li>

  <li>The app has a process currently in the foreground (either as an activity
  or foreground service, or in use by another activity or foreground service).
  </li>

  <li>The app generates a notification that users see on the lock screen or in
  the notification tray.
  </li>
</ul>

<p>
  Almost all apps should be able to support Doze by managing network, alarms,
  jobs, and syncs properly and using GCM high-priority messages. For a narrow
  set of use cases, this might not be sufficient. For those, the system
  provides a configurable whitelist of apps that are <strong>partially
  exempt</strong> from Doze and App Standby optimizations.
  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.
</p>

<h2 id="other_use_cases">Support for other use-cases</h2>

<p>
  Almost all apps should be able to support Doze and App Standby by managing
  network, alarms, jobs, and syncs properly and using GCM high-priority 
  messages. For a narrow set of use cases, this might not be sufficient.
  For those, the system provides a configurable whitelist of apps that are
  <strong>partially exempt</strong> from Doze and App Standby optimizations.
</p>

<p>
@@ -299,7 +327,7 @@ next.link=battery-monitoring.html
<p>
  Users can manually configure the whitelist in <strong>Settings &gt; Battery
  &gt; Battery Optimization.</strong> Alternatively, the system provides
  low-friction ways for apps to ask users to whitelist them.
  ways for apps to ask users to whitelist them.
</p>

<ul>
@@ -326,9 +354,10 @@ next.link=battery-monitoring.html
  </li>
</ul>

<p>Before asking the user to add your app to the whitelist, make sure the app

meets the acceptable use-cases for whitelisting listed below. </p>
<p>
  Before asking the user to add your app to the whitelist, make sure the
  app meets the acceptable use-cases for whitelisting listed below.
</p>


<p class="caution">
@@ -337,64 +366,16 @@ meets the acceptable use-cases for whitelisting listed below. </p>
  Standby) unless the core function of the app is adversely affected.
</p>


<h2 id="understand_app_standby">Understanding App Standby</h2>

<p>
  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:
</p>

<ul>
  <li>The user explicitly launches the app.
  </li>

  <li>The app has a process currently in the foreground (either as an activity
  or foreground service, or in use by another activity or foreground service).
  </li>

  <li>The app generates a notification that users see on the lock screen or in
  the notification tray.
  </li>
</ul>

<p>
  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.
</p>


<h2 id="testing_doze_and_app_standby>Testing with Doze and App Standby</h2>
<h2 id="testing_doze_and_app_standby">Testing with Doze and App Standby</h2>

<p>
  The power-saving features of Doze and App Standby limit the amount of
  background processing that your app can perform when a device is in an idle
  state or while your app is not in focus. The restrictions the system may
  impose on apps include limited or no network access, suspended background
  tasks, suspended Notifications, ignored wake requests, and alarms. To ensure
  that your app behaves properly with these power-saving optimizations, you
  should test it by simulating these low-power states.
  To ensure a great experience for your users, you should test your app fully
  in Doze and Standby.
</p>

<h3 id="testing_your_app_with_doze">Testing your app with Doze</h3>

<p>
  The power-saving features of Doze and App Standby limit the amount of
  background processing that your app can perform when a device is in an idle
  state or while your app is not in focus. The restrictions the system may
  impose on apps include limited or no network access, suspended background
  tasks, suspended Notifications, ignored wake requests, and alarms. To ensure
  that your app behaves properly with these power-saving optimizations, you
  should test it by simulating these low-power states.
</p>



<p>You can test Doze mode by following these steps:</p>
<p>You can test your app in Doze by following these steps:</p>

<ol>
  <li>Configure a hardware device or virtual device with an Android 6.0 (API
@@ -471,15 +452,15 @@ $ adb shell am get-inactive &lt;packageName&gt;</pre>

 <tr>
    <td rowspan="2">Instant messaging, chat, or calling app. </td>
    <td rowspan="3">Requires delivery of realtime messages to users while device is in Doze or app
    <td rowspan="3">Requires delivery of real-time messages to users while device is in Doze or app
    is in App Standby.</td>
    <td>Yes, using GCM</td>
    <td rowspan="2" style="color:red">Not Acceptable</td>
    <td rowspan="2">Should use GCM high-priority messages to wake the app and access the netowrk.</td>
    <td rowspan="2">Should use GCM high-priority messages to wake the app and access the network.</td>
 </tr>

 <tr>
    <td>Yes, but wants to use another messaging service for non-technical reason. </td>
    <td>Yes, but is not using GCM high-priority messages.</td>
 </tr>

 <tr>