Docs: Adding sustained performance docs for N
      Adding Gina's feedback

Bug: 27721400
Change-Id: Ia3f543ab7bd0572d3c60d70175931ea90b5f936f
diff --git a/src/devices/tech/images/power_sustained_perf.png b/src/devices/tech/images/power_sustained_perf.png
new file mode 100644
index 0000000..5ed7810
--- /dev/null
+++ b/src/devices/tech/images/power_sustained_perf.png
Binary files differ
diff --git a/src/devices/tech/power/mgmt.jd b/src/devices/tech/power/mgmt.jd
index 481e056..16aed9d 100644
--- a/src/devices/tech/power/mgmt.jd
+++ b/src/devices/tech/power/mgmt.jd
@@ -29,19 +29,25 @@
 <p>Android includes the following battery life enhancements:</p>
 
 <ul>
-<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 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. 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 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>
+<li><strong><a href="#app-standby">App Standby</strong></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><strong><a href="#doze">Doze</strong></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.
+Android 7.0 also enables Doze to trigger a lighter set of optimizations when
+users turn off the device screen yet continue to move around.</li>
+<li><strong><a href="#exempt-apps">Exemptions</strong></a>. System apps and
+cloud 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>
+<li><strong><a href="#sustained_performance">Sustained Performance</a></strong>.
+To address performance variations during high device temperatures, Android 7.0
+includes support for sustained performance, enabling OEMs to provide hints on
+device performance capabilities for long-running applications.</li>
 </ul>
+
 <p>The following sections describe these enhancements.</p>
 
 <h2 id="app-standby">App Standby</h2>
@@ -92,7 +98,7 @@
 a period of time.
 </p>
 
-<h3>Testing App Standby</h3>
+<h3 id=testing_app_standby>Testing App Standby</h3>
 <p>You can manually test App Standby using the following ADB commands:</p>
 
 <pre>
@@ -115,14 +121,14 @@
 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
+<p>Android 7.0 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
-Project (AOSP). For details on enabling Doze, see
+Settings menu. By default, Doze is <strong>disabled</strong> in the Android Open
+Source Project (AOSP). For details on enabling Doze, see
 <a href="#integrate-doze">Integrating Doze</a>.</p>
 
 <h3 id="doze-reqs">Doze requirements</h3>
@@ -132,7 +138,7 @@
 <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>
+Android 7.0 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>
@@ -192,7 +198,7 @@
 </tbody>
 </table>
 
-<p>Android N extends Doze by enabling a lightweight sleep mode during screen
+<p>Android 7.0 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
@@ -255,7 +261,7 @@
 <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
-<code>config_enableAutoPowerModes</code> to <b>true</b>:
+<code>config_enableAutoPowerModes</code> to <strong>true</strong>:
 <pre>
 bool name="config_enableAutoPowerModes"&gt;true&lt;/bool&gt;
 </pre>
@@ -267,7 +273,7 @@
 <a href="https://developer.android.com/preview/behavior-changes.html#behavior-power">power-saving
 optimization guidelines</a>. For details, see <a href="#test-apps">Testing and
 optimizing applications</a>.
-<p><b>OR</b></p>
+<p><strong>OR</strong></p>
 <li>Are exempted from Doze and App Standby. For details, see
 <a href="#exempt-apps">Exempting applications</a>.</li>
 </ul>
@@ -300,7 +306,7 @@
 <a href="https://developer.android.com/preview/testing/guide.html#doze-standby">Testing
 Doze and App Standby</a>.</p>
 
-<p class="note"><b>Note</b>: MMS/SMS/Telephony services function independently
+<p class="note"><strong>Note</strong>: MMS/SMS/Telephony services function independently
 of Doze and will always wake client apps even while the device remains in Doze
 mode.</p>
 
@@ -313,8 +319,8 @@
 <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
+<p class="warning"><strong>Warning</strong>: Do not exempt apps to avoid testing
+and optimizing. Unnecessary exemptions undermine the benefits of Doze and App
 Standby and can compromise the user experience, so we strongly suggest
 minimizing such exemptions as they allow applications to defeat beneficial
 controls the platform has over power use. If users become unhappy about the
