Docs: N Doze updates
      Adding Clay's feedback

Bug: 27720831

Change-Id: I5992b0665b09e006ac8f93e54141688bcce20a4f
diff --git a/src/devices/tech/images/doze_lightweight.png b/src/devices/tech/images/doze_lightweight.png
new file mode 100644
index 0000000..bfef55f
--- /dev/null
+++ b/src/devices/tech/images/doze_lightweight.png
Binary files differ
diff --git a/src/devices/tech/power/mgmt.jd b/src/devices/tech/power/mgmt.jd
index 32c20aa..481e056 100644
--- a/src/devices/tech/power/mgmt.jd
+++ b/src/devices/tech/power/mgmt.jd
@@ -26,27 +26,23 @@
 <p>Battery life is a perennial user concern. To extend battery life, Android
 continually adds new features and optimizations to help the platform optimize
 the off-charger behavior of applications and devices.</p>
-<p>The Android 6.0 release includes the following improvements to battery life:
-</p>
+<p>Android includes the following battery life enhancements:</p>
 
 <ul>
-<li><b><a href="#app-standby">App Standby</b></a>. The platform can now place
+<li><b><a href="#app-standby">App Standby</b></a>. The platform can place
 unused applications in App Standby mode, temporarily restricting network access
 and deferring syncs and jobs for those applications.</li>
-<li><b><a href="#doze">Doze</b></a>. The platform now enters a state of deep
+<li><b><a href="#doze">Doze</b></a>. The platform can enter a state of deep
 sleep (periodically resuming normal operations) if users have not actively used
-their device (screen off and stationary) for extended periods of time. As this
-feature requires the platform to detect the stationary state, it is available
-only on devices that implement the significant motion detection APIs in the
-Sensor HAL. Doze dramatically improves battery life.</li>
+their device (screen off and stationary) for extended periods of time. Android N
+also enables Doze to trigger a lighter set of optimizations when users turn
+off the device screen yet continue to move around.</li>
 <li><b><a href="#exempt-apps">Exemptions</b></a>. System apps and cloud
-messaging services preloaded on a device are typically exempted by default. App
-developers can intent their applications into this setting. Users can also
-exempt applications from App Standby and Doze via Settings > Battery >
-Battery optimization > All apps and then selecting the app to turn off (or back
-on) optimization.</li>
+messaging services preloaded on a device are typically exempted from App Standby
+and Doze by default (although app developers can intent their applications into
+this setting). Users can exempt applications via the Settings menu.</li>
 </ul>
-<p>The following sections describe these improvements.</p>
+<p>The following sections describe these enhancements.</p>
 
 <h2 id="app-standby">App Standby</h2>
 <p>App Standby extends battery life by deferring background network activity
@@ -59,9 +55,9 @@
 <table>
 <tbody>
 <tr>
-<th width=33%>Detection</th>
-<th width=33%>During App Standby</th>
-<th width=33%>Exit</th>
+<th width=46%>Detection</th>
+<th width=23%>During App Standby</th>
+<th width=31%>Exit</th>
 </tr>
 
 <tr>
@@ -119,6 +115,10 @@
 times, a device in Doze remains aware of motion and immediately leaves Doze
 if motion is detected.</p>
 
+<p>Android N extends Doze to trigger a lighter set of optimizations every time
+a user turns off the device screen, even when the user continues to move around,
+enabling longer lasting battery life.</p>
+
 <p>System services (such as telephony) may be preloaded and exempted from Doze
 by default. Users can also exempt specific applications from Doze in the
 Settings menu. By default, Doze is <b>disabled</b> in the Android Open Source
@@ -126,29 +126,31 @@
 <a href="#integrate-doze">Integrating Doze</a>.</p>
 
 <h3 id="doze-reqs">Doze requirements</h3>
-
-<p>Doze support requires the following:</p>
-<ul>
-<li>Device implements the
-<a href="http://source.android.com/devices/sensors/sensor-types.html#significant_motion">significant
-motion detector (SMD) APIs</a> in the Sensor HAL. Devices that do not implement
-these APIs cannot support Doze.</li>
-<li>Device has a cloud messaging service, such as
+<p>Doze support requires the device has a cloud messaging service, such as
 <a href="https://developers.google.com/cloud-messaging/">Google Cloud Messaging
-(GCM).</a> This enables the device to know when to wake from Doze.</li>
+(GCM)</a>. This enables the device to know when to wake from Doze.</p>
+<p>Full Doze support also requires a
+<a href="{@docRoot}devices/sensors/sensor-types.html#significant_motion">Significant
+Motion Detector (SMD)</a> on the device; however, the lightweight Doze mode in
+Android N does not require an SMD. If Doze is enabled on a device that:</p>
+<ul>
+<li>Has an SMD, full Doze optimizations occur (includes lightweight
+optimizations).</li>
+<li>Does not have an SMD, only the lightweight Doze optimizations occur.</li>
 </ul>
 
+
 <h3 id="doze-life">Doze lifecycle</h3>
 
-<p>The Doze lifecycle begins when the platform detects the device is idle and
-ends when the device exits Doze mode.</p>
+<p>Doze begins when the platform detects the device is idle and
+ends when one or more exit criteria activities occur.</p>
 
 <table>
 <tbody>
 <tr>
-<th width=33%>Detection</td>
-<th width=33%>During Doze</th>
-<th width=33%>Exit</th>
+<th width=20%>Detection</td>
+<th width=60%>During Doze</th>
+<th width=20%>Exit</th>
 </tr>
 <tr>
 <td><p>The platform detects a device is idle when:</p>
