Merge "Docs: Add Device Admin contents"
diff --git a/src/accessories/audio.jd b/src/accessories/audio.jd
index 9202438..0b61b3f 100644
--- a/src/accessories/audio.jd
+++ b/src/accessories/audio.jd
@@ -74,3 +74,9 @@
 <p class="note"><strong>Note:</strong> The ADK 2012 source code includes an open source Bluetooth stack that
 is built for the Texas Instruments CC2564 chip, but can work with any Bluetooth chip that
 implements a standard Host/Controller Interface (HCI).</p>
+
+<h2 id="midi-over-usb">MIDI over USB and Bluetooth LE</h2>
+<p>Both USB and Bluetooth Low Energy can be used as transports for the
+<a href="http://en.wikipedia.org/wiki/MIDI">MIDI</a> protocol.
+See <a href="{@docRoot}devices/audio/midi.html">MIDI</a> for more information.
+</p>
diff --git a/src/compatibility/cts/development.jd b/src/compatibility/cts/development.jd
index 8494be4..662d94a 100644
--- a/src/compatibility/cts/development.jd
+++ b/src/compatibility/cts/development.jd
@@ -120,3 +120,70 @@
 <p>Follow the <a href="{@docRoot}source/submit-patches.html">Submitting Patches workflow</a>
 to contribute changes to CTS. A reviewer
 will be assigned to your change, and your change should be reviewed shortly!</p>
+
+<h2 id="release-schedule">Release schedule and branch information</h2>
+
+<p>CTS releases follow this schedule.</p>
+
+<p class="note"><strong>Note</strong>: This schedule is tentative and may be
+updated from time to time as CTS for the given Android version matures.</p>
+
+<table>
+<tr>
+  <th>Version</th>
+  <th>Branch</th>
+  <th>Frequency</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+  <td>5.1</td>
+  <td>lollipop-mr1-cts-dev</td>
+  <td>Monthly</td>
+</tr>
+<tr>
+  <td>5.0</td>
+  <td>lollipop-cts-dev</td>
+  <td>Monthly</td>
+</tr>
+<tr>
+  <td>4.4</td>
+  <td>kitkat-cts-dev</td>
+  <td>Odd month (Jan, Mar, etc.)</td>
+</tr>
+<tr>
+  <td>4.3</td>
+  <td>jb-mr2-cts-dev</td>
+  <td>First month of each quarter</td>
+</tr>
+<tr>
+  <td>4.2</td>
+  <td>jb-mr1.1-cts-dev</td>
+  <td>First month of each quarter</td>
+</tr>
+</table>
+
+<h3 id="important-dates">Important Dates during month of the release</h3>
+
+<ul>
+  <li><strong>End of 1st Week</strong>: Code Freeze.  At this point,
+submissions on the current branch will no longer be accepted and will not be
+included in the next version of CTS.  Once we have chosen a candidate for
+release, the branch will again be open and accepting new submissions.
+
+  <li><strong>Second or third week</strong>: CTS is published in the Android
+Open Source Project (AOSP).
+</ul>
+
+<h3 id="auto-merge">Auto-merge flow</h3>
+
+<p>CTS development branches have been setup so that changes submitted to each
+branch will automatically merge as below:<br>
+jb-dev-> jb-mr1.1-cts-dev -> jb-mr2-cts-dev  -> kitkat-cts-dev ->
+lollipop-cts-dev -> lollipop-mr1-cts-dev -> &lt;private-development-branch for
+Android M&gt;</p>
+
+<p>If a changelist (CL) fails to merge correctly, the author of the CL will get
+an email with instructions on how to resolve the conflict. In most of the
+cases, the author of the CL can use the instructions to skip the auto-merge of
+the conflicting CL.</p>
diff --git a/src/devices/audio/images/venn.png b/src/devices/audio/images/venn.png
new file mode 100644
index 0000000..1db4f53
--- /dev/null
+++ b/src/devices/audio/images/venn.png
Binary files differ
diff --git a/src/devices/audio/latency.jd b/src/devices/audio/latency.jd
index 59c3f73..a45bf20 100644
--- a/src/devices/audio/latency.jd
+++ b/src/devices/audio/latency.jd
@@ -50,4 +50,8 @@
   <td>Round-trip audio latency results</td>
   <td><a href="latency_measurements.html">Audio Latency Measurements</a></td>
 </tr>
