Merge "Add density requirements for watches" into mnc-dev
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 8cec7ea..34246cc 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -41,7 +41,7 @@
 
 LOCAL_PACKAGE_NAME := CtsVerifier
 
-LOCAL_AAPT_FLAGS += --version-name "6.0_r0 $(BUILD_NUMBER)"
+LOCAL_AAPT_FLAGS += --version-name "6.0_r1 $(BUILD_NUMBER)"
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsverifier_jni libaudioloopback_jni
 
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 9d9b6df..e1d4eb0 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -754,7 +754,7 @@
             android:screenOrientation="locked" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST"/>
+                <category android:name="android.cts.intent.category.MANUAL_TEST_disabled"/>
             </intent-filter>
 
             <meta-data
@@ -763,8 +763,6 @@
             <meta-data
                 android:name="test_required_features"
                 android:value="android.hardware.sensor.accelerometer:android.hardware.sensor.gyroscope:android.hardware.sensor.compass:android.hardware.camera.any" />
-            <meta-data android:name="test_excluded_features"
-                    android:value="android.hardware.type.television" />
         </activity>
         <activity
             android:name=".sensors.RVCVRecordActivity"
@@ -1742,6 +1740,7 @@
             </intent-filter>
             <meta-data android:name="test_category" android:value="@string/test_category_audio" />
             <meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
+            <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" />
             <meta-data android:name="test_excluded_features" android:value="android.hardware.type.watch" />
             <meta-data android:name="test_excluded_features" android:value="android.hardware.type.television" />
         </activity>
diff --git a/apps/CtsVerifier/res/layout/audio_frequency_line_activity.xml b/apps/CtsVerifier/res/layout/audio_frequency_line_activity.xml
index 69e3bc7..c1b62af 100644
--- a/apps/CtsVerifier/res/layout/audio_frequency_line_activity.xml
+++ b/apps/CtsVerifier/res/layout/audio_frequency_line_activity.xml
@@ -13,60 +13,105 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:padding="10dip"
+    android:orientation="vertical"
+>
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:padding="10dip"
-        android:orientation="vertical">
+        android:layout_height="match_parent"
+        android:id="@+id/scrollView"
+    >
 
-  <TextView
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:scrollbars="vertical"
-      android:gravity="bottom"
-      android:id="@+id/info_text"
-      android:text="@string/audio_frequency_line_instructions" />
-  <LinearLayout
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:orientation="vertical">
-      <Button
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:id="@+id/audio_frequency_line_plug_ready_btn"
-          android:text="@string/audio_frequency_line_plug_ready_btn"/>
-
-    <LinearLayout
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-
-     <LinearLayout
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:orientation="horizontal"
-          android:id="@+id/audio_frequency_line_layout">
-            <Button
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/audio_frequency_line_test_btn"
-                android:id="@+id/audio_frequency_line_test_btn"/>
-
-            <ProgressBar
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:id="@+id/audio_frequency_line_progress_bar"/>
-        </LinearLayout>
-
-        <TextView
-            android:layout_width="wrap_content"
+        <LinearLayout
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="@string/audio_frequency_line_results_text"
-            android:id="@+id/audio_frequency_line_results_text"/>
+            android:orientation="vertical"
+        >
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:scrollbars="vertical"
+                android:gravity="bottom"
+                android:id="@+id/audio_general_headset_port_exists"
+                android:text="@string/audio_general_headset_port_exists" />
 
-    </LinearLayout>
-    </LinearLayout>
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+            >
 
-  <include layout="@layout/pass_fail_buttons" />
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_general_headset_no"
+                    android:text="@string/audio_general_headset_no" />
+
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_general_headset_yes"
+                    android:text="@string/audio_general_headset_yes" />
+
+            </LinearLayout>
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:scrollbars="vertical"
+                android:gravity="bottom"
+                android:id="@+id/info_text"
+                android:text="@string/audio_frequency_line_instructions" />
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+            >
+                <Button
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_frequency_line_plug_ready_btn"
+                    android:text="@string/audio_frequency_line_plug_ready_btn" />
+
+                <LinearLayout
+                    android:orientation="vertical"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                >
+
+                    <LinearLayout
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:orientation="horizontal"
+                        android:id="@+id/audio_frequency_line_layout"
+                    >
+                        <Button
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:text="@string/audio_frequency_line_test_btn"
+                            android:id="@+id/audio_frequency_line_test_btn" />
+
+                        <ProgressBar
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:id="@+id/audio_frequency_line_progress_bar" />
+                    </LinearLayout>
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/audio_frequency_line_results_text"
+                        android:id="@+id/audio_frequency_line_results_text" />
+
+                </LinearLayout>
+            </LinearLayout>
+
+            <include layout="@layout/pass_fail_buttons" />
+        </LinearLayout>
+    </ScrollView>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml b/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml
index 10b0003..db52998 100644
--- a/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml
+++ b/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml
@@ -18,116 +18,151 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:padding="10dip"
-    android:orientation="vertical">
+    android:orientation="vertical"
+>
 
     <ScrollView
-       android:layout_width="match_parent"
-       android:layout_height="match_parent"
-       android:id="@+id/scrollView">
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/scrollView"
+    >
 
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:orientation="vertical">
+            android:orientation="vertical"
+        >
 
-        <LinearLayout
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:scrollbars="vertical"
+                android:gravity="bottom"
+                android:id="@+id/audio_general_headset_port_exists"
+                android:text="@string/audio_general_headset_port_exists" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+            >
+
+                <Button
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:orientation="horizontal">
-          <TextView
-              android:layout_width="wrap_content"
-              android:layout_height="wrap_content"
-              android:layout_weight="1"
-              android:id="@+id/info_text"
-              android:text="@string/audio_frequency_mic_instructions"/>
+                    android:id="@+id/audio_general_headset_no"
+                    android:text="@string/audio_general_headset_no" />
 
-           <ProgressBar
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_weight="1"
-                        android:id="@+id/audio_frequency_mic_progress_bar"/>
-         </LinearLayout>
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_general_headset_yes"
+                    android:text="@string/audio_general_headset_yes" />
 
-          <Button
-              android:layout_width="match_parent"
-              android:layout_height="wrap_content"
-              android:id="@+id/audio_frequency_mic_speakers_ready_btn"
-              android:text="@string/audio_frequency_mic_speakers_ready_btn"/>
+            </LinearLayout>
 
-          <TextView
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+            >
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:id="@+id/info_text"
+                    android:text="@string/audio_frequency_mic_instructions" />
+
+                <ProgressBar
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:id="@+id/audio_frequency_mic_progress_bar" />
+            </LinearLayout>
+
+            <Button
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/audio_frequency_mic_speakers_ready_btn"
+                android:text="@string/audio_frequency_mic_speakers_ready_btn" />
+
+            <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:scrollbars="vertical"
                 android:gravity="bottom"
                 android:id="@+id/audio_frequency_mic_speakers_ready_status"
-                android:text="@string/audio_frequency_mic_speakers_ready_status"/>
+                android:text="@string/audio_frequency_mic_speakers_ready_status" />
 
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:orientation="vertical"
-                android:id="@+id/audio_frequency_mic_layout_test1">
+                android:id="@+id/audio_frequency_mic_layout_test1"
+            >
 
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/audio_frequency_mic_instructions2"
-                android:id="@+id/audio_frequency_mic_instructions2"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/audio_frequency_mic_instructions2"
+                    android:id="@+id/audio_frequency_mic_instructions2" />
 
-              <Button
+                <Button
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/audio_frequency_mic_test1_btn"
-                    android:id="@+id/audio_frequency_mic_test1_btn"/>
+                    android:id="@+id/audio_frequency_mic_test1_btn" />
 
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/audio_frequency_mic_results_text"
-                    android:id="@+id/audio_frequency_mic_results1_text"/>
-          </LinearLayout>
+                    android:id="@+id/audio_frequency_mic_results1_text" />
+            </LinearLayout>
 
-          <LinearLayout
+            <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:orientation="vertical"
-                android:id="@+id/audio_frequency_mic_layout_test2a">
+                android:id="@+id/audio_frequency_mic_layout_test2a"
+            >
 
-            <Button
+                <Button
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_frequency_mic_mic_ready_btn"
+                    android:text="@string/audio_frequency_mic_mic_ready_btn" />
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/audio_frequency_mic_usb_status"
+                    android:id="@+id/audio_frequency_mic_usb_status" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:orientation="vertical"
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:id="@+id/audio_frequency_mic_mic_ready_btn"
-                android:text="@string/audio_frequency_mic_mic_ready_btn"/>
+                android:layout_height="match_parent"
+                android:id="@+id/audio_frequency_mic_layout_test2b"
+            >
 
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/audio_frequency_mic_usb_status"
-                android:id="@+id/audio_frequency_mic_usb_status"/>
-           </LinearLayout>
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/audio_frequency_mic_test2_btn"
+                    android:id="@+id/audio_frequency_mic_test2_btn" />
 
-          <LinearLayout
-              android:orientation="vertical"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:id="@+id/audio_frequency_mic_layout_test2b">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/audio_frequency_mic_results_text"
+                    android:id="@+id/audio_frequency_mic_results_text" />
 
-            <Button
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/audio_frequency_mic_test2_btn"
-                android:id="@+id/audio_frequency_mic_test2_btn"/>
+            </LinearLayout>
 
-              <TextView
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:text="@string/audio_frequency_mic_results_text"
-                  android:id="@+id/audio_frequency_mic_results_text"/>
-
+            <include layout="@layout/pass_fail_buttons" />
         </LinearLayout>
-
-        <include layout="@layout/pass_fail_buttons"/>
-        </LinearLayout>
-      </ScrollView>
+    </ScrollView>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/audio_loopback_activity.xml b/apps/CtsVerifier/res/layout/audio_loopback_activity.xml
index 626ac4f..815f2bc 100644
--- a/apps/CtsVerifier/res/layout/audio_loopback_activity.xml
+++ b/apps/CtsVerifier/res/layout/audio_loopback_activity.xml
@@ -13,71 +13,120 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:padding="10dip"
-        android:orientation="vertical">
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:padding="10dip"
+    android:orientation="vertical"
+>
 
-  <TextView
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:scrollbars="vertical"
-      android:gravity="bottom"
-      android:id="@+id/info_text"
-      android:text="@string/audio_loopback_instructions" />
-  <LinearLayout
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:orientation="vertical">
-      <Button
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:id="@+id/audio_loopback_plug_ready_btn"
-          android:text="@string/audio_loopback_plug_ready_btn"/>
-
-    <LinearLayout
-        android:orientation="vertical"
+    <ScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:id="@+id/audio_loopback_layout">
+        android:id="@+id/scrollView"
+    >
 
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/audio_loopback_instructions2"
-            android:id="@+id/audio_loopback_instructions2"/>
-
-        <SeekBar
+        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:id="@+id/audio_loopback_level_seekbar"/>
+            android:orientation="vertical"
+        >
 
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/audio_loopback_level_text"
-            android:id="@+id/audio_loopback_level_text"/>
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:scrollbars="vertical"
+                android:gravity="bottom"
+                android:id="@+id/audio_general_headset_port_exists"
+                android:text="@string/audio_general_headset_port_exists" />
 
-        <Button
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/audio_loopback_test_btn"
-            android:id="@+id/audio_loopback_test_btn"/>
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+            >
 
-        <ProgressBar
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:id="@+id/audio_loopback_progress_bar"/>
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_general_headset_no"
+                    android:text="@string/audio_general_headset_no" />
 
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/audio_loopback_results_text"
-            android:id="@+id/audio_loopback_results_text"/>
-    </LinearLayout>
-    </LinearLayout>
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_general_headset_yes"
+                    android:text="@string/audio_general_headset_yes" />
 
-  <include layout="@layout/pass_fail_buttons" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:id="@+id/audio_loopback_headset_port"
+            >
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:scrollbars="vertical"
+                    android:gravity="bottom"
+                    android:id="@+id/info_text"
+                    android:text="@string/audio_loopback_instructions" />
+
+                <Button
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/audio_loopback_plug_ready_btn"
+                    android:text="@string/audio_loopback_plug_ready_btn" />
+
+                <LinearLayout
+                    android:orientation="vertical"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:id="@+id/audio_loopback_layout"
+                >
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/audio_loopback_instructions2"
+                        android:id="@+id/audio_loopback_instructions2" />
+
+                    <SeekBar
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:id="@+id/audio_loopback_level_seekbar" />
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/audio_loopback_level_text"
+                        android:id="@+id/audio_loopback_level_text" />
+
+                    <Button
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/audio_loopback_test_btn"
+                        android:id="@+id/audio_loopback_test_btn" />
+
+                    <ProgressBar
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:id="@+id/audio_loopback_progress_bar" />
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/audio_loopback_results_text"
+                        android:id="@+id/audio_loopback_results_text" />
+                </LinearLayout>
+
+            </LinearLayout>
+            <include layout="@layout/pass_fail_buttons" />
+        </LinearLayout>
+    </ScrollView>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/keychain_main.xml b/apps/CtsVerifier/res/layout/keychain_main.xml
index 01eb255..3f695cd 100644
--- a/apps/CtsVerifier/res/layout/keychain_main.xml
+++ b/apps/CtsVerifier/res/layout/keychain_main.xml
@@ -24,22 +24,36 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
-        android:padding="10dip" >
+        android:padding="10dip">
 