@@ -327,9 +333,81 @@
 <p>Apps exempted by default are listed in a single view within the Settings >
 Battery menu. This list is used for exempting the app from both Doze and App
 Standby modes. To provide transparency to the user, the Settings menu
-<b>MUST</b> show all exempted applications.</p>
+<strong>MUST</strong> show all exempted applications.</p>
 
 <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>
+
+<h2 id=sustained_performance>Sustained performance</h2>
+<p>For long-running applications (games, camera, RenderScript, audio
+processing), performance can vary dramatically as device temperature limits are
+reached and system on chip (SoC) engines are throttled. App developers creating
+high-performance, long-running apps are limited because the capabilities of the
+underlying platform are a moving target when the device begins to heat up.</p>
+
+<p>To address these limitations, Android 7.0 includes support for sustained
+performance, enabling OEMs to provide hints on device performance capabilities
+for long-running applications. App developers can use these hints to tune
+applications for a predictable, consistent level of device performance over long
+periods of time.</p>
+
+<h3 id=architecture>Architecture</h3>
+<p>An Android application can request the platform to enter a sustained
+performance mode where the Android device can keep a consistent level of
+performance for prolonged periods of time.</p>
+
+<p><img src="../images/power_sustained_perf.png"></p>
+<p class="img-caption"><strong>Figure 1.</strong> Sustained performance mode
+architecture</p>
+
+<h3 id=implementation>Implementation</h3>
+<p>To support sustained performance in Android 7.0, OEMs must:</p>
+<ul>
+<li>Make device-specific changes to the power HAL to either lock the maximum
+CPU/GPU frequencies <strong>or</strong> perform other optimizations to prevent
+thermal throttling.</li>
+<li>Implement the new hint <code>POWER_HINT_SUSTAINED_PERFORMANCE</code> in
+power HAL.</li>
+<li>Declare support by returning TRUE through the
+<code>isSustainedPerformanceModeSupported()</code> API.</li>
+<li>Implement <code>Window.setSustainedPerformanceMode</code>.</li>
+</ul>
+
+<p>In the Nexus reference implementation, the power hint caps the
+maximum frequencies of the CPU and GPU at the highest sustainable levels. Keep
+in mind that lowering the MAX bar in CPU/GPU frequency will lower the frame
+rate, but this lower rate is preferred in this mode due to its sustainability.
+For example, a device using normal max clocks might be able to render at 60
+FPS for a few minutes, but after the device heats up,  it may throttle to 30 FPS
+by the end of 30 minutes. When using sustained mode, the device can, for
+example, render consistently at 45 FPS for the entire 30 minutes. The goal is a
+frame rate when using the mode that is as high (or higher) than the frame rate
+when not using the mode, and consistent over time so that developers don't have
+to chase a moving target.</p>
+<p>We strongly recommend implementing sustained mode such that the device
+achieves the highest possible sustained performance—not just the minimum values
+required to pass the test (e.g. choose the highest possible MAX frequency caps
+that do not cause the device to thermally throttle over time).</p>
+
+<p class="note"><strong>Note</strong>: Capping MAX clock rates is not required
+to implement sustained mode.</p>
+
+
+<h3 id=validation>Validation</h3>
+<p>OEMs can use a new Android 7.0 CTS test to verify their implementation of the
+sustained performance API. The test runs a workload for approximately 30 minutes
+and benchmarks the performance with and without sustained mode enabled:</p>
+<ul>
+<li>With sustained mode enabled, the frame rate must remain relatively constant
+(test measures the percentage of change in frame rate over time and requires a
+&lt;5% change).</li>
+<li>With sustained mode enabled, the frame rate must not be lower than the frame
+rate at the end of 30 minutes with the mode disabled.</li>
+</ul>
+<p>In addition, you can manually test your implementation with several CPU- and
+GPU-intensive workloads to ensure the device does not thermally throttle after
+30 minutes of use. In internal testing, we used sample workloads including
+games and benchmarking apps (e.g.
+<a href="https://gfxbench.com/result.jsp">gfxbench</a>).</p>