+<tr>
+  <td>Applications</td>
+  <td><a href="latency_app.html">Audio Latency for App Developers</a></td>
+</tr>
 </table>
diff --git a/src/devices/audio/latency_app.jd b/src/devices/audio/latency_app.jd
new file mode 100644
index 0000000..22e3984
--- /dev/null
+++ b/src/devices/audio/latency_app.jd
@@ -0,0 +1,174 @@
+page.title=Audio Latency for App Developers
+@jd:body
+
+<!--
+    Copyright 2015 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<div id="qv-wrapper">
+  <div id="qv">
+    <h2>In this document</h2>
+    <ol id="auto-toc">
+    </ol>
+  </div>
+</div>
+
+<p>For the lowest audio latency possible, we recommend you use Android native audio
+based on OpenSL ES 1.0.1.</p>
+
+<h2 id=implementation>Implementation checklist</h2>
+
+<p>To use Android native audio:</p>
+
+<ol>
+
+<li>
+Download and install the
+<a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a>.
+In the rest of this document, we'll assume <code>NDKroot</code> is the
+directory where you installed NDK.
+</li>
+
+<li>
+Read the <a href="#supporting">supporting documentation.</a>
+</li>
+
+<li>
+Check for API level 9 or higher.
+</li>
+
+<li>
+Check for feature
+<a href="http://developer.android.com/guide/topics/manifest/uses-feature-element.html#hw-features">android.hardware.audio.low_latency.</a>
+</li>
+
+<li>
+Use the recommended native buffer size and sample rate returned by
+<a href="http://developer.android.com/reference/android/media/AudioManager.html#getProperty(java.lang.String)">android.media.AudioManager.getProperty(java.lang.String)</a>
+<p> <strong>Note</strong>: the same buffer size and sample rate should also be used for input.</p>
+</li>
+
+<li>
+Usually an OpenSL ES buffer count of 1 is sufficient.
+</li>
+
+<li>
+Keep your callback handlers short, without bursty CPU usage or unbounded blocking.  Avoid
+<a href="avoiding_pi.html">priority inversion.</a>
+</li>
+
+<li>
+Consider using
+<a href="avoiding_pi.html#nonBlockingAlgorithms">non-blocking algorithms</a>
+to communicate between input and output callback handlers,
+and between the callback handlers and the rest of your application.
+</li>
+
+</ol>
+
+<h2 id=supporting>Supporting documentation</h2>
+
+<h3 id=opensl_es_1_0_1>OpenSL ES 1.0.1</h3>
+
+<p>
+Use a PDF viewer to review the
+<a href="https://www.khronos.org/registry/sles/specs/OpenSL_ES_Specification_1.0.1.pdf">OpenSL 1.0.1 Specification.</a>
+This is a rather long reference, and not all of it will be relevant to you; but you
+will need to consult it for details on the API.
+</p>
+
+<p class="note">
+<strong>Note</strong>: this document describes the full OpenSL ES 1.0.1, but Android
+native audio is actually based on a subset of OpenSL ES 1.0.1 with some Android-specific extensions.
+</p>
+
+<p>
+Documents describing later versions of OpenSL ES, such as 1.1,
+are not relevant to Android.
+</p>
+
+<h3 id=opensl_es_for_android>OpenSL ES for Android</h3>
+
+<p>
+The document "OpenSL ES for Android" is provided in the NDK installation,
+and is not currently available online.  Open this link in a browser:
+</p>
+
+<pre>
+NDKroot/docs/Additional_library_docs/opensles/index.html
+</pre>
+
+<p>
+You’ll want to skim the whole
+document, but pay special attention to the "Performance" subsection of the
+"Programming notes" section.
+</p>
+
+<p>
+Section "Supported features from OpenSL ES 1.0.1"
+describes the subset supported by Android.
+</p>
+
+<p>
+Section "Android extensions" describes Android-specific extensions
+that aren't included in base OpenSL ES 1.0.1.
+</p>
+
+<h3 id=relationship>Relationship with OpenSL ES 1.0.1</h3>
+
+<p>
+This Venn diagram shows the relationship between
+Android native audio and OpenSL ES 1.0.1.
+</p>
+
+<img src="images/venn.png" alt="Venn diagram" id="figure1" />
+<p class="img-caption">
+  <strong>Figure 1.</strong> Venn diagram
+</p>
+
+<h2 id=resources>Other resources</h2>
+
+<h3 id=source_android_com>source.android.com</h3>
+
+<p>
+The site <a href="{@docRoot}">source.android.com</a>
+is primarily designed for OEMs building Android
+devices, and the SoC vendors who supply components to these OEMs.
+</p>
+
+<p>
+However, there is a wealth of useful information about latency at this site, so
+you may want to review it.  See the articles at
+<a href="latency.html">Audio Latency.</a>
+</p>
+
+<h3 id=android_ndk>android-ndk</h3>
+
+<p>
+If you have questions about how to use Android native audio, you can ask at the discussion group
+<a href="https://groups.google.com/forum/#!forum/android-ndk">android-ndk.</a>
+</p>
+
+<h3 id=videos>Videos</h3>
+
+<dl>
+
+<dt><a href="https://www.youtube.com/watch?v=d3kfEeMZ65c">Google I/O 2013 - High performance audio on Android</a></dt>
+<dd>The whole video is about latency.</dd>
+
+<dt><a href="https://www.youtube.com/watch?v=92fgcUNCHic">Google I/O 2014 - Building great multi-media experiences on Android</a></dt>
+<dd>The first 14 minutes are about audio in general and input latency in particular.</dd>
+
+</dl>
diff --git a/src/devices/audio/midi.jd b/src/devices/audio/midi.jd
new file mode 100644
index 0000000..b6fb99b
--- /dev/null
+++ b/src/devices/audio/midi.jd
@@ -0,0 +1,160 @@
+page.title=MIDI
+@jd:body
+
+<!--
+    Copyright 2015 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<div id="qv-wrapper">
+  <div id="qv">
+    <h2>In this document</h2>
+    <ol id="auto-toc">
+    </ol>
+  </div>
+</div>
+
+<p>
+<a href="http://en.wikipedia.org/wiki/MIDI">MIDI</a> (Musical Instrument Digital Interface)
+is a standard protocol for inter-connecting computers with musical instruments, stage lighting,
+and other time-oriented media.
+</p>
+
+<p>
+The physical <a href="http://en.wikipedia.org/wiki/Transport_layer">transport layer</a>
+specified in original MIDI 1.0 is a current loop with
+<a href="http://en.wikipedia.org/wiki/DIN_connector">5-pin DIN</a> connector.
+</p>
+
+<p>
+Since MIDI 1.0, additional transports have been defined, including MIDI over USB
+and a proposed draft for MIDI over
+<a href="http://en.wikipedia.org/wiki/Bluetooth_low_energy">Bluetooth Low Energy</a> (BLE.)
+</p>
+
+<p>
+Strictly speaking, MIDI is unrelated to audio. But since MIDI is commonly used with
+music, this article is placed in the audio section.
+</p>
+
+<h2>MIDI for Android</h2>
+
+<p>
+Android 3.1 and later support
+<a href="http://en.wikipedia.org/wiki/USB_On-The-Go">USB On-The-Go</a>,
+which permits an Android device to act as USB host to drive USB
+peripherals. The USB host mode APIs introduced in Android 3.1 permit
+developers to implement MIDI over USB at the application level, but until
+recently there have been no built-in platform APIs for MIDI.
+</p>
+
+<p>
+Beginning with the Android M release, device makers can enable optional MIDI support in the platform.
+Supported transports include USB, draft BLE, and virtual (inter-app).
+</p>
+
+<p>
+For details on application programming with the new MIDI APIs, see the
+<a href="https://android-preview.googleplex.com/reference/android/media/midi/package-summary.html">android.media.midi</a>
+package.
+</p>
+
+<p>
+The remainder of this article discusses how an Android device maker can
+enable MIDI support in the platform.
+</p>
+
+<h2>Enabling transports</h2>
+
+<h3>USB host mode</h3>
+
+<p>
+To enable MIDI for USB host mode, first support USB host mode in general, and
+then enable <code>CONFIG_SND_RAWMIDI</code> in your kernel configuration.
+</p>
+
+<h3>USB peripheral mode</h3>
+
+<p>
+To enable MIDI for USB peripheral mode, you may need to apply patches
+to your Linux kernel to integrate the
+<code>drivers/usb/gadget/f_midi.c</code> into the USB gadget
+driver. As of this writing, these patches are available for Linux kernel version
+3.10. These patches have not yet been updated for
+<a href="http://en.wikipedia.org/wiki/Configfs">ConfigFs</a>
+(a new architecture
+for USB gadget drivers), nor are they merged at upstream
+<a href="http://kernel.org"</a>kernel.org</a>.
+</p>
+
+<p>
+The patches are shown in commit order for the <code>tegra</code> tree:
+</p>
+<ol>
+<li><a href="https://android.googlesource.com/kernel/tegra/+/261230ce54cfc119efe643fc1d128e431d1678d3"</a>261230ce54cfc119efe643fc1d128e431d1678d3</a></li>
+<li><a href="https://android.googlesource.com/kernel/tegra/+/3f048135f3028e503d9d6e32b602e362bd9f374f"</a>3f048135f3028e503d9d6e32b602e362bd9f374f</a></li>
+<li><a href="https://android.googlesource.com/kernel/tegra/+/ae2019d83ecf14454315240c16dc3136212f0da2"</a>ae2019d83ecf14454315240c16dc3136212f0da2</a></li>
+</ol>
+
+<p>
+In addition, the end user must also check the box for MIDI
+in the <em>Settings</em> dialog for <em>Select USB configuration</em>,
+or by pulling down from the top of screen while attached
+to the USB host, and choosing <strong>MIDI</strong> for "Use USB for ...".
+</p>
+
+<h3>BLE</h3>
+
+<p>
+MIDI over BLE is always enabled.
+As this transport is in draft status, it is subject to change.
+</p>
+
+<h3>Virtual (inter-app)</h3>
+
+<p>
+The virtual (inter-app) transport is always enabled.
+</p>
+
+<h2>Claiming the feature</h2>
+
+<p>
+Applications can screen for the presence of MIDI support using the
+<code>android.software.midi</code> feature.
+</p>
+
+<p>
+To claim MIDI support, add this line to your <code>device.mk</code>:
+</p>
+<pre>
+PRODUCT_COPY_FILES += \
+frameworks/native/data/etc/android.software.midi.xml:system/etc/permissions/android.software.midi.xml
+</pre>
+
+<p>
+See the
+<a href="{@docRoot}compatibility/android-cdd.pdf">Android Compatibility Definition Document (CDD)</a>
+for information
+on requirements to claim the feature.
+</p>
+
+<h2 id="hostDebugging">Debugging while in host mode</h2>
+
+<p>
+While in USB host mode, Android Debug Bridge (adb) debugging over USB is unavailable.
+See section <a href="http://developer.android.com/tools/help/adb.html#wireless">Wireless usage</a>
+of
+<a href="http://developer.android.com/tools/help/adb.html">Android Debug Bridge</a>
+for an alternative.
+</p>
diff --git a/src/devices/devices_toc.cs b/src/devices/devices_toc.cs
index f812ccf..10a5dbb 100644
--- a/src/devices/devices_toc.cs
+++ b/src/devices/devices_toc.cs
@@ -46,11 +46,13 @@
               <li><a href="<?cs var:toroot ?>devices/audio/testing_circuit.html">Light Testing Circuit</a></li>
               <li><a href="<?cs var:toroot ?>devices/audio/loopback.html">Audio Loopback Dongle</a></li>
               <li><a href="<?cs var:toroot ?>devices/audio/latency_measurements.html">Measurements</a></li>