-        <TextView
-            android:id="@+id/test_instruction"
-            style="@style/InstructionsFont"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_weight="0" />
-
-        <TextView
-            android:id="@+id/test_log"
+        <ScrollView
             android:layout_width="match_parent"
             android:layout_height="0dp"
             android:layout_weight="1"
-            android:layout_gravity="bottom"
-            android:orientation="vertical" />
+            android:fillViewport="true">
+
+            <LinearLayout
+                android:id="@+id/test_messages"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/test_instruction"
+                    style="@style/InstructionsFont"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="0" />
+
+                <TextView
+                    android:id="@+id/test_log"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1"
+                    android:orientation="vertical" />
+
+            </LinearLayout>
+        </ScrollView>
 
         <LinearLayout
             android:id="@+id/action_buttons"
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 68f9d82..1c4ec06 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1277,6 +1277,7 @@
     <string name="provisioning_byod_no_video_capture_resolver">No video capture app present. Skip test.</string>
     <string name="provisioning_byod_no_audio_capture_resolver">No audio capture app present. Skip test.</string>
     <string name="provisioning_byod_capture_media_error">Error while capturing media from managed profile.</string>
+    <string name="provisioning_byod_capture_image_error">Error while capturing image from managed profile.</string>
 
     <string name="provisioning_byod_auth_bound_key">Autentication-boud keys</string>
     <string name="provisioning_byod_auth_bound_key_info">
@@ -2068,14 +2069,19 @@
     <string name="audio_routingnotification_trackRoutingMsg">AudioTrack rerouting</string>
     <string name="audio_routingnotification_recordRoutingMsg">AudioRecord rerouting</string>
 
+    <!-- Audio general text -->
+    <string name="audio_general_headset_port_exists">Does this device have a headset port?</string>
+    <string name="audio_general_headset_no">No</string>
+    <string name="audio_general_headset_yes">Yes</string>
+
     <!-- Audio Loopback Latency Test -->
     <string name="audio_loopback_test">Audio Loopback Latency Test</string>
      <string name="audio_loopback_info">
-          This test requires the Loopback Plug. Please connect a Loopback Plug on the headset
+          This test requires the Loopback Plug. Please connect a Loopback Plug into the headset
           connector, and proceed with the instructions on the screen.
           The system will measure the input-output audio latency by injecting a pulse on the output,
           and computing the distance between replicas of the pulse.
-          You can vary the Audio Level slider to ensure the pulse will feed back at adecuate levels.
+          You can vary the Audio Level slider to ensure the pulse will feed back at adequate levels.
           Repeat until a confidence level >= 0.6 is achieved.
     </string>
     <string name="audio_loopback_instructions">
@@ -2110,7 +2116,7 @@
     <string name="audio_frequency_speaker_test">Audio Frequency Speaker Test</string>
     <string name="audio_frequency_speaker_info">
         This test requires an external USB reference microphone. Please connect the USB microphone and proceed with the instructions on the screen.
-        The system will measure frequency response of the left and right speakers (if there are two speakers), or twice the response of the mono speaker.
+        The system will measure frequency response of the left and right speakers (if there are two speakers), or the response of the mono speaker twice.
        </string>
     <string name="audio_frequency_speaker_instructions">
           Please connect an USB reference microphone and press "USB Reference microphone ready"
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyLineActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyLineActivity.java
index d3e2571..508fae0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyLineActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyLineActivity.java
@@ -64,6 +64,9 @@
     OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
     Context mContext;
 
+    Button mHeadsetPortYes;
+    Button mHeadsetPortNo;
+
     Button mLoopbackPlugReady;
     LinearLayout mLinearLayout;
     Button mTestButton;
@@ -116,6 +119,20 @@
                     Log.i(TAG, "audio loopback test");
                     startAudioTest();
                     break;
+                case R.id.audio_general_headset_yes:
+                    Log.i(TAG, "User confirms Headset Port existence");
+                    mLoopbackPlugReady.setEnabled(true);
+                    recordHeasetPortFound(true);
+                    mHeadsetPortYes.setEnabled(false);
+                    mHeadsetPortNo.setEnabled(false);
+                    break;
+                case R.id.audio_general_headset_no:
+                    Log.i(TAG, "User denies Headset Port existence");
+                    recordHeasetPortFound(false);
+                    getPassButton().setEnabled(true);
+                    mHeadsetPortYes.setEnabled(false);
+                    mHeadsetPortNo.setEnabled(false);
+                    break;
             }
         }
     }
@@ -127,8 +144,14 @@
 
         mContext = this;
 
+        mHeadsetPortYes = (Button)findViewById(R.id.audio_general_headset_yes);
+        mHeadsetPortYes.setOnClickListener(mBtnClickListener);
+        mHeadsetPortNo = (Button)findViewById(R.id.audio_general_headset_no);
+        mHeadsetPortNo.setOnClickListener(mBtnClickListener);
+
         mLoopbackPlugReady = (Button)findViewById(R.id.audio_frequency_line_plug_ready_btn);
         mLoopbackPlugReady.setOnClickListener(mBtnClickListener);
+        mLoopbackPlugReady.setEnabled(false);
         mLinearLayout = (LinearLayout)findViewById(R.id.audio_frequency_line_layout);
         mTestButton = (Button)findViewById(R.id.audio_frequency_line_test_btn);
         mTestButton.setOnClickListener(mBtnClickListener);
@@ -479,6 +502,14 @@
         Log.v(TAG, "Results Recorded");
     }
 
+    private void recordHeasetPortFound(boolean found) {
+        getReportLog().addValue(
+                "User Reported Headset Port",
+                found ? 1.0 : 0,
+                ResultType.NEUTRAL,
+                ResultUnit.NONE);
+    }
+
     private void startRecording() {
         synchronized (mRecordingLock) {
             mIsRecording = true;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyMicActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyMicActivity.java
index b37a721..03d84e1 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyMicActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyMicActivity.java
@@ -72,6 +72,9 @@
     final OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
     Context mContext;
 
+    Button mHeadsetPortYes;
+    Button mHeadsetPortNo;
+
     Button mSpeakersReady;              //user signal to have connected external speakers
     Button mTest1Button;                //execute test 1
     Button mUsbMicReady;          //user signal to have connected USB Microphone
@@ -137,6 +140,20 @@
             case R.id.audio_frequency_mic_test2_btn:
                 startTest2();
                 break;
+            case R.id.audio_general_headset_yes:
+                Log.i(TAG, "User confirms Headset Port existence");
+                mSpeakersReady.setEnabled(true);
+                recordHeasetPortFound(true);
+                mHeadsetPortYes.setEnabled(false);
+                mHeadsetPortNo.setEnabled(false);
+                break;
+            case R.id.audio_general_headset_no:
+                Log.i(TAG, "User denies Headset Port existence");
+                recordHeasetPortFound(false);
+                getPassButton().setEnabled(true);
+                mHeadsetPortYes.setEnabled(false);
+                mHeadsetPortNo.setEnabled(false);
+                break;
             }
         }
     }
@@ -146,10 +163,17 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.audio_frequency_mic_activity);
         mContext = this;
+
+        mHeadsetPortYes = (Button)findViewById(R.id.audio_general_headset_yes);
+        mHeadsetPortYes.setOnClickListener(mBtnClickListener);
+        mHeadsetPortNo = (Button)findViewById(R.id.audio_general_headset_no);
+        mHeadsetPortNo.setOnClickListener(mBtnClickListener);
+
         mSpeakerReadyText = (TextView) findViewById(R.id.audio_frequency_mic_speakers_ready_status);
 
         mSpeakersReady  = (Button)findViewById(R.id.audio_frequency_mic_speakers_ready_btn);
         mSpeakersReady.setOnClickListener(mBtnClickListener);
+        mSpeakersReady.setEnabled(false);
         mTest1Button = (Button)findViewById(R.id.audio_frequency_mic_test1_btn);
         mTest1Button.setOnClickListener(mBtnClickListener);
         mTest1Result = (TextView)findViewById(R.id.audio_frequency_mic_results1_text);
@@ -644,6 +668,14 @@
         Log.v(TAG, "Results Recorded");
     }
 
+    private void recordHeasetPortFound(boolean found) {
+        getReportLog().addValue(
+                "User Reported Headset Port",
+                found ? 1.0 : 0,
+                ResultType.NEUTRAL,
+                ResultUnit.NONE);
+    }
+
     private void startRecording() {
         synchronized (mRecordingLock) {
             mIsRecording = true;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java
index e603a69..fbec57a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioLoopbackActivity.java
@@ -61,6 +61,9 @@
     OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
     Context mContext;
 
+    Button mHeadsetPortYes;
+    Button mHeadsetPortNo;
+
     Button mLoopbackPlugReady;
     TextView mAudioLevelText;
     SeekBar mAudioLevelSeekbar;
@@ -83,7 +86,20 @@
                     Log.i(TAG, "audio loopback test");
                     startAudioTest();
                     break;
-
+                case R.id.audio_general_headset_yes:
+                    Log.i(TAG, "User confirms Headset Port existence");
+                    mLoopbackPlugReady.setEnabled(true);
+                    recordHeasetPortFound(true);
+                    mHeadsetPortYes.setEnabled(false);
+                    mHeadsetPortNo.setEnabled(false);
+                    break;
+                case R.id.audio_general_headset_no:
+                    Log.i(TAG, "User denies Headset Port existence");
+                    recordHeasetPortFound(false);
+                    getPassButton().setEnabled(true);
+                    mHeadsetPortYes.setEnabled(false);
+                    mHeadsetPortNo.setEnabled(false);
+                    break;
             }
         }
     }
@@ -95,8 +111,14 @@
 
         mContext = this;
 
+        mHeadsetPortYes = (Button)findViewById(R.id.audio_general_headset_yes);
+        mHeadsetPortYes.setOnClickListener(mBtnClickListener);
+        mHeadsetPortNo = (Button)findViewById(R.id.audio_general_headset_no);
+        mHeadsetPortNo.setOnClickListener(mBtnClickListener);
+
         mLoopbackPlugReady = (Button)findViewById(R.id.audio_loopback_plug_ready_btn);
         mLoopbackPlugReady.setOnClickListener(mBtnClickListener);
+        mLoopbackPlugReady.setEnabled(false);
         mLinearLayout = (LinearLayout)findViewById(R.id.audio_loopback_layout);
         mAudioLevelText = (TextView)findViewById(R.id.audio_loopback_level_text);
         mAudioLevelSeekbar = (SeekBar)findViewById(R.id.audio_loopback_level_seekbar);
@@ -135,7 +157,7 @@
 
         setPassFailButtonClickListeners();
         getPassButton().setEnabled(false);
-        setInfoResources(R.string.sample_test, R.string.audio_loopback_info, -1);
+        setInfoResources(R.string.audio_loopback_test, R.string.audio_loopback_info, -1);
     }
 
     /**
@@ -304,4 +326,12 @@
 
         Log.v(TAG,"Results Recorded");
     }
+
+    private void recordHeasetPortFound(boolean found) {
+        getReportLog().addValue(
+                "User Reported Headset Port",
+                found ? 1.0 : 0,
+                ResultType.NEUTRAL,
+                ResultUnit.NONE);
+    }
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodPresentMediaDialog.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodPresentMediaDialog.java
index b3f126b..15f5bc8 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodPresentMediaDialog.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodPresentMediaDialog.java
@@ -31,10 +31,14 @@
 import android.widget.ImageView;
 import android.widget.Toast;
 import android.widget.VideoView;
-
+import android.view.Display;
+import android.graphics.BitmapFactory;
+import android.graphics.Point;
+import android.content.ContentResolver;
 import com.android.cts.verifier.R;
 
 import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * This dialog shows/plays an image, video or audio uri.
@@ -46,6 +50,7 @@
     private static final String KEY_IMAGE_URI = "image";
     private static final String KEY_AUDIO_URI = "audio";
 
+    private Bitmap scaled = null;
     /**
      * Get a dialogFragment showing an image.
      */
@@ -79,6 +84,16 @@
         return dialog;
     }
 