@@ -161,7 +163,7 @@
 </td>
 <td><p>The platform attempts to keep the system in a sleep state, periodically
 resuming normal operations during a maintenance window then returning the device
-to sleep for longer repeating periods. During the sleep state, the following
+to sleep for longer repeating periods. During sleep, the following
 restrictions are active:</p>
 <ul>
 <li>Apps not allowed network access.</li>
@@ -190,6 +192,47 @@
 </tbody>
 </table>
 
+<p>Android N extends Doze by enabling a lightweight sleep mode during screen
+off, before the device is idle.</p>
+<p><img src="../images/doze_lightweight.png"></p>
+<p class="img-caption">Figure 1. Doze modes for non-stationary and stationary
+devices.</p>
+
+<table>
+<tbody>
+<tr>
+<th>Action</th>
+<th>Doze</th>
+<th>Lightweight Doze</th>
+</tr>
+<tr>
+<td>Trigger</td>
+<td>Screen off, on battery, stationary</td>
+<td>Screen off, on battery (unplugged)</td>
+</tr>
+<tr>
+<td>Timing</td>
+<td>Successively increasing periods with maintenance</td>
+<td>Repeated N-minute periods with maintenance windows</td>
+</tr>
+<tr>
+<td>Restrictions</td>
+<td>No network access, wake lock, or GPS/Wi-FI scan. Alarms and jobs/syncs deferred.</td>
+<td>No network access. Jobs/syncs deferred except during maintenance windows.</td>
+</tr>
+<tr>
+<td>Behavior</td>
+<td>Only high-priority push notification messages received.</td>
+<td>All real-time messages (instant messages, calls, etc.) received. High-priority push notification message enables temporary network access.</td>
+</tr>
+<tr>
+<td>Exit</td>
+<td>Motion, screen on, or alarm clock alarm.</td>
+<td>Screen on.</td>
+</tr>
+</tbody>
+</table>
+
 <h3 id="doze-interactions">Interaction with App Standby</h3>
 <ul>
 <li>Time spent in Doze does not count towards App Standby.</li>
@@ -198,12 +241,17 @@
 </ul>
 
 <h3 id="integrate-doze">Integrating Doze</h3>
+
+<p>When Doze is enabled, devices that support
+<a href="{@docRoot}devices/sensors/sensor-types.html#significant_motion">SENSOR_TYPE_SIGNIFICANT_MOTION</a>
+will perform full Doze optimizations (includes lightweight optimizations);
+devices without an SMD will perform only lightweight Doze optimizations. Android
+automatically selects the appropriate Doze optimizations and no vendor
+configuration is necessary.</p>
+
 <p>To enable Doze for a device, perform the following tasks:</p>
 
 <ol>
-<li>Confirm the device supports
-<a href="http://source.android.com/devices/sensors/sensor-types.html#significant_motion">SENSOR_TYPE_SIGNIFICANT_MOTION
-</a>. If the device does not support this sensor, it cannot support Doze.</li>
 <li>Confirm the device has a cloud messaging service installed.</li>
 <li>In the device overlay config file
 <code>overlay/frameworks/base/core/res/res/values/config.xml</code>, set
@@ -228,6 +276,24 @@
 </li>
 </ol>
 
+<h4 id="doze-tips">Tips</h4>
+<ul>
+<li>If possible, use GCM for
+<a href="https://developers.google.com/cloud-messaging/downstream">downstream
+messaging</a>.</li>
+<li>If your users must see a notification right away, use a
+<a href="https://developers.google.com/cloud-messaging/concept-options#setting-the-priority-of-a-message">GCM high priority
+message</a>.</li>
+<li>Provide sufficient information within the initial
+<a href="https://developers.google.com/cloud-messaging/concept-options#payload">message
+payload</a> (to avoid unnecessary subsequent network access).</li>
+<li>Set critical alarms with
+<a href="http://developer.android.com/reference/android/app/AlarmManager.html#setAndAllowWhileIdle(int,%20long,%20android.app.PendingIntent)">setAndAllowWhileIdle()</a>
+and
+<a href="http://developer.android.com/reference/android/app/AlarmManager.html#setExactAndAllowWhileIdle(int,%20long,%20android.app.PendingIntent)">setExactAndAllowWhileIdle()</a>.
+</li>
+</ul>
+
 <h4 id="test-apps">Testing and optimizing applications</h4>
 <p>Test all applications (especially preloaded applications) in Doze mode. For
 details, refer to
@@ -239,7 +305,13 @@
 mode.</p>
 
 <h2 id="exempt-apps">Exempting applications</h2>
-<p>You can exempt applications from being subject to Doze or App Standby.</p>
+<p>You can exempt applications from being subject to Doze or App Standby.
+Exemptions may be needed in the following use cases:</p>
+<ul>
+<li>OEM using non-GCM Cloud Messaging platform</li>
+<li>Carrier using non-GCM Cloud Messaging platform</li>
+<li>Third-party application using non-GCM Cloud Messaging platform</li>
+</ul>
 
 <p class="warning"><b>Warning</b>: Do not exempt apps to avoid testing and
 optimizing. Unnecessary exemptions undermine the benefits of Doze and App
@@ -257,6 +329,7 @@
 Standby modes. To provide transparency to the user, the Settings menu
 <b>MUST</b> show all exempted applications.</p>
 
-<p>Users can manually exempt apps using the Settings menu. However, users cannot
-unexempt any application or service that is exempted by default in the system
-image.</p>
\ No newline at end of file
+<p>Users can manually exempt apps via Settings > Battery > Battery optimization
+> All apps and then selecting the app to turn off (or back on) optimization.
+However, users cannot unexempt any application or service that is exempted by
+default in the system image.</p>