+              <li><a href="<?cs var:toroot ?>devices/audio/latency_app.html">Applications</a></li>
             </ul>
           </li>
           <li><a href="<?cs var:toroot ?>devices/audio/avoiding_pi.html">Priority Inversion</a></li>
           <li><a href="<?cs var:toroot ?>devices/audio/src.html">Sample Rate Conversion</a></li>
           <li><a href="<?cs var:toroot ?>devices/audio/debugging.html">Debugging</a></li>
+          <li><a href="<?cs var:toroot ?>devices/audio/midi.html">MIDI</a></li>
           <li><a href="<?cs var:toroot ?>devices/audio/usb.html">USB Digital Audio</a></li>
           <li><a href="<?cs var:toroot ?>devices/audio/tv.html">TV Audio</a></li>
         </ul>
@@ -237,20 +239,6 @@
         </div>
       </li>
 
-      <li><a href="<?cs var:toroot ?>devices/tech/kernel.html">Kernel</a></li>
-
-      <li class="nav-section">
-        <div class="nav-section-header">
-            <a href="<?cs var:toroot ?>devices/tech/ram/index.html">
-              <span class="en">RAM</span>
-            </a>
-        </div>
-        <ul>
-          <li><a href="<?cs var:toroot ?>devices/tech/ram/low-ram.html">Low RAM</a></li>
-          <li><a href="<?cs var:toroot ?>devices/tech/ram/procstats.html">Viewing RAM Usage Data</a></li>
-        </ul>
-      </li>
-
       <li class="nav-section">
         <div class="nav-section-header">
             <a href="<?cs var:toroot ?>devices/tech/ota/index.html">