+    private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight){
+        // Raw height and width of image
+        final int height = options.outHeight;
+        final int width = options.outWidth;
+        if(reqWidth <= 0 || reqHeight <= 0) {
+           return 1;
+        }
+        return Math.max(height/reqHeight, width/reqWidth) + 1;
+    }
+
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         final Dialog dialog = new Dialog(getActivity());
@@ -114,11 +129,36 @@
         } else if (arguments.containsKey(KEY_IMAGE_URI)) {
             // Show image UI.
             dialog.setTitle(getString(R.string.provisioning_byod_verify_image_title));
-
-            Uri uri = (Uri) getArguments().getParcelable(KEY_IMAGE_URI);
+            Uri uri = (Uri)getArguments().getParcelable(KEY_IMAGE_URI);
             ImageView imageView = (ImageView) dialog.findViewById(R.id.imageView);
             imageView.setVisibility(View.VISIBLE);
-            imageView.setImageURI(uri);
+
+            try{
+                InputStream input = getActivity().getContentResolver().openInputStream(uri);
+                BitmapFactory.Options options = new BitmapFactory.Options();
+                options.inJustDecodeBounds = true;
+                BitmapFactory.decodeStream(input, null, options);
+                //scale the picture
+                Display display = getActivity().getWindowManager().getDefaultDisplay();
+                Point size = new Point();
+                display.getSize(size);
+                int reqWidth = size.x;
+                int reqHeight = size.y;
+                options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
+
+                options.inJustDecodeBounds = false;
+                input.close();
+                input = getActivity().getContentResolver().openInputStream(uri);
+                scaled = BitmapFactory.decodeStream(input, null, options);
+                input.close();
+                imageView.setImageBitmap(scaled);
+            }catch(IOException e){
+                Log.e(TAG, "Cannot get image.", e);
+                Toast.makeText(getActivity(),R.string.provisioning_byod_capture_image_error,
+                        Toast.LENGTH_SHORT).show();
+                getActivity().finish();
+            }
+
         } else if (arguments.containsKey(KEY_AUDIO_URI)) {
             // Show audio playback UI.
             dialog.setTitle(getString(R.string.provisioning_byod_verify_audio_title));
@@ -161,6 +201,13 @@
         ((DialogCallback) getActivity()).onDialogClose();
     }
 
+    @Override
+    public void onDestroyView() {
+        if(scaled!=null){
+            scaled.recycle();
+        }
+        super.onDestroyView();
+    }
     public interface DialogCallback {
         public abstract void onDialogClose();
     }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
index 70899c6..bca7a66 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
@@ -89,6 +89,22 @@
         if (requestCode == FINGERPRINT_PERMISSION_REQUEST_CODE && state[0] == PackageManager.PERMISSION_GRANTED) {
             mFingerprintManager = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
             mKeyguardManager = (KeyguardManager) getSystemService(KeyguardManager.class);
+            Button startTestButton = (Button) findViewById(R.id.sec_start_test_button);
+
+            if (!mKeyguardManager.isKeyguardSecure()) {
+                // Show a message that the user hasn't set up a lock screen.
+                showToast( "Secure lock screen hasn't been set up.\n"
+                                + "Go to 'Settings -> Security -> Screen lock' to set up a lock screen");
+                startTestButton.setEnabled(false);
+                return;
+            } else if (!mFingerprintManager.hasEnrolledFingerprints()) {
+                showToast("No fingerprints enrolled.\n"
+                                + "Go to 'Settings -> Security -> Fingerprint' to set up a fingerprint");
+                startTestButton.setEnabled(false);
+                return;
+            }
+
+            createKey();
 
             try {
                 KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
@@ -107,7 +123,6 @@
                 throw new RuntimeException("Failed to init Cipher", e);
             }
 
-            Button startTestButton = (Button) findViewById(R.id.sec_start_test_button);
             startTestButton.setOnClickListener(new OnClickListener() {
                 @Override
                 public void onClick(View v) {
@@ -117,21 +132,7 @@
                         showAuthenticationScreen();
                     }
                 }
-
             });
-
-            if (!mKeyguardManager.isKeyguardSecure()) {
-                // Show a message that the user hasn't set up a lock screen.
-                showToast( "Secure lock screen hasn't been set up.\n"
-                                + "Go to 'Settings -> Security -> Screen lock' to set up a lock screen");
-                startTestButton.setEnabled(false);
-            } else if (!mFingerprintManager.hasEnrolledFingerprints()) {
-                showToast("No fingerprints enrolled.\n"
-                                + "Go to 'Settings -> Security -> Fingerprint' to set up a fingerprint");
-                startTestButton.setEnabled(false);
-            } else {
-                createKey();
-            }
         }
     }
 
diff --git a/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java b/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java
index a0d3167..abb1ac4 100644
--- a/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java
@@ -589,9 +589,9 @@
         assertDomainN("u:r:zygote:s0", "zygote", "zygote64");
     }
 
-    /* drm server is always present */
+    /* Checks drmserver for devices that require it */
     public void testDrmServerDomain() throws DeviceNotAvailableException {
-        assertDomainOne("u:r:drmserver:s0", "/system/bin/drmserver");
+        assertDomainZeroOrOne("u:r:drmserver:s0", "/system/bin/drmserver");
     }
 
     /* Media server is always running */
diff --git a/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java b/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
old mode 100644
new mode 100755
index 63c7472..0e11111
--- a/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
+++ b/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
@@ -77,27 +77,42 @@
      * @param threshold maximum difference per channel
      * @return {@code true} if the images are similar, false otherwise
      */