@@ -266,14 +254,12 @@
         </ul>
       </li>
 
-      <li><a href="<?cs var:toroot ?>devices/tech/netstats.html">Network Data</a></li>
-
       <li class="nav-section">
         <div class="nav-section-header">
           <a href="<?cs var:toroot ?>devices/tech/power/index.html"><span class="en">Power</span></a>
         </div>
         <ul>
-          <li><a href="<?cs var:toroot ?>devices/tech/power/batterystats.html">Viewing Battery Usage Data</a></li>
+          <li><a href="<?cs var:toroot ?>devices/tech/power/batterystats.html">Battery Usage Data</a></li>
         </ul>
       </li>
 
@@ -346,6 +332,29 @@
           </ul>
         </li>
       </ul>
+
+      <li class="nav-section">
+        <div class="nav-section-header">
+            <a href="<?cs var:toroot ?>devices/tech/resources.html">
+              <span class="en">System Resources</span>
+            </a>
+        </div>
+        <ul>
+          <li><a href="<?cs var:toroot ?>devices/tech/kernel.html">Kernel Configuration</a></li>
+          <li><a href="<?cs var:toroot ?>devices/tech/netstats.html">Network Usage Data</a></li>
+          <li class="nav-section">
+            <div class="nav-section-header">
+                <a href="<?cs var:toroot ?>devices/tech/ram/index.html">
+                  <span class="en">RAM</span>
+                </a>
+            </div>
+            <ul>
+              <li><a href="<?cs var:toroot ?>devices/tech/ram/low-ram.html">Low RAM Configuration</a></li>
+              <li><a href="<?cs var:toroot ?>devices/tech/ram/procstats.html">RAM Usage Data</a></li>
+            </ul>
+          </li>
+        </ul>
+
       <li class="nav-section">
         <div class="nav-section-header">
           <a href="<?cs var:toroot ?>devices/tech/test_infra/tradefed/index.html">
diff --git a/src/devices/tech/resources.jd b/src/devices/tech/resources.jd
new file mode 100644
index 0000000..dade1a7
--- /dev/null
+++ b/src/devices/tech/resources.jd
@@ -0,0 +1,20 @@
+page.title=System Resources
+@jd:body
+
+<!--
+    Copyright 2015 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<p> The following sections contain information, documentation, tips and tricks about Android system resources.</p>