-    private static boolean compare(BufferedImage expected, BufferedImage actual,
-            int threshold) {
-        final int w = actual.getWidth();
-        final int h = actual.getHeight();
-        if (w != expected.getWidth() || h != expected.getHeight()) {
+    private static int getAlphaScaledBlue(final int color) {
+        return (color & 0x000000FF) * getAlpha(color) / 255;
+    }
+
+    private static int getAlphaScaledGreen(final int color) {
+        return ((color & 0x0000FF00) >> 8) * getAlpha(color) / 255;
+    }
+
+    private static int getAlphaScaledRed(final int color) {
+        return ((color & 0x00FF0000) >> 16) * getAlpha(color) / 255;
+    }
+
+    private static int getAlpha(final int color) {
+        // use logical shift for keeping an unsigned value
+        return (color & 0xFF000000) >>> 24;
+    }
+
+    private static boolean compare(BufferedImage reference, BufferedImage generated, int threshold) {
+        final int w = generated.getWidth();
+        final int h = generated.getHeight();
+        if (w != reference.getWidth() || h != reference.getHeight()) {
             return false;
         }
 
         for (int i = 0; i < w; i++) {
             for (int j = 0; j < h; j++) {
-                final int p1 = expected.getRGB(i, j);
-                final int p2 = actual.getRGB(i, j);
-                final int dr = (p1 & 0x000000FF) - (p2 & 0x000000FF);
-                final int dg = ((p1 & 0x0000FF00) - (p2 & 0x0000FF00)) >> 8;
-                final int db = ((p1 & 0x00FF0000) - (p2 & 0x00FF0000)) >> 16;
-                final int da = ((p1 & 0xFF000000) - (p2 & 0xFF000000)) >> 24;
+                final int p1 = reference.getRGB(i, j);
+                final int p2 = generated.getRGB(i, j);
+
+                final int dr = getAlphaScaledRed(p1) - getAlphaScaledRed(p2);
+                final int dg = getAlphaScaledGreen(p1) - getAlphaScaledGreen(p2);
+                final int db = getAlphaScaledBlue(p1) - getAlphaScaledBlue(p2);
 
                 if (Math.abs(db) > threshold ||
                         Math.abs(dg) > threshold ||
-                        Math.abs(dr) > threshold ||
-                        Math.abs(da) > threshold) {
+                        Math.abs(dr) > threshold) {
                     return false;
                 }
             }
diff --git a/libs/deviceutil/src/android/cts/util/MediaUtils.java b/libs/deviceutil/src/android/cts/util/MediaUtils.java
index 4e4a07d..b3ebbad 100755
--- a/libs/deviceutil/src/android/cts/util/MediaUtils.java
+++ b/libs/deviceutil/src/android/cts/util/MediaUtils.java
@@ -337,6 +337,27 @@
         return check(hasCodecsForPath(context, path), "no decoder found");
     }
 
+    public static boolean hasCodecForDomain(boolean encoder, String domain) {
+        for (MediaCodecInfo info : sMCL.getCodecInfos()) {
+            if (encoder != info.isEncoder()) {
+                continue;
+            }
+
+            for (String type : info.getSupportedTypes()) {
+                if (type.toLowerCase().startsWith(domain.toLowerCase() + "/")) {
+                    Log.i(TAG, "found codec " + info.getName() + " for mime " + type);
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    public static boolean checkCodecForDomain(boolean encoder, String domain) {
+        return check(hasCodecForDomain(encoder, domain),
+                "no " + domain + (encoder ? " encoder" : " decoder") + " found");
+    }
+
     private static boolean hasCodecForMime(boolean encoder, String mime) {
         for (MediaCodecInfo info : sMCL.getCodecInfos()) {
             if (encoder != info.isEncoder()) {
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index fb28d6d..4c599c0 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -315,5 +315,43 @@
     "android.assist.cts.WebViewTest"
   ],
   bug: 21668302
+},
+{
+  description: "ConnectivityConstraintTest job scheduler not working.",
+  names: [
+     "android.jobscheduler.cts.ConnectivityConstraintTest#testConnectivityConstraintExecutes_withWifi",
+     "android.jobscheduler.cts.ConnectivityConstraintTest#testUnmeteredConstraintExecutes_withWifi"
+  ],
+  bug: 21262226
+},
+{
+   description: "ConnectivityConstraintTest times out.",
+   names: [
+     "android.jobscheduler.cts.TimingConstraintsTest#testJobParameters_unexpiredDeadline"
+   ],
+   bug: 23144425
+},
+{
+   description: "Telephony returning wrong value.",
+   names: [
+     "android.telephony.cts.CellInfoTest#testCellInfo"
+   ],
+   bug: 23979591
+},
+{
+   description: "Video encoding tests are timing out.",
+   names: [
+     "android.media.cts.VideoEncoderTest#testGoogH264FlexArbitraryW",
+     "android.media.cts.VideoEncoderTest#testGoogH264SurfArbitraryW"
+   ],
+   bug: 23827982
+},
+{
+  description: "tests not yet ready",
+  names: [
+    "android.telecom.cts.OutgoingCallTest#testStartCallWithSpeakerphoneFalse_SpeakerphoneOffInCall",
+    "android.telecom.cts.OutgoingCallTest#testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault"
+  ],
+  bug: 24067587
 }
 ]
diff --git a/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java b/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
index b6fef4a..a889c02 100644
--- a/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
+++ b/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
@@ -20,6 +20,7 @@
 import android.app.usage.NetworkStatsManager;
 import android.app.usage.NetworkStats;
 import android.content.Context;
+import android.content.pm.PackageManager;
 import android.net.ConnectivityManager;
 import android.net.Network;
 import android.net.NetworkCapabilities;
@@ -39,7 +40,7 @@
 import java.net.URL;
 import java.text.MessageFormat;
 import java.util.Scanner;
-import javax.net.ssl.HttpsURLConnection;
+import java.net.HttpURLConnection;
 
 import libcore.io.IoUtils;
 import libcore.io.Streams;
@@ -56,14 +57,21 @@
         ConnectivityManager.TYPE_MOBILE,
     };
 
-    // Order corresponds to sNetworkTypesToTest
-    private static final int[] sTransportTypesToTest = new int[] {
-        NetworkCapabilities.TRANSPORT_WIFI,
-        NetworkCapabilities.TRANSPORT_CELLULAR,
+    private static final String[] sSystemFeaturesToTest = new String[] {
+        PackageManager.FEATURE_WIFI,
+        PackageManager.FEATURE_TELEPHONY,
+    };
+
+    private static final String[] sFeatureNotConnectedCause = new String[] {
+        " Please make sure you are connected to a WiFi access point.",
+        " Please make sure you have added a SIM card with data plan to your phone, have enabled " +
+                "data over cellular and in case of dual SIM devices, have selected the right SIM " +
+                "for data connection."
     };
 
     private NetworkStatsManager mNsm;
     private ConnectivityManager mCm;
+    private PackageManager mPm;
     private long mStartTime;
     private long mEndTime;
 
@@ -71,62 +79,50 @@
     private String mWriteSettingsMode;
     private String mUsageStatsMode;
 
-    private void exerciseRemoteHost(int transportType) throws Exception {
+    private void exerciseRemoteHost(Network network) throws Exception {
         final int timeout = 15000;
-        mCm.requestNetwork(new NetworkRequest.Builder()
-            .addTransportType(transportType)
-            .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
-            .build(), new ConnectivityManager.NetworkCallback() {
-                @Override
-                public void onAvailable(Network network) {
-                    NetworkInfo networkInfo = mCm.getNetworkInfo(network);
-                    if (networkInfo == null) {
-                        Log.w(LOG_TAG, "Network info is null");
-                    } else {
-                        Log.w(LOG_TAG, "Network: " + networkInfo.toString());
-                    }
-                    InputStreamReader in = null;
-                    HttpsURLConnection urlc = null;
-                    String originalKeepAlive = System.getProperty("http.keepAlive");
-                    System.setProperty("http.keepAlive", "false");
-                    try {
-                        urlc = (HttpsURLConnection) network.openConnection(new URL(
-                                "https://www.google.com"));
-                        urlc.setConnectTimeout(timeout);
-                        urlc.setUseCaches(false);
-                        urlc.connect();
-                        boolean ping = urlc.getResponseCode() == 200;
-                        if (ping) {
-                            in = new InputStreamReader(
-                                    (InputStream) urlc.getContent());
-
-                            mBytesRead = 0;
-                            while (in.read() != -1) ++mBytesRead;
-                        }
-                    } catch (Exception e) {
-                        Log.i(LOG_TAG, "Badness during exercising remote server: " + e);
-                    } finally {
-                        if (in != null) {
-                            try {
-                                in.close();
-                            } catch (IOException e) {
-                                // don't care
-                            }
-                        }
-                        if (urlc != null) {
-                            urlc.disconnect();
-                        }
-                        if (originalKeepAlive == null) {
-                            System.clearProperty("http.keepAlive");
-                        } else {
-                            System.setProperty("http.keepAlive", originalKeepAlive);
-                        }
-                    }
-                }
-            });
+        NetworkInfo networkInfo = mCm.getNetworkInfo(network);
+        if (networkInfo == null) {
+            Log.w(LOG_TAG, "Network info is null");
+        } else {
+            Log.w(LOG_TAG, "Network: " + networkInfo.toString());
+        }
+        InputStreamReader in = null;
+        HttpURLConnection urlc = null;
+        String originalKeepAlive = System.getProperty("http.keepAlive");
+        System.setProperty("http.keepAlive", "false");
         try {
-            Thread.sleep(timeout);
-        } catch (InterruptedException e) {
+            urlc = (HttpURLConnection) network.openConnection(new URL(
+                    "http://www.265.com/"));
+            urlc.setConnectTimeout(timeout);
+            urlc.setUseCaches(false);
+            urlc.connect();
+            boolean ping = urlc.getResponseCode() == 200;
+            if (ping) {
+                in = new InputStreamReader(
+                        (InputStream) urlc.getContent());
+
+                mBytesRead = 0;
+                while (in.read() != -1) ++mBytesRead;
+            }
+        } catch (Exception e) {
+            Log.i(LOG_TAG, "Badness during exercising remote server: " + e);
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    // don't care
+                }
+            }
+            if (urlc != null) {
+                urlc.disconnect();
+            }
+            if (originalKeepAlive == null) {
+                System.clearProperty("http.keepAlive");
+            } else {
+                System.setProperty("http.keepAlive", originalKeepAlive);
+            }
         }
     }
 
@@ -139,6 +135,8 @@
         mCm = (ConnectivityManager) getInstrumentation().getContext()
                 .getSystemService(Context.CONNECTIVITY_SERVICE);
 
+        mPm = getInstrumentation().getContext().getPackageManager();
+
         mWriteSettingsMode = getAppOpsMode(AppOpsManager.OPSTR_WRITE_SETTINGS);
         setAppOpsMode(AppOpsManager.OPSTR_WRITE_SETTINGS, "allow");
         mUsageStatsMode = getAppOpsMode(AppOpsManager.OPSTR_GET_USAGE_STATS);
@@ -192,14 +190,26 @@
 
     private boolean shouldTestThisNetworkType(int networkTypeIndex, long tolerance)
             throws Exception {
-        NetworkInfo networkInfo = mCm.getNetworkInfo(sNetworkTypesToTest[networkTypeIndex]);
-        if (networkInfo == null || !networkInfo.isAvailable()) {
-            return false;
+        Network[] networks = mCm.getAllNetworks();
+        for (Network network : networks) {
+            NetworkInfo networkInfo = mCm.getNetworkInfo(network);
+            if (networkInfo != null && networkInfo.isConnected() &&
+                    networkInfo.getType() == sNetworkTypesToTest[networkTypeIndex]) {
+                NetworkCapabilities capabilities = mCm.getNetworkCapabilities(network);
+                if (capabilities != null && capabilities.hasCapability(
+                        NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
+                    mStartTime = System.currentTimeMillis() - tolerance;
+                    exerciseRemoteHost(network);
+                    mEndTime = System.currentTimeMillis() + tolerance;
+                    return true;
+                }
+            }
         }
-        mStartTime = System.currentTimeMillis() - tolerance;
-        exerciseRemoteHost(sTransportTypesToTest[networkTypeIndex]);
-        mEndTime = System.currentTimeMillis() + tolerance;
-        return true;
+        assertFalse (sSystemFeaturesToTest[networkTypeIndex] + " is a reported system feature, " +
+                "however no corresponding connected network interface was found. " +
+                sFeatureNotConnectedCause[networkTypeIndex],
+                mPm.hasSystemFeature(sSystemFeaturesToTest[networkTypeIndex]));
+        return false;
     }
 
     private String getSubscriberId(int networkType) {
diff --git a/tests/tests/app/src/android/app/cts/NotificationManagerTest.java b/tests/tests/app/src/android/app/cts/NotificationManagerTest.java
index 5781442..fbb3060 100644
--- a/tests/tests/app/src/android/app/cts/NotificationManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/NotificationManagerTest.java
@@ -74,9 +74,8 @@
         sendNotification(id, R.drawable.black);
         mNotificationManager.cancel(id);
 
-        StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
-        for (StatusBarNotification sbn : sbns) {
-            assertFalse("canceled notification was still alive, id=" + id, sbn.getId() == id);
+        if (!checkNotificationExistence(id, /*shouldExist=*/ false)) {
+            fail("canceled notification was still alive, id=" + id);
         }
     }
 
@@ -116,10 +115,31 @@
                 .build();
         mNotificationManager.notify(id, notification);
 
-        StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
-        for (StatusBarNotification sbn : sbns) {
-            if (sbn.getId() == id) return;
+
+        if (!checkNotificationExistence(id, /*shouldExist=*/ true)) {
+            fail("couldn't find posted notification id=" + id);
         }
-        fail("couldn't find posted notification id=" + id);
+    }
+
+    private boolean checkNotificationExistence(int id, boolean shouldExist) {
+        // notification is a bit asynchronous so it may take a few ms to appear in getActiveNotifications()
+        // we will check for it for up to 200ms before giving up
+        boolean found = false;
+        for (int tries=3; tries-->0;) {
+            final StatusBarNotification[] sbns = mNotificationManager.getActiveNotifications();
+            for (StatusBarNotification sbn : sbns) {
+                if (sbn.getId() == id) {
+                    found = true;
+                    break;
+                }
+            }
+            if (found == shouldExist) break;
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException ex) {
+                // pass
+            }
+        }
+        return found == shouldExist;
     }
 }
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
index 9e75d94..e0a1d4e 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
@@ -69,7 +69,8 @@
     private static final long EXPOSURE_TIME_BOUNDARY_50HZ_NS = 10000000L; // 10ms
     private static final long EXPOSURE_TIME_BOUNDARY_60HZ_NS = 8333333L; // 8.3ms, Approximation.
     private static final long EXPOSURE_TIME_ERROR_MARGIN_NS = 100000L; // 100us, Approximation.
-    private static final int SENSITIVITY_ERROR_MARGIN = 10; // 10
+    private static final float EXPOSURE_TIME_ERROR_MARGIN_RATE = 0.03f; // 3%, Approximation.
+    private static final float SENSITIVITY_ERROR_MARGIN_RATE = 0.03f; // 3%, Approximation.
     private static final int DEFAULT_NUM_EXPOSURE_TIME_STEPS = 3;
     private static final int DEFAULT_NUM_SENSITIVITY_STEPS = 16;
     private static final int DEFAULT_SENSITIVITY_STEP_SIZE = 100;
@@ -2093,10 +2094,12 @@
      */
     private void validateExposureTime(long request, long result) {
         long expTimeDelta = request - result;
+        long expTimeErrorMargin = (long)(Math.max(EXPOSURE_TIME_ERROR_MARGIN_NS, request
+                * EXPOSURE_TIME_ERROR_MARGIN_RATE));
         // First, round down not up, second, need close enough.
         mCollector.expectTrue("Exposture time is invalid for AE manaul control test, request: "
                 + request + " result: " + result,
-                expTimeDelta < EXPOSURE_TIME_ERROR_MARGIN_NS && expTimeDelta >= 0);
+                expTimeDelta < expTimeErrorMargin && expTimeDelta >= 0);
     }
 
     /**
@@ -2106,11 +2109,12 @@
      * @param result Result sensitivity
      */
     private void validateSensitivity(int request, int result) {
-        int sensitivityDelta = request - result;
+        float sensitivityDelta = (float)(request - result);
+        float sensitivityErrorMargin = request * SENSITIVITY_ERROR_MARGIN_RATE;
         // First, round down not up, second, need close enough.
         mCollector.expectTrue("Sensitivity is invalid for AE manaul control test, request: "
                 + request + " result: " + result,
-                sensitivityDelta < SENSITIVITY_ERROR_MARGIN && sensitivityDelta >= 0);
+                sensitivityDelta < sensitivityErrorMargin && sensitivityDelta >= 0);
     }
 
     /**
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
index 52fd69f..de0e3d5 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
@@ -14,6 +14,7 @@
 import static android.hardware.camera2.cts.CameraTestUtils.*;
 import static com.android.ex.camera2.blocking.BlockingSessionCallback.*;
 
+import android.cts.util.MediaUtils;
 import android.graphics.ImageFormat;
 import android.hardware.camera2.CameraCharacteristics;
 import android.hardware.camera2.CameraCaptureSession;
@@ -151,6 +152,9 @@
      * </p>
      */
     public void testRecordingFromPersistentSurface() throws Exception {
+        if (!MediaUtils.checkCodecForDomain(true /* encoder */, "video")) {
+            return; // skipped
+        }
         mPersistentSurface = MediaCodec.createPersistentInputSurface();
         assertNotNull("Failed to create persistent input surface!", mPersistentSurface);
 
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
index a69dc54..9cb3710 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
@@ -40,6 +40,9 @@
     /**
      * Get percentiles using nearest rank algorithm.
      *
+     * @param percentiles List of percentiles interested. Its range is 0 to 1, instead of in %.
+     *        The value will be internally bounded.
+     *
      * @throws IllegalArgumentException if the collection or percentiles is null or empty
      */
     public static <TValue extends Comparable<? super TValue>> List<TValue> getPercentileValue(
@@ -55,7 +58,9 @@
         List<TValue> percentileValues = new ArrayList<TValue>();
         for (float p : percentiles) {
             // zero-based array index
-            int arrayIndex = (int) Math.round(arrayCopy.size() * p + .5) - 1;
+            int arrayIndex = (int) Math.round(arrayCopy.size() * p - .5f);
+            // bound the index to avoid out of range error
+            arrayIndex = Math.min(Math.max(arrayIndex, 0), arrayCopy.size() - 1);
             percentileValues.add(arrayCopy.get(arrayIndex));
         }
         return percentileValues;
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
index d9ee5b8..9d36f37 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
@@ -16,8 +16,6 @@
 
 package android.hardware.cts.helpers.sensorverification;
 
-import junit.framework.Assert;
-
 import android.content.Context;
 import android.content.pm.PackageManager;
 
@@ -34,6 +32,7 @@
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
+import junit.framework.Assert;
 
 /**
  * A {@link ISensorVerification} which verifies that the sensor jitter is in an acceptable range.
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
index 79c3b65..d8e1586 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
@@ -66,7 +66,8 @@
         } catch (AssertionError e) {
             // Expected;
         }
-        verifyStats(stats, false, 50); // 500 us range divide by 1ms requested sample time x 100%
+        verifyStats(stats, false, 25); // 500 us range (250 us in single-sided sense)
+                                       // divide by 1ms requested sample time x 100%
     }
 
     public void testCalculateDelta() {
@@ -74,48 +75,48 @@
         JitterVerification verification = getVerification(1, timestamps);
         List<Long> deltaValues = verification.getDeltaValues();
         assertEquals(4, deltaValues.size());
-        assertEquals(1, deltaValues.get(0).doubleValue());
-        assertEquals(1, deltaValues.get(1).doubleValue());
-        assertEquals(1, deltaValues.get(2).doubleValue());
-        assertEquals(1, deltaValues.get(3).doubleValue());
+        assertEquals(1, deltaValues.get(0).longValue());
+        assertEquals(1, deltaValues.get(1).longValue());
+        assertEquals(1, deltaValues.get(2).longValue());
+        assertEquals(1, deltaValues.get(3).longValue());
 
         timestamps = new long[]{0, 0, 2, 4, 4};
         verification = getVerification(1, timestamps);
         deltaValues = verification.getDeltaValues();
         assertEquals(4, deltaValues.size());
-        assertEquals(0, deltaValues.get(0).doubleValue());
-        assertEquals(2, deltaValues.get(1).doubleValue());
-        assertEquals(2, deltaValues.get(2).doubleValue());
-        assertEquals(0, deltaValues.get(3).doubleValue());
+        assertEquals(0, deltaValues.get(0).longValue());
+        assertEquals(2, deltaValues.get(1).longValue());
+        assertEquals(2, deltaValues.get(2).longValue());
+        assertEquals(0, deltaValues.get(3).longValue());
 
         timestamps = new long[]{0, 1, 4, 9, 16};
         verification = getVerification(1, timestamps);
         deltaValues = verification.getDeltaValues();
         assertEquals(4, deltaValues.size());
-        assertEquals(1, deltaValues.get(0).doubleValue());
-        assertEquals(3, deltaValues.get(1).doubleValue());
-        assertEquals(5, deltaValues.get(2).doubleValue());
-        assertEquals(7, deltaValues.get(3).doubleValue());
+        assertEquals(1, deltaValues.get(0).longValue());
+        assertEquals(3, deltaValues.get(1).longValue());
+        assertEquals(5, deltaValues.get(2).longValue());
+        assertEquals(7, deltaValues.get(3).longValue());
     }
 
-    private static JitterVerification getVerification(int threshold, long ... timestamps) {
+    private static JitterVerification getVerification(int marginPercent, long ... timestamps) {
         Collection<TestSensorEvent> events = new ArrayList<>(timestamps.length);
         for (long timestamp : timestamps) {
             events.add(new TestSensorEvent(null, timestamp, 0, null));
         }
         long samplePeriodNs = 1000*1000; //1000Hz
-        long jitterThresholdNs = 20*1000; // 2%
+        long jitterThresholdNs = 20*1000; // 2% of that
 
         JitterVerification verification =
-                new JitterVerification(threshold, jitterThresholdNs, samplePeriodNs);
+                new JitterVerification(marginPercent/100.0f, jitterThresholdNs, samplePeriodNs);
         verification.addSensorEvents(events);
         return verification;
     }
 
-    private void verifyStats(SensorStats stats, boolean passed, double normalizedRange) {
+    private void verifyStats(SensorStats stats, boolean passed, double percentageJitter) {
         assertEquals(passed, stats.getValue(JitterVerification.PASSED_KEY));
         assertEquals(
-                normalizedRange,
+                percentageJitter,
                 (Double) stats.getValue(SensorStats.JITTER_95_PERCENTILE_PERCENT_KEY),
                 0.01);
     }
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index cb217b2..4c90e56 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -890,6 +890,12 @@
         boolean success = false;
         Surface surface = null;
         int noOfFailure = 0;
+
+        if (!hasH264()) {
+            MediaUtils.skipTest("no codecs");
+            return true;
+        }
+
         try {
             if (persistent) {
                 surface = MediaCodec.createPersistentInputSurface();
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index 419f320..af60139 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -29,8 +29,8 @@
 
     private static final String LOG_TAG = "BuildVersionTest";
     private static final Set<String> EXPECTED_RELEASES =
-            new HashSet<String>(Arrays.asList("5.1", "5.1.1"));
-    private static final int EXPECTED_SDK = 22;
+            new HashSet<String>(Arrays.asList("6.0"));
+    private static final int EXPECTED_SDK = 23;
     private static final String EXPECTED_BUILD_VARIANT = "user";
     private static final String EXPECTED_TAG = "release-keys";
 
diff --git a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
index f7e5443..387cd18 100644
--- a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
@@ -19,69 +19,280 @@
 import android.content.Intent;
 import android.test.AndroidTestCase;
 
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+
 /**
  * Verify that applications can not send protected broadcasts.
  */
 public class ProtectedBroadcastsTest extends AndroidTestCase {
     private static final String BROADCASTS[] = new String[] {
-        Intent.ACTION_SCREEN_OFF,
-        Intent.ACTION_SCREEN_ON,
-        Intent.ACTION_USER_PRESENT,
-        Intent.ACTION_TIME_TICK,
-        Intent.ACTION_TIMEZONE_CHANGED,
-        Intent.ACTION_BOOT_COMPLETED,
-        Intent.ACTION_PACKAGE_INSTALL,
-        Intent.ACTION_PACKAGE_ADDED,
-        Intent.ACTION_PACKAGE_REPLACED,
-        Intent.ACTION_PACKAGE_REMOVED,
-        Intent.ACTION_PACKAGE_CHANGED,
-        Intent.ACTION_PACKAGE_RESTARTED,
-        Intent.ACTION_PACKAGE_DATA_CLEARED,
-        Intent.ACTION_UID_REMOVED,
-        Intent.ACTION_CONFIGURATION_CHANGED,
-        Intent.ACTION_BATTERY_CHANGED,
-        Intent.ACTION_BATTERY_LOW,
-        Intent.ACTION_BATTERY_OKAY,
-        Intent.ACTION_POWER_CONNECTED,
-        Intent.ACTION_POWER_DISCONNECTED,
-        Intent.ACTION_SHUTDOWN,
-        Intent.ACTION_DEVICE_STORAGE_LOW,
-        Intent.ACTION_DEVICE_STORAGE_OK,
-        Intent.ACTION_NEW_OUTGOING_CALL,
-        Intent.ACTION_REBOOT,
-        "android.intent.action.SERVICE_STATE",
-        "android.intent.action.RADIO_TECHNOLOGY",
-        "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED",
-        "android.intent.action.SIG_STR",
+        "android.app.action.DEVICE_OWNER_CHANGED",
+        "android.app.action.ENTER_CAR_MODE",
+        "android.app.action.ENTER_DESK_MODE",
+        "android.app.action.EXIT_CAR_MODE",
+        "android.app.action.EXIT_DESK_MODE",
+        "android.app.action.NEXT_ALARM_CLOCK_CHANGED",
+        "android.app.action.SYSTEM_UPDATE_POLICY_CHANGED",
+        "android.appwidget.action.APPWIDGET_DELETED",
+        "android.appwidget.action.APPWIDGET_DISABLED",
+        "android.appwidget.action.APPWIDGET_ENABLED",
+        "android.appwidget.action.APPWIDGET_HOST_RESTORED",
+        "android.appwidget.action.APPWIDGET_RESTORED",
+        "android.appwidget.action.APPWIDGET_UPDATE_OPTIONS",
+        "android.backup.intent.CLEAR",
+        "android.backup.intent.INIT",
+        "android.backup.intent.RUN",
+        "android.bluetooth.a2dp-sink.profile.action.AUDIO_CONFIG_CHANGED",
+        "android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED",
+        "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED",
+        "android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.adapter.action.DISCOVERY_FINISHED",
+        "android.bluetooth.adapter.action.DISCOVERY_STARTED",
+        "android.bluetooth.adapter.action.LOCAL_NAME_CHANGED",
+        "android.bluetooth.adapter.action.SCAN_MODE_CHANGED",
+        "android.bluetooth.adapter.action.STATE_CHANGED",
+        "android.bluetooth.avrcp-controller.profile.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.device.action.ACL_CONNECTED",
+        "android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED",
+        "android.bluetooth.device.action.ACL_DISCONNECTED",
+        "android.bluetooth.device.action.ALIAS_CHANGED",
+        "android.bluetooth.device.action.BOND_STATE_CHANGED",
+        "android.bluetooth.device.action.CLASS_CHANGED",
+        "android.bluetooth.device.action.CONNECTION_ACCESS_CANCEL",
+        "android.bluetooth.device.action.CONNECTION_ACCESS_REPLY",
+        "android.bluetooth.device.action.CONNECTION_ACCESS_REQUEST",
+        "android.bluetooth.device.action.DISAPPEARED",
+        "android.bluetooth.device.action.FOUND",
+        "android.bluetooth.device.action.MAS_INSTANCE",
+        "android.bluetooth.device.action.NAME_CHANGED",
+        "android.bluetooth.device.action.NAME_FAILED",
+        "android.bluetooth.device.action.PAIRING_CANCEL",
+        "android.bluetooth.device.action.PAIRING_REQUEST",
+        "android.bluetooth.device.action.UUID",
+        "android.bluetooth.devicepicker.action.DEVICE_SELECTED",
+        "android.bluetooth.devicepicker.action.LAUNCH",
+        "android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT",
+        "android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED",
+        "android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED",
+        "android.bluetooth.headsetclient.profile.action.AG_EVENT",
+        "android.bluetooth.headsetclient.profile.action.AUDIO_STATE_CHANGED",
+        "android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.headsetclient.profile.action.LAST_VTAG",
+        "android.bluetooth.headsetclient.profile.action.RESULT",
+        "android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED",
+        "android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS",
+        "android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED",
+        "android.bluetooth.pbap.intent.action.PBAP_STATE_CHANGED",
+        "android.btopp.intent.action.CONFIRM",
+        "android.btopp.intent.action.HIDE_COMPLETE",
+        "android.btopp.intent.action.HIDE",
+        "android.btopp.intent.action.INCOMING_FILE_NOTIFICATION",
+        "android.btopp.intent.action.LIST",
+        "android.btopp.intent.action.OPEN_INBOUND",
+        "android.btopp.intent.action.OPEN_OUTBOUND",
+        "android.btopp.intent.action.OPEN",
+        "android.btopp.intent.action.RETRY",
+        "android.btopp.intent.action.USER_CONFIRMATION_TIMEOUT",
+        "android.hardware.display.action.WIFI_DISPLAY_STATUS_CHANGED",
+        "android.hardware.usb.action.USB_ACCESSORY_ATTACHED",
+        "android.hardware.usb.action.USB_DEVICE_ATTACHED",
+        "android.hardware.usb.action.USB_PORT_CHANGED",
+        "android.hardware.usb.action.USB_STATE",
+        "android.intent.action.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED",
+        "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED",
+        "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED",
+        "android.intent.action.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED",
+        "android.intent.action.ACTION_IDLE_MAINTENANCE_END",
+        "android.intent.action.ACTION_IDLE_MAINTENANCE_START",
+        "android.intent.action.ACTION_POWER_CONNECTED",
+        "android.intent.action.ACTION_POWER_DISCONNECTED",
+        "android.intent.action.ACTION_SET_RADIO_CAPABILITY_DONE",
+        "android.intent.action.ACTION_SET_RADIO_CAPABILITY_FAILED",
+        "android.intent.action.ACTION_SHUTDOWN",
+        "android.intent.action.ACTION_SUBINFO_CONTENT_CHANGE",
+        "android.intent.action.ACTION_SUBINFO_RECORD_UPDATED",
+        "android.intent.action.ADVANCED_SETTINGS",
+        "android.intent.action.AIRPLANE_MODE",
         "android.intent.action.ANY_DATA_STATE",
-        "android.intent.action.DATA_CONNECTION_FAILED",
-        "android.intent.action.SIM_STATE_CHANGED",
-        "android.intent.action.NETWORK_SET_TIME",
-        "android.intent.action.NETWORK_SET_TIMEZONE",
-        "android.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS",
-        "android.intent.action.ACTION_MDN_STATE_CHANGED",
-        "android.provider.Telephony.SPN_STRINGS_UPDATED",
-        "android.intent.action.ANY_DATA_STATE",
-        "com.android.server.WifiManager.action.START_SCAN",
-        "com.android.server.WifiManager.action.DELAYED_DRIVER_STOP",
-        "android.net.wifi.WIFI_STATE_CHANGED",
-        "android.net.wifi.WIFI_AP_STATE_CHANGED",
-        "android.net.wifi.SCAN_RESULTS",
-        "android.net.wifi.RSSI_CHANGED",
-        "android.net.wifi.STATE_CHANGE",
-        "android.net.wifi.LINK_CONFIGURATION_CHANGED",
+        "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED",
+        "android.intent.action.BATTERY_CHANGED",
+        "android.intent.action.BATTERY_LOW",
+        "android.intent.action.BATTERY_OKAY",
+        "android.intent.action.BOOT_COMPLETED",
+        "android.intent.action.BUGREPORT_FINISHED",
+        "android.intent.action.CHARGING",
+        "android.intent.action.CLEAR_DNS_CACHE",
+        "android.intent.action.CONFIGURATION_CHANGED",
+        "android.intent.action.DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN",
+        "android.intent.action.DATE_CHANGED",
+        "android.intent.action.DEVICE_STORAGE_FULL",
+        "android.intent.action.DEVICE_STORAGE_LOW",
+        "android.intent.action.DEVICE_STORAGE_NOT_FULL",
+        "android.intent.action.DEVICE_STORAGE_OK",
+        "android.intent.action.DISCHARGING",
+        "android.intent.action.DOCK_EVENT",
+        "android.intent.action.DREAMING_STARTED",
+        "android.intent.action.DREAMING_STOPPED",
+        "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE",
+        "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE",
+        "android.intent.action.HDMI_PLUGGED",
+        "android.intent.action.HEADSET_PLUG",
+        "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION",
+        "android.intent.action.LOCALE_CHANGED",
+        "android.intent.action.MASTER_CLEAR_NOTIFICATION",
+        "android.intent.action.MEDIA_BAD_REMOVAL",
+        "android.intent.action.MEDIA_CHECKING",
+        "android.intent.action.MEDIA_EJECT",
+        "android.intent.action.MEDIA_MOUNTED",
+        "android.intent.action.MEDIA_NOFS",
+        "android.intent.action.MEDIA_REMOVED",
+        "android.intent.action.MEDIA_SHARED",
+        "android.intent.action.MEDIA_UNMOUNTABLE",
+        "android.intent.action.MEDIA_UNMOUNTED",
+        "android.intent.action.MEDIA_UNSHARED",
+        "android.intent.action.MY_PACKAGE_REPLACED",
+        "android.intent.action.NEW_OUTGOING_CALL",
+        "android.intent.action.PACKAGE_ADDED",
+        "android.intent.action.PACKAGE_CHANGED",
+        "android.intent.action.PACKAGE_DATA_CLEARED",
+        "android.intent.action.PACKAGE_FIRST_LAUNCH",
+        "android.intent.action.PACKAGE_FULLY_REMOVED",
+        "android.intent.action.PACKAGE_INSTALL",
+        "android.intent.action.PACKAGE_NEEDS_VERIFICATION",
+        "android.intent.action.PACKAGE_REMOVED",
+        "android.intent.action.PACKAGE_REPLACED",
+        "android.intent.action.PACKAGE_RESTARTED",
+        "android.intent.action.PACKAGE_VERIFIED",
+        "android.intent.action.PERMISSION_RESPONSE_RECEIVED",
+        "android.intent.action.PHONE_STATE",
+        "android.intent.action.PROXY_CHANGE",
+        "android.intent.action.QUERY_PACKAGE_RESTART",
+        "android.intent.action.REBOOT",
+        "android.intent.action.REQUEST_PERMISSION",
+        "android.intent.action.SCREEN_OFF",
+        "android.intent.action.SCREEN_ON",
+        "android.intent.action.SUB_DEFAULT_CHANGED",
+        "android.intent.action.TIME_SET",
+        "android.intent.action.TIME_TICK",
+        "android.intent.action.TIMEZONE_CHANGED",
+        "android.intent.action.UID_REMOVED",
+        "android.intent.action.USER_ADDED",
+        "android.intent.action.USER_BACKGROUND",
+        "android.intent.action.USER_FOREGROUND",
+        "android.intent.action.USER_PRESENT",
+        "android.intent.action.USER_REMOVED",
+        "android.intent.action.USER_STARTED",
+        "android.intent.action.USER_STARTING",
+        "android.intent.action.USER_STOPPED",
+        "android.intent.action.USER_STOPPING",
+        "android.intent.action.USER_SWITCHED",
+        "android.internal.policy.action.BURN_IN_PROTECTION",
+        "android.location.GPS_ENABLED_CHANGE",
+        "android.location.GPS_FIX_CHANGE",
+        "android.location.MODE_CHANGED",
+        "android.location.PROVIDERS_CHANGED",
+        "android.media.ACTION_SCO_AUDIO_STATE_UPDATED",
+        "android.media.action.HDMI_AUDIO_PLUG",
+        "android.media.AUDIO_BECOMING_NOISY",
+        "android.media.MASTER_MUTE_CHANGED_ACTION",
+        "android.media.MASTER_VOLUME_CHANGED_ACTION",
+        "android.media.RINGER_MODE_CHANGED",
+        "android.media.SCO_AUDIO_STATE_CHANGED",
+        "android.media.VIBRATE_SETTING_CHANGED",
+        "android.media.VOLUME_CHANGED_ACTION",
+        "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED",
+        "android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED",
+        "android.net.conn.CAPTIVE_PORTAL",
+        "android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE",
+        "android.net.conn.CONNECTIVITY_CHANGE",
+        "android.net.conn.DATA_ACTIVITY_CHANGE",
+        "android.net.conn.INET_CONDITION_ACTION",
+        "android.net.conn.NETWORK_CONDITIONS_MEASURED",
+        "android.net.conn.TETHER_STATE_CHANGED",
+        "android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED",
+        "android.net.nsd.STATE_CHANGED",
+        "android.net.proxy.PAC_REFRESH",
+        "android.net.scoring.SCORE_NETWORKS",
+        "android.net.scoring.SCORER_CHANGED",
         "android.net.wifi.CONFIGURED_NETWORKS_CHANGE",
+        "android.net.wifi.LINK_CONFIGURATION_CHANGED",
+        "android.net.wifi.p2p.CONNECTION_STATE_CHANGE",
+        "android.net.wifi.p2p.DISCOVERY_STATE_CHANGE",
+        "android.net.wifi.p2p.PEERS_CHANGED",
+        "android.net.wifi.p2p.PERSISTENT_GROUPS_CHANGED",
+        "android.net.wifi.p2p.STATE_CHANGED",
+        "android.net.wifi.p2p.THIS_DEVICE_CHANGED",
+        "android.net.wifi.RSSI_CHANGED",
+        "android.net.wifi.SCAN_RESULTS",
+        "android.net.wifi.STATE_CHANGE",
         "android.net.wifi.supplicant.CONNECTION_CHANGE",
         "android.net.wifi.supplicant.STATE_CHANGE",
-        "android.net.wifi.p2p.STATE_CHANGED",
-        "android.net.wifi.p2p.DISCOVERY_STATE_CHANGE",
-        "android.net.wifi.p2p.THIS_DEVICE_CHANGED",
-        "android.net.wifi.p2p.PEERS_CHANGED",
-        "android.net.wifi.p2p.CONNECTION_STATE_CHANGE",
-        "android.net.wifi.p2p.PERSISTENT_GROUPS_CHANGED",
-        "android.net.conn.TETHER_STATE_CHANGED",
-        "android.net.conn.INET_CONDITION_ACTION",
-        "android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED"
+        "android.net.wifi.WIFI_AP_STATE_CHANGED",
+        "android.net.wifi.WIFI_CREDENTIAL_CHANGED",
+        "android.net.wifi.WIFI_SCAN_AVAILABLE",
+        "android.net.wifi.WIFI_STATE_CHANGED",
+        "android.nfc.action.LLCP_LINK_STATE_CHANGED",
+        "android.nfc.action.TRANSACTION_DETECTED",
+        "android.nfc.handover.intent.action.HANDOVER_STARTED",
+        "android.nfc.handover.intent.action.TRANSFER_DONE",
+        "android.nfc.handover.intent.action.TRANSFER_PROGRESS",
+        "android.os.action.DEVICE_IDLE_MODE_CHANGED",
+        "android.os.action.POWER_SAVE_MODE_CHANGED",
+        "android.os.action.POWER_SAVE_MODE_CHANGING",
+        "android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED",
+        "android.os.action.POWER_SAVE_WHITELIST_CHANGED",
+        "android.os.action.SCREEN_BRIGHTNESS_BOOST_CHANGED",
+        "android.os.action.SETTING_RESTORED",
+        "android.os.UpdateLock.UPDATE_LOCK_CHANGED",
+        "android.telecom.action.DEFAULT_DIALER_CHANGED",
+        "com.android.bluetooth.pbap.authcancelled",
+        "com.android.bluetooth.pbap.authchall",
+        "com.android.bluetooth.pbap.authresponse",
+        "com.android.bluetooth.pbap.userconfirmtimeout",
+        "com.android.nfc_extras.action.AID_SELECTED",
+        "com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED",
+        "com.android.nfc_extras.action.RF_FIELD_ON_DETECTED",
+        "com.android.server.connectivityservice.CONNECTED_TO_PROVISIONING_NETWORK_ACTION",
+        "com.android.server.WifiManager.action.DELAYED_DRIVER_STOP",
+        "com.android.server.WifiManager.action.START_PNO",
+        "com.android.server.WifiManager.action.START_SCAN"
+    };
+    private static final String PHONE_BROADCASTS = new String[] {
+        "android.intent.action.ACTION_MDN_STATE_CHANGED",
+        "android.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS",
+        "android.intent.action.ANY_DATA_STATE",
+        "android.intent.action.DATA_CONNECTION_FAILED",
+        "android.intent.action.DATA_SMS_RECEIVED",
+        "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED",
+        "android.intent.action.NETWORK_SET_TIME",
+        "android.intent.action.NETWORK_SET_TIMEZONE",
+        "android.intent.action.RADIO_TECHNOLOGY",
+        "android.intent.action.SERVICE_STATE",
+        "android.intent.action.SIG_STR",
+        "android.intent.action.SIM_STATE_CHANGED",
+        "android.intent.action.stk.alpha_notify",
+        "android.intent.action.stk.command",
+        "android.intent.action.stk.icc_status_change",
+        "android.intent.action.stk.session_end",
+        "android.provider.Telephony.SIM_FULL",
+        "android.provider.Telephony.SMS_CB_RECEIVED",
+        "android.provider.Telephony.SMS_DELIVER",
+        "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED",
+        "android.provider.Telephony.SMS_RECEIVED",
+        "android.provider.Telephony.SPN_STRINGS_UPDATED",
+        "android.provider.Telephony.WAP_PUSH_DELIVER",
+        "android.provider.Telephony.WAP_PUSH_RECEIVED",
+        "com.android.internal.telephony.data-restart-trysetup",
+        "com.android.internal.telephony.data-stall"
+    };
+    private static final String TELECOM_BROADCASTS = new String[] {
+        "android.intent.action.SHOW_MISSED_CALLS_NOTIFICATION"
     };
 
     /**
@@ -97,5 +308,35 @@
                 assertNotNull("security exception's error message.", expected.getMessage());
             }
         }
+        try {
+            PackageInfo packageInfo = packageManager.getPackageInfo("com.android.phone", NO_FLAGS);
+            for (String action : PHONE_BROADCASTS) {
+                try {
+                    Intent intent = new Intent(action);
+                    getContext().sendBroadcast(intent);
+                    fail("expected security exception broadcasting com.android.phone action: " +
+                            action);
+                } catch (SecurityException expected) {
+                    assertNotNull("security exception's error message.", expected.getMessage());
+                }
+            }
+        } catch (NameNotFoundException e) {
+          // this catch intentionally left blank
+        }
+        try {
+            PackageInfo packageInfo =
+                    packageManager.getPackageInfo("com.android.server.telecom", NO_FLAGS);
+            for (String action : TELECOM_BROADCASTS) {
+                try {
+                    Intent intent = new Intent(action);
+                    getContext().sendBroadcast(intent);
+                    fail("expected security exception broadcasting telcom action: " + action);
+                } catch (SecurityException expected) {
+                    assertNotNull("security exception's error message.", expected.getMessage());
+                }
+            }
+        } catch (NameNotFoundException e) {
+          // this catch intentionally left empty
+        }
     }
-}
+}
\ No newline at end of file
diff --git a/tests/tests/security/jni/Android.mk b/tests/tests/security/jni/Android.mk
index 159131a..e61d787 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -32,28 +32,13 @@
 		android_security_cts_MMapExecutableTest.cpp \
 		android_security_cts_AudioPolicyBinderTest.cpp \
 		android_security_cts_EncryptionTest.cpp \
-		android_security_cts_MediaCryptoTest.cpp \
 		android_security_cts_MediaPlayerInfoLeakTest.cpp \
 		android_security_cts_AudioEffectBinderTest.cpp \
 		android_security_cts_AudioFlingerBinderTest.cpp
 
-LOCAL_C_INCLUDES := \
-	$(JNI_H_INCLUDE) \
-	system/core/include \
-	frameworks/base/media/jni
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
 
-LOCAL_SHARED_LIBRARIES := \
-	libnativehelper \
-	liblog \
-	libbinder \
-	libutils \
-	libmedia \
-	libselinux \
-	libdl \
-	libcutils \
-	libcrypto \
-	libstagefright_foundation \
-	libmedia_jni
+LOCAL_SHARED_LIBRARIES := libnativehelper liblog libbinder libutils libmedia libselinux libdl libcutils libcrypto
 
 LOCAL_C_INCLUDES += ndk/sources/cpufeatures
 LOCAL_STATIC_LIBRARIES := cpufeatures
diff --git a/tests/tests/security/jni/android_security_cts_MediaCryptoTest.cpp b/tests/tests/security/jni/android_security_cts_MediaCryptoTest.cpp
deleted file mode 100644
index abb26eb..0000000
--- a/tests/tests/security/jni/android_security_cts_MediaCryptoTest.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-/* Original code copied from NDK Native-media sample code */
-
-//#define LOG_NDEBUG 0
-#define TAG "NativeMediaCrypto"
-#include <log/log.h>
-
-#include <android_media_MediaCrypto.h>
-#include <assert.h>
-#include <binder/MemoryDealer.h>
-#include <jni.h>
-#include <media/ICrypto.h>
-#include <media/stagefright/foundation/AString.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <utils/StrongPointer.h>
-#include <semaphore.h>
-
-
-static const size_t kBufferSize = 1024;
-
-using namespace android;
-
-static jboolean testCrypto(sp<ICrypto> icrypto,
-        const CryptoPlugin::SubSample *subSample, CryptoPlugin::Mode mode)
-{
-    // Allocate source buffer
-    sp<MemoryDealer> memDealer = new MemoryDealer(kBufferSize, "MediaCryptoTest");
-    sp<IMemory> srcBuffer = memDealer->allocate(kBufferSize);
-    if (!srcBuffer->pointer()) {
-        ALOGE("Failed to allocate source buffer");
-        return false;
-    }
-    memset(srcBuffer->pointer(), 's', kBufferSize);
-
-    // Invalid dest pointer should fault if mediaserver attempts
-    // to write to it.  Don't use NULL because that's probably
-    // checked for.
-    void *dstPtr = reinterpret_cast<void *>(1);
-
-    // Spoof the device as being secure
-    bool secure = true;
-
-    uint8_t key[16] = {0};
-    uint8_t iv[16] = {0};
-    uint32_t offset = 0;
-    AString errorDetailMsg;
-
-    ssize_t result = icrypto->decrypt(secure, key, iv, mode, srcBuffer, offset,
-            subSample, 1, dstPtr, &errorDetailMsg);
-
-    // call should return an error and shouldn't kill media server
-    return (result != OK && result != DEAD_OBJECT);
-}
-
-// Test for icrypto interface vulnerabilities
-extern "C" jboolean Java_android_security_cts_MediaCryptoTest_validateCryptoNative(JNIEnv *env,
-        jclass /*clazz*/, jobject crypto)
-{
-    bool result = false;
-    sp<ICrypto> icrypto = JCrypto::GetCrypto(env, crypto);
-    if (icrypto != NULL) {
-        if (icrypto->requiresSecureDecoderComponent("video/avc")) {
-            ALOGI("device is secure, bypassing test");
-            return true;
-        }
-
-        CryptoPlugin::Mode unencryptedMode = CryptoPlugin::kMode_Unencrypted;
-        CryptoPlugin::Mode aesCtrMode = CryptoPlugin::kMode_AES_CTR;
-
-        CryptoPlugin::SubSample clrSubSample = {kBufferSize, 0};
-        CryptoPlugin::SubSample encSubSample = {0, kBufferSize};
-
-        result =
-            testCrypto(icrypto, &clrSubSample, unencryptedMode) &&
-            testCrypto(icrypto, &clrSubSample, aesCtrMode) &&
-            testCrypto(icrypto, &encSubSample, unencryptedMode) &&
-            testCrypto(icrypto, &encSubSample, aesCtrMode);
-    } else {
-        ALOGE("Failed to get icrypto interface");
-    }
-    return result;
-}
-
-
-
diff --git a/tests/tests/security/src/android/security/cts/HttpPost.java b/tests/tests/security/src/android/security/cts/HttpPost.java
deleted file mode 100644
index 7f855d9..0000000
--- a/tests/tests/security/src/android/security/cts/HttpPost.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-package android.security.cts;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.util.Log;
-import android.util.Pair;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * HttpPost utility functions.
- */
-public final class HttpPost {
-    private static final String TAG = "HttpPost";
-
-    private HttpPost() {}
-
-    /**
-     * Executes a post request using {@link HttpURLConnection}.
-     *
-     * @param url The request URL.
-     * @param data The request body, or null.
-     * @param requestProperties Request properties, or null.
-     * @return The response code and body.
-     * @throws IOException If an error occurred making the request.
-     */
-    public static Pair<Integer, byte[]> execute(String url, byte[] data,
-            Map<String, String> requestProperties) throws IOException {
-        HttpURLConnection urlConnection = null;
-        try {
-            urlConnection = (HttpURLConnection) new URL(url).openConnection();
-            urlConnection.setRequestMethod("POST");
-            urlConnection.setDoOutput(data != null);
-            urlConnection.setDoInput(true);
-            urlConnection.setConnectTimeout(5000);
-            urlConnection.setReadTimeout(5000);
-            if (requestProperties != null) {
-                for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) {
-                    urlConnection.setRequestProperty(requestProperty.getKey(),
-                            requestProperty.getValue());
-                }
-            }
-            // Write the request body, if there is one.
-            if (data != null) {
-                OutputStream out = urlConnection.getOutputStream();
-                try {
-                    out.write(data);
-                } finally {
-                    out.close();
-                }
-            }
-            // Read the response code.
-            int responseCode = urlConnection.getResponseCode();
-            // Read the response body.
-            InputStream inputStream = urlConnection.getInputStream();
-            try {
-                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-                byte scratch[] = new byte[1024];
-                int bytesRead;
-                while ((bytesRead = inputStream.read(scratch)) != -1) {
-                    byteArrayOutputStream.write(scratch, 0, bytesRead);
-                }
-                byte[] responseBody = byteArrayOutputStream.toByteArray();
-                Log.d(TAG, "responseCode=" + responseCode + ", length=" + responseBody.length);
-                return Pair.create(responseCode, responseBody);
-            } finally {
-                inputStream.close();
-            }
-        } finally {
-            if (urlConnection != null) {
-                urlConnection.disconnect();
-            }
-        }
-    }
-
-}
diff --git a/tests/tests/security/src/android/security/cts/KeyRequester.java b/tests/tests/security/src/android/security/cts/KeyRequester.java
deleted file mode 100644
index 26a3337..0000000
--- a/tests/tests/security/src/android/security/cts/KeyRequester.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.security.cts;
-
-import android.media.DeniedByServerException;
-import android.media.MediaDrm;
-import android.media.NotProvisionedException;
-import android.util.Log;
-import android.util.Pair;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-public class KeyRequester {
-    private final String TAG = "KeyRequester";
-    private final int MAX_RETRY_COUNT = 3;
-    private final int POOL_SIZE = 1;
-    private final int POOL_TERMINATION_MS_TIMEOUT = 3000;  // in milliseconds
-    private final int KEYREQUEST_MS_TIMEOUT = 5000;  // in milliseconds
-
-    private byte[] mPssh;
-    private ExecutorService mExecutorService;
-    private Future<byte[]> mFuture;
-    private String mDefaultHeartbeatUrl;
-    private String mServerUrl;
-
-    public KeyRequester(byte[] pssh, String url) {
-        mPssh = pssh;
-        mServerUrl = url;
-    }
-
-    public final String getDefaultHeartbeatUrl() {
-        return mDefaultHeartbeatUrl;
-    }
-
-    public byte[] doTransact(final MediaDrm drm, final byte[] sessionId, final int keyType) {
-        boolean retryRequest;
-        boolean retryTransaction;
-        byte[] keySetIdResult;
-        int getKeyRequestRetryCount;
-        int provisioningRetryCount = 0;
-        MediaDrm.KeyRequest drmRequest;
-
-        mExecutorService = Executors.newFixedThreadPool(POOL_SIZE);
-
-        do {
-            drmRequest = null;
-            getKeyRequestRetryCount = 0;
-            keySetIdResult = null;
-            retryTransaction = false;
-
-            do {
-                retryRequest = false;
-
-                try {
-                    drmRequest = drm.getKeyRequest(sessionId, mPssh,
-                        "video/avc", keyType, null);
-                } catch (NotProvisionedException e) {
-                    Log.i(TAG, "Invalid certificate, reprovisioning");
-                    ProvisionRequester provisionRequester = new ProvisionRequester();
-                    provisionRequester.doTransact(drm);
-                    retryRequest = true;
-                }
-            } while (retryRequest && ++getKeyRequestRetryCount < MAX_RETRY_COUNT);
-
-            if (drmRequest == null) {
-                Log.e(TAG, "Failed to get key request");
-                return null;
-            }
-
-            try {
-                mFuture = mExecutorService.submit(new KeyRequesterTask(mServerUrl, drmRequest));
-            } catch (RejectedExecutionException e) {
-                Log.e(TAG, "Failed to submit KeyRequesterTask for execution", e);
-                if (++provisioningRetryCount < MAX_RETRY_COUNT) {
-                    continue;
-                } else {
-                    break;
-                }
-            }
-
-            try {
-                byte[] responseBody = mFuture.get(KEYREQUEST_MS_TIMEOUT, TimeUnit.MILLISECONDS);
-                if (responseBody == null) {
-                    Log.e(TAG, "No response from license server!");
-                    retryTransaction = true;
-                } else {
-                    byte[] drmResponse = parseResponseBody(responseBody);
-                    try {
-                        keySetIdResult = drm.provideKeyResponse(sessionId, drmResponse);
-                    } catch (NotProvisionedException e) {
-                        Log.i(TAG, "Response invalidated the certificate, reprovisioning");
-                        ProvisionRequester provisionRequester = new ProvisionRequester();
-                        provisionRequester.doTransact(drm);
-                        retryTransaction = true;
-                    } catch (DeniedByServerException e) {
-                        // informational, the event handler will take care of provisioning
-                        Log.i(TAG, "Server rejected the key request");
-                    }  catch (IllegalStateException e) {
-                        Log.e(TAG, "provideKeyResponse failed", e);
-                    }
-
-                    try {
-                        // first call to getKeyRequest does not return heartbeat url
-                        drmRequest = drm.getKeyRequest(sessionId, mPssh, "video/avc",
-                                keyType, null);
-                        try {
-                            mDefaultHeartbeatUrl = drmRequest.getDefaultUrl();
-                        } catch (Exception e) {
-                            // ignore
-                        }
-                    } catch (NotProvisionedException e) {
-                        Log.e(TAG, "Fails to get heartbeat url");
-                    }
-                    break;
-                }
-            } catch (ExecutionException | InterruptedException ex) {
-                Log.e(TAG, "Failed to execute KeyRequesterTask", ex);
-                shutdownAndAwaitTermination(mExecutorService);
-                return null;
-            } catch (TimeoutException te) {
-                // The request timed out. The network is possibly too slow.
-                // Cancel the running task.
-                Log.d(TAG, "Request timed out, retry...");
-                mFuture.cancel(true);
-                retryTransaction = true;
-            }
-        } while (retryTransaction && ++provisioningRetryCount < MAX_RETRY_COUNT);
-
-        shutdownAndAwaitTermination(mExecutorService);
-        return keySetIdResult;
-    }
-
-    private void shutdownAndAwaitTermination(ExecutorService pool) {
-        pool.shutdown();  // disable new tasks from being submitted
-        try {
-            // wait for existing tasks to terminate
-            if (!pool.awaitTermination(POOL_TERMINATION_MS_TIMEOUT, TimeUnit.MILLISECONDS)) {
-                pool.shutdownNow();
-                // wait for tasks to respond to being cancelled
-                if (!pool.awaitTermination(POOL_TERMINATION_MS_TIMEOUT, TimeUnit.MILLISECONDS))
-                    Log.e(TAG, "Pool did not terminate");
-            }
-        } catch (InterruptedException ie) {
-            // (Re-)Cancel if current thread also interrupted
-            pool.shutdownNow();
-            // Preserve interrupt status
-            Thread.currentThread().interrupt();
-        }
-    }
-
-    // Validate the response body and return the drmResponse blob.
-    private byte[] parseResponseBody(byte[] responseBody) {
-        String bodyString = null;
-        try {
-            bodyString = new String(responseBody, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-
-        if (bodyString == null) {
-            return null;
-        }
-
-        if (bodyString.startsWith("GLS/")) {
-            if (!bodyString.startsWith("GLS/1.")) {
-                Log.e(TAG, "Invalid server version, expected 1.x");
-                return null;
-            }
-            int drmMessageOffset = bodyString.indexOf("\r\n\r\n");
-            if (drmMessageOffset == -1) {
-                Log.e(TAG, "Invalid server response, could not locate drm message");
-                return null;
-            }
-            responseBody = Arrays.copyOfRange(responseBody, drmMessageOffset + 4,
-                    responseBody.length);
-        }
-        return responseBody;
-    }
-}
diff --git a/tests/tests/security/src/android/security/cts/KeyRequesterTask.java b/tests/tests/security/src/android/security/cts/KeyRequesterTask.java
deleted file mode 100644
index c4d96dd..0000000
--- a/tests/tests/security/src/android/security/cts/KeyRequesterTask.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.security.cts;
-
-import android.media.MediaDrm;
-import android.util.Log;
-import android.util.Pair;
-
-import java.io.IOException;
-import java.util.concurrent.Callable;
-import java.util.HashMap;
-
-public class KeyRequesterTask implements Callable<byte[]> {
-    private static final String TAG = "KeyRequesterTask";
-    private final MediaDrm.KeyRequest mDrmRequest;
-    private final String mUrl;
-
-    public KeyRequesterTask(String url, MediaDrm.KeyRequest drmRequest) {
-        mDrmRequest = drmRequest;
-        mUrl = url;
-    }
-
-    /**
-     * @return a byte array containing the license response if successful,
-     * {@code null} otherwise.
-     */
-    @Override
-    public byte[] call() throws Exception {
-        byte[] drmRequest = mDrmRequest.getData();
-        Log.d(TAG, "PostRequest:" + mUrl);
-
-        HashMap<String, String> headers = new HashMap<>();
-        headers.put("User-Agent", "Widevine CDM v1.0");
-        headers.put("Connection", "close");
-
-        try {
-            Pair<Integer, byte[]> response = HttpPost.execute(mUrl, drmRequest, headers);
-            int responseCode = response.first;
-            if (responseCode != 200) {
-                Log.d(TAG, "Server returned HTTP error code " + responseCode);
-                return null;
-            }
-            return response.second;
-        } catch (IOException e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-}
-
diff --git a/tests/tests/security/src/android/security/cts/MediaCryptoTest.java b/tests/tests/security/src/android/security/cts/MediaCryptoTest.java
deleted file mode 100644
index b5639a7..0000000
--- a/tests/tests/security/src/android/security/cts/MediaCryptoTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-package android.security.cts;
-
-import android.media.MediaCrypto;
-import android.media.MediaCryptoException;
-import android.media.MediaDrm;
-import android.media.MediaDrmException;
-import android.media.NotProvisionedException;
-import android.media.ResourceBusyException;
-import android.test.AndroidTestCase;
-import android.util.Log;
-import java.util.UUID;
-
-public class MediaCryptoTest extends AndroidTestCase {
-    private static final String TAG = "MediaCryptoTest";
-
-    private static final UUID CLEARKEY_SCHEME_UUID =
-        new UUID(0x1077efecc0b24d02L, 0xace33c1e52e2fb4bL);
-    private static final UUID WIDEVINE_SCHEME_UUID =
-        new UUID(0xedef8ba979d64aceL, 0xa3c827dcd51d21edL);
-
-    static {
-        System.loadLibrary("ctssecurity_jni");
-    }
-
-    private native boolean validateCryptoNative(MediaCrypto crypto);
-
-    public void testMediaCryptoClearKey() throws Exception {
-        MediaCrypto crypto = null;
-        if (!MediaDrm.isCryptoSchemeSupported(CLEARKEY_SCHEME_UUID)) {
-            Log.i(TAG, "No ClearKey plugin, skipping test");
-            return;
-        }
-        try {
-            byte[] initData = new byte[0];
-            crypto = new MediaCrypto(CLEARKEY_SCHEME_UUID, initData);
-        } catch (MediaCryptoException e) {
-            throw new Error("Failed to create MediaCrypto using ClearKey plugin");
-        }
-
-        assertTrue("MediaCrypto validation failed", validateCryptoNative(crypto));
-    }
-
-    public void testMediaCryptoWidevine() throws Exception {
-        if (!MediaDrm.isCryptoSchemeSupported(WIDEVINE_SCHEME_UUID)) {
-            Log.i(TAG, "No Widevine plugin, skipping test");
-            return;
-        }
-
-        MediaDrm drm = null;
-        byte[] sessionId = null;
-
-        try {
-            drm = new MediaDrm(WIDEVINE_SCHEME_UUID);
-            sessionId = openSession(drm);
-            getWidevineKeys(drm, sessionId);
-            MediaCrypto crypto = new MediaCrypto(WIDEVINE_SCHEME_UUID, sessionId);
-            assertTrue("MediaCrypto validation failed", validateCryptoNative(crypto));
-        } catch (MediaCryptoException | MediaDrmException e) {
-            if (drm != null && sessionId != null) {
-                drm.closeSession(sessionId);
-            }
-            throw e;
-        }
-    }
-
-    private byte[] openSession(MediaDrm drm) throws Exception {
-        byte[] sessionId = null;
-        int retryCount = 3;
-        while (retryCount-- > 0) {
-            try {
-                return drm.openSession();
-            } catch (NotProvisionedException e) {
-                Log.i(TAG, "Missing certificate, provisioning");
-                ProvisionRequester provisionRequester = new ProvisionRequester();
-                provisionRequester.doTransact(drm);
-            } catch (ResourceBusyException e) {
-                Log.w(TAG, "Resource busy in openSession, retrying...");
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException ie) {
-                    // ignore
-                }
-            }
-        }
-        throw new Error("Failed to open session");
-    }
-
-    private void getWidevineKeys(MediaDrm drm, byte[] sessionId) throws Exception {
-        final String kKeyServerUrl = "https://jmt17.google.com/video/license/GetCencLicense";
-        final byte[] kPssh = hex2ba("08011210e02562e04cd55351b14b3d748d36ed8e");
-        final String kClientAuth = "?source=YOUTUBE&video_id=EGHC6OHNbOo&oauth=ya.gtsqawidevine";
-        final String kPort = "80";
-        KeyRequester keyRequester = new KeyRequester(kPssh, kKeyServerUrl + ":" + kPort + kClientAuth);
-        if (keyRequester.doTransact(drm, sessionId, MediaDrm.KEY_TYPE_STREAMING) == null) {
-            throw new Error("Failed to get keys from license server!");
-        }
-    }
-
-    private static byte[] hex2ba(String s) {
-        int len = s.length();
-        byte[] data = new byte[len / 2];
-        for (int i = 0; i < len; i += 2) {
-            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
-                                  + Character.digit(s.charAt(i+1), 16));
-        }
-        return data;
-    }
-}
diff --git a/tests/tests/security/src/android/security/cts/ProvisionRequester.java b/tests/tests/security/src/android/security/cts/ProvisionRequester.java
deleted file mode 100644
index ee1cb9e..0000000
--- a/tests/tests/security/src/android/security/cts/ProvisionRequester.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-package android.security.cts;
-
-import android.media.DeniedByServerException;
-import android.media.MediaDrm;
-import android.util.Log;
-import android.util.Pair;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-public class ProvisionRequester {
-    private final String TAG = "ProvisionRequester";
-
-    public ProvisionRequester() {
-    }
-
-    public void doTransact(final MediaDrm drm) {
-        Thread t = new Thread() {
-            @Override
-            public void run() {
-                MediaDrm.ProvisionRequest drmRequest;
-                drmRequest = drm.getProvisionRequest();
-                byte[] responseBody = postRequest(drmRequest.getDefaultUrl(),
-                        drmRequest.getData());
-
-                if (responseBody == null) {
-                    Log.e(TAG, "No response from provisioning server!");
-                } else {
-                    try {
-                        drm.provideProvisionResponse(responseBody);
-                    } catch (DeniedByServerException e) {
-                        Log.e(TAG, "Server denied provisioning request");
-                    }
-                }
-            }
-        };
-        t.start();
-
-        try {
-            t.join();
-        } catch (InterruptedException e) {
-        }
-    }
-
-    // TODO May want to throw exceptions without having try/catch in body.
-    private byte[] postRequest(String url, byte[] drmRequest) {
-        String signedUrl = url + "&signedRequest=" + new String(drmRequest);
-        Log.d(TAG, "PostRequest:" + signedUrl);
-
-        HashMap<String, String> headers = new HashMap<>();
-        headers.put("Accept", "*/*");
-        headers.put("User-Agent", "Widevine CDM v1.0");
-        headers.put("Content-Type", "application/json");
-        headers.put("Connection", "close");
-
-        try {
-            Pair<Integer, byte[]> response = HttpPost.execute(signedUrl, null, headers);
-            int responseCode = response.first;
-            if (responseCode != 200) {
-                Log.e(TAG, "Server returned HTTP error code " + responseCode);
-                return null;
-            }
-            return response.second;
-        } catch (IOException e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-
-    private void sleep(int msec) {
-        try {
-            Thread.sleep(msec);
-        } catch (InterruptedException e) {
-        }
-    }
-}
diff --git a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
index e02de92..bba9a44 100644
--- a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
@@ -18,6 +18,8 @@
 
 import static android.telecom.cts.TestUtils.shouldTestTelecom;
 
+import android.content.Context;
+import android.media.AudioManager;
 import android.os.Bundle;
 import android.telecom.CallAudioState;
 import android.telecom.TelecomManager;
@@ -66,11 +68,15 @@
             return;
         }
 
+        AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+        int expectedRoute = am.isWiredHeadsetOn() ?
+                CallAudioState.ROUTE_WIRED_HEADSET : CallAudioState.ROUTE_EARPIECE;
+
         final Bundle extras = new Bundle();
         extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
         placeAndVerifyCall(extras);
         verifyConnectionForOutgoingCall();
-        assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_EARPIECE);
+        assertAudioRoute(mInCallCallbacks.getService(), expectedRoute);
     }
 
     public void testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault() {
@@ -78,8 +84,12 @@
             return;
         }
 
+        AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+        int expectedRoute = am.isWiredHeadsetOn() ?
+                CallAudioState.ROUTE_WIRED_HEADSET : CallAudioState.ROUTE_EARPIECE;
+
         placeAndVerifyCall();
         verifyConnectionForOutgoingCall();
-        assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_EARPIECE);
+        assertAudioRoute(mInCallCallbacks.getService(), expectedRoute);
     }
 }
diff --git a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
index ab4106e..e7130ba 100644
--- a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
@@ -110,16 +110,6 @@
         assertConnectionState(connection, Connection.STATE_DISCONNECTED);
     }
 
-    public void testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault() {
-        if (!mShouldTestTelecom) {
-            return;
-        }
-
-        placeAndVerifyCall();
-        verifyConnectionForOutgoingCall();
-        assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_EARPIECE);
-    }
-
     private void sendMediaButtonShortPress() throws Exception {
         sendMediaButtonPress(false /* longPress */);
     }
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index 6eb09eb..9ab815f 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -94,20 +94,20 @@
         final long ONE_SECOND_IN_MS = 1000;
         assertEquals("0 minutes ago",
                 DateUtils.getRelativeTimeSpanString(mBaseTime - ONE_SECOND_IN_MS));
-        assertEquals("in 0 minutes",
+        assertEquals("In 0 minutes",
                 DateUtils.getRelativeTimeSpanString(mBaseTime + ONE_SECOND_IN_MS));
 
         final long ONE_MINUTE_IN_MS = 60 * ONE_SECOND_IN_MS;
         assertEquals("1 minute ago", DateUtils.getRelativeTimeSpanString(0, ONE_MINUTE_IN_MS,
                 DateUtils.MINUTE_IN_MILLIS));
-        assertEquals("in 1 minute", DateUtils.getRelativeTimeSpanString(ONE_MINUTE_IN_MS, 0,
+        assertEquals("In 1 minute", DateUtils.getRelativeTimeSpanString(ONE_MINUTE_IN_MS, 0,
                 DateUtils.MINUTE_IN_MILLIS));
 
         final long ONE_HOUR_IN_MS = 60 * 60 * 1000;
         final long TWO_HOURS_IN_MS = 2 * ONE_HOUR_IN_MS;
         assertEquals("2 hours ago", DateUtils.getRelativeTimeSpanString(mBaseTime - TWO_HOURS_IN_MS,
                 mBaseTime, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_NUMERIC_DATE));
-        assertEquals("in 2 hours", DateUtils.getRelativeTimeSpanString(mBaseTime + TWO_HOURS_IN_MS,
+        assertEquals("In 2 hours", DateUtils.getRelativeTimeSpanString(mBaseTime + TWO_HOURS_IN_MS,
                 mBaseTime, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_NUMERIC_DATE));
     }
 
diff --git a/tests/tests/uiautomation/src/android/app/uiautomation/cts/UiAutomationTest.java b/tests/tests/uiautomation/src/android/app/uiautomation/cts/UiAutomationTest.java
index 3c6028f..6514402 100755
--- a/tests/tests/uiautomation/src/android/app/uiautomation/cts/UiAutomationTest.java
+++ b/tests/tests/uiautomation/src/android/app/uiautomation/cts/UiAutomationTest.java
@@ -165,6 +165,9 @@
             // Wait for things to settle.
             getUiDevice().waitForIdle();
 
+            // Wait for Activity draw finish
+            getInstrumentation().waitForIdleSync();
+
             // Clear the window animation stats to be with a clean slate.
             uiAutomation.clearWindowAnimationFrameStats();
 
@@ -177,6 +180,9 @@
             // Wait for things to settle.
             getUiDevice().waitForIdle();
 
+            // Wait for Activity draw finish
+            getInstrumentation().waitForIdleSync();
+
             // Get the frame stats.
             WindowAnimationFrameStats stats = uiAutomation.getWindowAnimationFrameStats();
 
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index fa930df..782e6ab 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
     @Option(name="cts-install-path", description="the path to the cts installation to use")
     private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
 
-    public static final String CTS_BUILD_VERSION = "6.0_r0";
+    public static final String CTS_BUILD_VERSION = "6.0_r1";
     public static final String CTS_PACKAGE = "com.android.cts.tradefed.testtype";
 
     /**