Merge "Revert "PixelCopyTest: More modification to the edge detection area."" into pie-cts-dev
diff --git a/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml b/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml
index 272a9fc..a0a715f 100644
--- a/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml
+++ b/apps/CtsVerifier/res/layout/audio_frequency_mic_activity.xml
@@ -32,6 +32,8 @@
             android:orientation="vertical"
         >
 
+            <include layout="@layout/audio_refmic_layout"/>
+
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/audio_frequency_speaker_activity.xml b/apps/CtsVerifier/res/layout/audio_frequency_speaker_activity.xml
index 435f5a7..a9aeafa 100644
--- a/apps/CtsVerifier/res/layout/audio_frequency_speaker_activity.xml
+++ b/apps/CtsVerifier/res/layout/audio_frequency_speaker_activity.xml
@@ -30,70 +30,72 @@
             android:layout_height="wrap_content"
             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_frequency_speaker_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_speaker_mic_ready_btn"
-                android:text="@string/audio_frequency_speaker_mic_ready_btn"
-                android:nextFocusForward="@+id/audio_frequency_speaker_test_btn"
-                android:nextFocusDown="@+id/audio_frequency_speaker_test_btn"
-                android:nextFocusRight="@+id/audio_frequency_speaker_test_btn" />
+            <include layout="@layout/audio_refmic_layout"/>
 
             <TextView
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="@string/audio_frequency_speaker_usb_status"
-                android:id="@+id/audio_frequency_speaker_usb_status"/>
+                android:scrollbars="vertical"
+                android:gravity="bottom"
+                android:id="@+id/info_text"
+                android:text="@string/audio_frequency_speaker_instructions"/>
 
             <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="vertical">
+                <Button
+                    android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:orientation="horizontal"
-                    android:id="@+id/audio_frequency_speaker_layout">
-                    <Button
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:text="@string/audio_frequency_speaker_test_btn"
-                        android:id="@+id/audio_frequency_speaker_test_btn"
-                        android:nextFocusForward="@+id/pass_button"
-                        android:nextFocusUp="@+id/audio_frequency_speaker_mic_ready_btn"
-                        android:nextFocusDown="@+id/pass_button"
-                        android:nextFocusLeft="@+id/audio_frequency_speaker_mic_ready_btn"
-                        android:nextFocusRight="@+id/pass_button" />
-
-                    <ProgressBar
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:id="@+id/audio_frequency_speaker_progress_bar"/>
-                </LinearLayout>
+                    android:id="@+id/audio_frequency_speaker_mic_ready_btn"
+                    android:text="@string/audio_frequency_speaker_mic_ready_btn"
+                    android:nextFocusForward="@+id/audio_frequency_speaker_test_btn"
+                    android:nextFocusDown="@+id/audio_frequency_speaker_test_btn"
+                    android:nextFocusRight="@+id/audio_frequency_speaker_test_btn" />
 
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="@string/audio_frequency_speaker_results_text"
-                    android:id="@+id/audio_frequency_speaker_results_text"/>
+                    android:text="@string/audio_frequency_speaker_usb_status"
+                    android:id="@+id/audio_frequency_speaker_usb_status"/>
 
+                <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_speaker_layout">
+                        <Button
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:text="@string/audio_frequency_speaker_test_btn"
+                            android:id="@+id/audio_frequency_speaker_test_btn"
+                            android:nextFocusForward="@+id/pass_button"
+                            android:nextFocusUp="@+id/audio_frequency_speaker_mic_ready_btn"
+                            android:nextFocusDown="@+id/pass_button"
+                            android:nextFocusLeft="@+id/audio_frequency_speaker_mic_ready_btn"
+                            android:nextFocusRight="@+id/pass_button" />
+
+                        <ProgressBar
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:id="@+id/audio_frequency_speaker_progress_bar"/>
+                    </LinearLayout>
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/audio_frequency_speaker_results_text"
+                        android:id="@+id/audio_frequency_speaker_results_text"/>
+
+                </LinearLayout>
             </LinearLayout>
-        </LinearLayout>
 
-        <include layout="@layout/pass_fail_buttons"/>
+            <include layout="@layout/pass_fail_buttons"/>
         </LinearLayout>
       </ScrollView>
 
diff --git a/apps/CtsVerifier/res/layout/audio_frequency_unprocessed_activity.xml b/apps/CtsVerifier/res/layout/audio_frequency_unprocessed_activity.xml
index d02ef0b..8032f93 100644
--- a/apps/CtsVerifier/res/layout/audio_frequency_unprocessed_activity.xml
+++ b/apps/CtsVerifier/res/layout/audio_frequency_unprocessed_activity.xml
@@ -23,6 +23,8 @@
             android:layout_height="wrap_content"
             android:orientation="vertical">
 
+            <include layout="@layout/audio_refmic_layout"/>
+
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/audio_refmic_layout.xml b/apps/CtsVerifier/res/layout/audio_refmic_layout.xml
new file mode 100644
index 0000000..bd806a1
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/audio_refmic_layout.xml
@@ -0,0 +1,38 @@
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/refmic_test_question"/>
+
+    <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:soundEffectsEnabled="false"
+            android:text="@string/refmic_test_yes"
+            android:id="@+id/refmic_tests_yes_btn" />
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:soundEffectsEnabled="false"
+            android:text="@string/refmic_test_no"
+            android:id="@+id/refmic_tests_no_btn" />
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:soundEffectsEnabled="false"
+            android:text="@string/refmic_test_info"
+            android:id="@+id/refmic_test_info_btn" />
+    </LinearLayout>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/uap_attribs_panel.xml b/apps/CtsVerifier/res/layout/uap_attribs_panel.xml
index 6c33d9f..b9c5d3e 100644
--- a/apps/CtsVerifier/res/layout/uap_attribs_panel.xml
+++ b/apps/CtsVerifier/res/layout/uap_attribs_panel.xml
@@ -9,6 +9,8 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
 
+    <include layout="@layout/uap_usb_confirm"/>
+
     <include layout="@layout/uap_profile_header"/>
 
     <LinearLayout
diff --git a/apps/CtsVerifier/res/layout/uap_buttons_panel.xml b/apps/CtsVerifier/res/layout/uap_buttons_panel.xml
index 4fdc757..355bfb6 100644
--- a/apps/CtsVerifier/res/layout/uap_buttons_panel.xml
+++ b/apps/CtsVerifier/res/layout/uap_buttons_panel.xml
@@ -9,6 +9,8 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
 
+    <include layout="@layout/uap_usb_confirm"/>
+
     <include layout="@layout/uap_profile_header"/>
 
     <LinearLayout
diff --git a/apps/CtsVerifier/res/layout/uap_play_panel.xml b/apps/CtsVerifier/res/layout/uap_play_panel.xml
index 2faa50c..30ef884 100644
--- a/apps/CtsVerifier/res/layout/uap_play_panel.xml
+++ b/apps/CtsVerifier/res/layout/uap_play_panel.xml
@@ -9,6 +9,8 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
 
+    <include layout="@layout/uap_usb_confirm"/>
+
     <include layout="@layout/uap_profile_header"/>
 
     <LinearLayout
diff --git a/apps/CtsVerifier/res/layout/uap_record_panel.xml b/apps/CtsVerifier/res/layout/uap_record_panel.xml
index 2deb738..a5bfcfc 100644
--- a/apps/CtsVerifier/res/layout/uap_record_panel.xml
+++ b/apps/CtsVerifier/res/layout/uap_record_panel.xml
@@ -9,6 +9,8 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
 
+    <include layout="@layout/uap_usb_confirm"/>
+
     <include layout="@layout/uap_profile_header"/>
 
     <LinearLayout
diff --git a/apps/CtsVerifier/res/layout/uap_usb_confirm.xml b/apps/CtsVerifier/res/layout/uap_usb_confirm.xml
new file mode 100644
index 0000000..ea73b88
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/uap_usb_confirm.xml
@@ -0,0 +1,38 @@
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/uap_test_question"/>
+
+    <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:soundEffectsEnabled="false"
+            android:text="@string/uap_test_yes"
+            android:id="@+id/uap_tests_yes_btn" />
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:soundEffectsEnabled="false"
+            android:text="@string/uap_test_no"
+            android:id="@+id/uap_tests_no_btn" />
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:soundEffectsEnabled="false"
+            android:text="@string/uap_test_info"
+            android:id="@+id/uap_test_info_btn" />
+    </LinearLayout>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 7b3f626..3ec34a7 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -4538,4 +4538,30 @@
         Click the button below to confirm that the incoming call was answered.
     </string>
     <string name="telecom_incoming_self_mgd_confirm_answer_button">Confirm Answer</string>
+
+    <string name="uap_test_no">No</string>
+    <string name="uap_test_yes">Yes</string>
+    <string name="uap_test_info">Info</string>
+    <string name="uap_test_question">Does this device allow for the connectiono of a USB reference microphone?</string>
+    <string name="uap_mic_dlg_caption">USB Host Mode Audio Required</string>
+    <string name="uap_mic_dlg_text">This test requires a USB audio peripheral to be connected to the device.
+    If the device under test does not support USB Host Mode Audio (either because it does not have a
+    USB port, or USB Host Mode Audio has been removed from the OS) you can be granted a provisional
+    pass on this test by pressing the \"No\" button and indicating \"Test Pass\" at the bottom.\n
+    Note: Handheld devices supporting USB host mode MUST support USB audio class (CDD 7.7 .2/H-1-1)\n
+    Note: Devices declaring feature android.hardware.audio.pro MUST implement USB host mode (CDD 5.10 C-1-3) and if they omit a 4 conductor 3.5mm audio jack MUST support USB audio class (CDD 5.10 C-3-1)
+    </string>
+
+    <string name="refmic_test_no">No</string>
+    <string name="refmic_test_yes">Yes</string>
+    <string name="refmic_test_info">Info</string>
+    <string name="refmic_test_question">Does this device allow for the connection of a USB reference microphone?</string>
+    <string name="ref_mic_dlg_caption">Reference Mic Required</string>
+    <string name="ref_mic_dlg_text">This test requires a USB Reference Mic to be connected to the device.
+    If the device under test does not support USB Host Mode Audio (either because it does not have a
+    USB port, or USB Host Mode Audio has been removed from the OS) you can be granted a provisional
+    pass on this test by pressing the \"No\" button and indicating \"Test Pass\" at the bottom.\n
+    Note: Handheld devices supporting USB host mode MUST support USB audio class (CDD 7.7 .2/H-1-1)\n
+    Note: Devices declaring feature android.hardware.audio.pro MUST implement USB host mode (CDD 5.10 C-1-3) and if they omit a 4 conductor 3.5mm audio jack MUST support USB audio class (CDD 5.10 C-3-1)
+    </string>
 </resources>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyActivity.java
index 1893ac2..1857d18 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyActivity.java
@@ -53,6 +53,65 @@
 
     public int mMaxLevel = 0;
 
+    private OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
+    //
+    // Common UI Handling
+    protected void connectRefMicUI() {
+        findViewById(R.id.refmic_tests_yes_btn).setOnClickListener(mBtnClickListener);
+        findViewById(R.id.refmic_tests_no_btn).setOnClickListener(mBtnClickListener);
+        findViewById(R.id.refmic_test_info_btn).setOnClickListener(mBtnClickListener);
+
+        enableTestUI(false);
+    }
+
+    private void showRefMicInfoDialog() {
+        new AlertDialog.Builder(this)
+                .setTitle(R.string.ref_mic_dlg_caption)
+                .setMessage(R.string.ref_mic_dlg_text)
+                .setPositiveButton(R.string.audio_general_ok, null)
+                .show();
+    }
+
+    private class OnBtnClickListener implements OnClickListener {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+                case R.id.refmic_tests_yes_btn:
+                    recordRefMicStatus(true);
+                    enableTestUI(true);
+                    // disable test button so that they will now run the test(s)
+                    getPassButton().setEnabled(false);
+                    break;
+
+                case R.id.refmic_tests_no_btn:
+                    recordRefMicStatus(false);
+                    enableTestUI(false);
+                    // Allow the user to "pass" the test.
+                    getPassButton().setEnabled(true);
+                    break;
+
+                case R.id.refmic_test_info_btn:
+                    showRefMicInfoDialog();
+                    break;
+            }
+        }
+    }
+
+    private void recordRefMicStatus(boolean has) {
+        getReportLog().addValue(
+                "User reported ref mic availability: ",
+                has ? 1.0 : 0,
+                ResultType.NEUTRAL,
+                ResultUnit.NONE);
+    }
+
+    //
+    // Overrides
+    //
+    void enableTestUI(boolean enable) {
+
+    }
+
     public void setMaxLevel() {
         AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
         mMaxLevel = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
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 129fb72..e296f86 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyMicActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyMicActivity.java
@@ -238,7 +238,22 @@
                 5.0, -50.0,      /* start top,bottom value */
                 5.0, -50.0      /* stop top,bottom value */);
 
+        connectRefMicUI();
     }
+
+    //
+    // Overrides
+    //
+    void enableTestUI(boolean enable) {
+        mButtonTestNoise.setEnabled(enable);
+        mButtonPlayNoise.setEnabled(enable);
+
+        mButtonTestUsbBackground.setEnabled(enable);
+
+        mButtonTestUsbNoise.setEnabled(enable);
+        mButtonPlayUsbNoise.setEnabled(enable);
+    }
+
     private void playerToggleButton(int buttonId) {
         if (playerIsPlaying()) {
             playerStopAll();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java
index 294e48d..f954b0c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencySpeakerActivity.java
@@ -205,6 +205,15 @@
                 5.0, -50.0,      /* start top,bottom value */
                 5.0, -50.0      /* stop top,bottom value */);
 
+        connectRefMicUI();
+    }
+
+    //
+    // Overrides
+    //
+    void enableTestUI(boolean enable) {
+        mLoopbackPlugReady.setEnabled(enable);
+        mTestButton.setEnabled(enable);
     }
 
     /**
@@ -212,8 +221,8 @@
      */
     private void enableLayout(boolean enable) {
         for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
-            View view = mLinearLayout.getChildAt(i);
-            view.setEnabled(enable);
+            mLoopbackPlugReady.setEnabled(enable);
+            mTestButton.setEnabled(enable);
         }
     }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java
index 009dd58..fb8460b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioFrequencyUnprocessedActivity.java
@@ -292,6 +292,24 @@
         mResultsMic =  new Results("mic_response", mBands);
         mResultsTone = new Results("tone_response", mBandsTone);
         mResultsBack = new Results("background_response", mBandsBack);
+
+        connectRefMicUI();
+    }
+
+    //
+    // Overrides
+    //
+    void enableTestUI(boolean enable) {
+        mButtonTestTone.setEnabled(enable);
+        mButtonPlayTone.setEnabled(enable);
+
+        mButtonTestNoise.setEnabled(enable);
+        mButtonPlayNoise.setEnabled(enable);
+
+        mButtonTestUsbBackground.setEnabled(enable);
+
+        mButtonTestUsbNoise.setEnabled(enable);
+        mButtonPlayUsbNoise.setEnabled(enable);
     }
 
     private void playerToggleButton(int buttonId, int sourceId) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java
index 140757d..8f0a9b0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java
@@ -16,12 +16,18 @@
 
 package com.android.cts.verifier.audio;
 
+import android.app.AlertDialog;
+import com.android.compatibility.common.util.ReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
 import android.media.AudioDeviceCallback;
 import android.media.AudioDeviceInfo;
 import android.media.AudioManager;
 import android.os.Bundle;
 import android.os.Handler;
 import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
 import android.widget.TextView;
 
 import com.android.cts.verifier.audio.peripheralprofile.PeripheralProfile;
@@ -55,6 +61,68 @@
 
     private TextView mPeripheralNameTx;
 
+    private OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
+
+    //
+    // Common UI Handling
+    //
+    protected void connectUSBPeripheralUI() {
+        findViewById(R.id.uap_tests_yes_btn).setOnClickListener(mBtnClickListener);
+        findViewById(R.id.uap_tests_no_btn).setOnClickListener(mBtnClickListener);
+        findViewById(R.id.uap_test_info_btn).setOnClickListener(mBtnClickListener);
+
+        // Leave the default state in tact
+        // enableTestUI(false);
+    }
+
+    private void showUAPInfoDialog() {
+        new AlertDialog.Builder(this)
+                .setTitle(R.string.uap_mic_dlg_caption)
+                .setMessage(R.string.uap_mic_dlg_text)
+                .setPositiveButton(R.string.audio_general_ok, null)
+                .show();
+    }
+
+    private class OnBtnClickListener implements OnClickListener {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+                case R.id.uap_tests_yes_btn:
+                    recordUSBAudioStatus(true);
+                    enableTestUI(true);
+                    // disable test button so that they will now run the test(s)
+                    getPassButton().setEnabled(false);
+                    break;
+
+                case R.id.uap_tests_no_btn:
+                    recordUSBAudioStatus(false);
+                    enableTestUI(false);
+                    // Allow the user to "pass" the test.
+                    getPassButton().setEnabled(true);
+                    break;
+
+                case R.id.uap_test_info_btn:
+                    showUAPInfoDialog();
+                    break;
+            }
+        }
+    }
+
+    private void recordUSBAudioStatus(boolean has) {
+        getReportLog().addValue(
+                "User reported USB Host Audio Support: ",
+                has ? 1.0 : 0,
+                ResultType.NEUTRAL,
+                ResultUnit.NONE);
+    }
+
+    //
+    // Overrides
+    //
+    void enableTestUI(boolean enable) {
+
+    }
+
     public USBAudioPeripheralActivity(boolean mandatedRequired) {
         super();
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
index 5029160..23ed91a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
@@ -47,6 +47,8 @@
 
         setPassFailButtonClickListeners();
         setInfoResources(R.string.usbaudio_attribs_test, R.string.usbaudio_attribs_info, -1);
+
+        connectUSBPeripheralUI();
     }
 
     //
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
index de3ce7f..823f326 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
@@ -83,6 +83,8 @@
         setInfoResources(R.string.usbaudio_buttons_test, R.string.usbaudio_buttons_info, -1);
 
         showDisableAssistantDialog();
+
+        connectUSBPeripheralUI();
     }
 
     private void showButtonsState() {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
index de9016a..4ae5ec3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
@@ -50,11 +50,17 @@
 
         setPassFailButtonClickListeners();
         setInfoResources(R.string.usbaudio_play_test, R.string.usbaudio_play_info, -1);
+
+        connectUSBPeripheralUI();
     }
 
     //
     // USBAudioPeripheralActivity
     // Headset not publicly available, violates CTS Verifier additional equipment guidelines.
+    void enableTestUI(boolean enable) {
+        mPlayBtn.setEnabled(enable);
+    }
+
     public void updateConnectStatus() {
         mPlayBtn.setEnabled(mIsPeripheralAttached);
         getPassButton().setEnabled(mIsPeripheralAttached);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
index 268201c..d51eac3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
@@ -139,11 +139,18 @@
 
         setPassFailButtonClickListeners();
         setInfoResources(R.string.usbaudio_record_test, R.string.usbaudio_record_info, -1);
+
+        connectUSBPeripheralUI();
     }
 
     //
     // USBAudioPeripheralActivity
     //
+    void enableTestUI(boolean enable) {
+        mRecordBtn.setEnabled(enable);
+        mRecordLoopbackBtn.setEnabled(enable);
+    }
+
     public void updateConnectStatus() {
         mRecordBtn.setEnabled(mIsPeripheralAttached);
         mRecordLoopbackBtn.setEnabled(mIsPeripheralAttached);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
index fd62ed2..7796992 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
@@ -339,6 +339,7 @@
                             + e, Toast.LENGTH_SHORT).show();
         }
 
+        super.onCreate(savedInstanceState);
         if (mToBeTestedCameraIds.size() == 0) {
             showToast(R.string.all_exempted_devices);
             ItsTestActivity.this.getReportLog().setSummary(
@@ -346,7 +347,6 @@
                     , 1.0, ResultType.NEUTRAL, ResultUnit.NONE);
             setTestResultAndFinish(true);
         }
-        super.onCreate(savedInstanceState);
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
     }
 
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
index 8b1e28c..e953724 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
@@ -19,6 +19,7 @@
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.PermissionInfo;
+import android.os.Build;
 import com.android.compatibility.common.util.DeviceInfoStore;
 
 import java.io.IOException;
@@ -55,7 +56,8 @@
     protected void collectDeviceInfo(DeviceInfoStore store) throws Exception {
         final PackageManager pm = getContext().getPackageManager();
 
-        final List<PackageInfo> allPackages = pm.getInstalledPackages(PackageManager.GET_PERMISSIONS);
+        final List<PackageInfo> allPackages =
+                pm.getInstalledPackages(PackageManager.GET_PERMISSIONS);
 
         store.startArray(PACKAGE);
         for (PackageInfo pkg : allPackages) {
@@ -72,10 +74,7 @@
 
                         store.startGroup();
                         store.addResult(PERMISSION_NAME, permission);
-                        store.addResult(PERMISSION_FLAGS, pi.flags);
-                        store.addResult(PERMISSION_GROUP, pi.group);
-                        store.addResult(PERMISSION_PROTECTION, pi.getProtection());
-                        store.addResult(PERMISSION_PROTECTION_FLAGS, pi.getProtectionFlags());
+                        writePermissionsDetails(pi, store);
                         store.endGroup();
                     } catch (PackageManager.NameNotFoundException e) {
                         // ignore unrecognized permission and continue
@@ -94,7 +93,7 @@
 
                 store.addResult(HAS_SYSTEM_UID, appInfo.uid < SYS_UID_MAX);
 
-                final boolean canInstall = sharesUidWithPackageHolding(pm, appInfo.uid, INSTALL_PACKAGES_PERMISSION);
+                final boolean canInstall = sharesUidWithInstallerPackage(pm, appInfo.uid);
                 store.addResult(SHARES_INSTALL_PERMISSION, canInstall);
             }
 
@@ -102,7 +101,8 @@
         }
         store.endArray(); // "package"
     }
-    private static boolean sharesUidWithPackageHolding(PackageManager pm, int uid, String permission) {
+
+    private static boolean sharesUidWithInstallerPackage(PackageManager pm, int uid) {
         final String[] sharesUidWith = pm.getPackagesForUid(uid);
 
         if (sharesUidWith == null) {
@@ -110,7 +110,8 @@
         }
 
         // Approx 20 permissions per package for rough estimate of sizing
-        final List<String> sharedPermissions = new ArrayList<>(sharesUidWith.length * 20);
+        final int capacity = sharesUidWith.length * 20;
+        final List<String> sharedPermissions = new ArrayList<>(capacity);
         for (String pkg :sharesUidWith){
             try {
                 final PackageInfo info = pm.getPackageInfo(pkg, PackageManager.GET_PERMISSIONS);
@@ -129,6 +130,27 @@
             }
         }
 
-        return sharedPermissions.contains(permission);
+        return sharedPermissions.contains(PackageDeviceInfo.INSTALL_PACKAGES_PERMISSION);
+    }
+
+    private static void writePermissionsDetails(PermissionInfo pi, DeviceInfoStore store)
+            throws IOException {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+            store.addResult(PERMISSION_FLAGS, pi.flags);
+        } else {
+            store.addResult(PERMISSION_FLAGS, 0);
+        }
+
+        store.addResult(PERMISSION_GROUP, pi.group);
+
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+            store.addResult(PERMISSION_PROTECTION, pi.getProtection());
+            store.addResult(PERMISSION_PROTECTION_FLAGS, pi.getProtectionFlags());
+        } else {
+            store.addResult(PERMISSION_PROTECTION,
+                    pi.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE);
+            store.addResult(PERMISSION_PROTECTION_FLAGS,
+                    pi.protectionLevel & ~PermissionInfo.PROTECTION_MASK_BASE);
+        }
     }
 }
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
index 2c412e7..041c39a 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionsTest.java
@@ -37,6 +37,7 @@
 import android.support.test.uiautomator.UiDevice;
 import android.support.test.uiautomator.UiObject;
 import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.UiObjectNotFoundException;
 import android.support.test.uiautomator.UiScrollable;
 import android.support.test.uiautomator.UiSelector;
 import android.support.test.uiautomator.Until;
@@ -349,6 +350,17 @@
         }
     }
 
+    private boolean scrollToAndGetTextObject(String text) {
+        UiScrollable scroller = new UiScrollable(new UiSelector().scrollable(true));
+        try {
+            // Swipe far away from the edges to avoid not triggering swipes
+            scroller.setSwipeDeadZonePercentage(0.25);
+            return scroller.scrollTextIntoView(text);
+        } catch (UiObjectNotFoundException e) {
+            throw new AssertionError("View with text '" + text + "' was not found!", e);
+        }
+    }
+
     private void setPermissionGrantState(String[] permissions, boolean granted,
             boolean legacyApp) throws Exception {
         getUiDevice().pressBack();
@@ -387,6 +399,7 @@
         for (String permission : permissions) {
             // Find the permission toggle
             String permissionLabel = getPermissionLabel(permission);
+            scrollToAndGetTextObject(permissionLabel);
 
             AccessibilityNodeInfo labelView = getNodeTimed(() -> findByText(permissionLabel), true);
             Assert.assertNotNull("Permission label should be present", labelView);
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DelegatedCertInstallerTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DelegatedCertInstallerTest.java
index 99b310e..74706c9 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DelegatedCertInstallerTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DelegatedCertInstallerTest.java
@@ -324,7 +324,7 @@
 
     private void assertResult(String testName, Boolean expectSuccess) throws InterruptedException {
         assertTrue("Cert installer did not respond in time.",
-                mAvailableResultSemaphore.tryAcquire(10, TimeUnit.SECONDS));
+                mAvailableResultSemaphore.tryAcquire(60, TimeUnit.SECONDS));
         synchronized (this) {
             if (expectSuccess) {
                 assertTrue(testName + " failed unexpectedly.", mReceivedResult);
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index d551872..0b8cc41 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -297,10 +297,12 @@
     }
 
     private void simulateUserInteraction(int timeMs) throws Exception {
+        final long endTime = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeMs);
         final UserActivityEmulator helper = new UserActivityEmulator(getDevice());
-        for (int i = 0; i < timeMs; i += timeMs/10) {
-            Thread.sleep(timeMs/10);
+        while (System.nanoTime() < endTime) {
             helper.tapScreenCenter();
+            // Just in case to prevent busy loop.
+            Thread.sleep(100);
         }
     }
 
diff --git a/hostsidetests/incident/apps/graphicsstatsapp/AndroidManifest.xml b/hostsidetests/incident/apps/graphicsstatsapp/AndroidManifest.xml
index 0f9a3a0..be9d645 100644
--- a/hostsidetests/incident/apps/graphicsstatsapp/AndroidManifest.xml
+++ b/hostsidetests/incident/apps/graphicsstatsapp/AndroidManifest.xml
@@ -20,7 +20,9 @@
 
     <application>
         <uses-library android:name="android.test.runner" />
-        <activity android:name=".DrawFramesActivity" android:label="GraphicsStats Test Activity" />
+        <activity android:name=".DrawFramesActivity"
+                  android:label="GraphicsStats Test Activity"
+                  android:theme="@style/DefaultTheme"/>
     </application>
 
     <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
diff --git a/hostsidetests/incident/apps/graphicsstatsapp/res/values/themes.xml b/hostsidetests/incident/apps/graphicsstatsapp/res/values/themes.xml
new file mode 100644
index 0000000..b3b1514
--- /dev/null
+++ b/hostsidetests/incident/apps/graphicsstatsapp/res/values/themes.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+
+<resources>
+    <style name="DefaultTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:windowFullscreen">true</item>
+        <item name="android:windowOverscan">true</item>
+        <item name="android:fadingEdge">none</item>
+        <item name="android:windowBackground">@android:color/white</item>
+        <item name="android:windowContentTransitions">false</item>
+        <item name="android:windowAnimationStyle">@null</item>
+    </style>
+</resources>
\ No newline at end of file
diff --git a/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java b/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
index 2e3b97a..e6981ba 100644
--- a/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
+++ b/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
@@ -423,8 +423,10 @@
             //        new ViewPressedModifier()),
             //new Layout(R.layout.ratingbar_5, "ratingbar_5_pressed",
             //        new ViewPressedModifier()),
-            new Layout(R.layout.searchview, "searchview_query",
-                    new SearchViewModifier(SearchViewModifier.QUERY)),
+            // Temporarily remove tests for the SearchView widget with no hint. The "X" icon has
+            // indeterminate rendering behavior on 480dpi devices, but we don't know why yet.
+            //new LayoutInfo(R.layout.searchview, "searchview_query",
+            //        new SearchViewModifier(SearchViewModifier.QUERY)),
             new Layout(R.layout.searchview, "searchview_query_hint",
                     new SearchViewModifier(SearchViewModifier.QUERY_HINT)),
             new Layout(R.layout.seekbar_0, "seekbar_0"),
diff --git a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
index 4dc56f8..a77482a 100644
--- a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
+++ b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
@@ -44,6 +44,8 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
+import com.android.compatibility.common.util.CddTest;
+
 /**
  * Test to check non-modifiable themes have not been changed.
  */
@@ -146,7 +148,7 @@
 
         super.tearDown();
     }
-
+    @CddTest(requirement="3.8.6/C-1-1,C-1-2")
     public void testThemes() throws Exception {
         if (checkHardwareTypeSkipTest(mDevice.executeShellCommand(HARDWARE_TYPE_CMD).trim())) {
             Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Skipped themes test for watch / TV / automotive");
diff --git a/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java b/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java
index b286695..83ceabd 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java
@@ -111,10 +111,10 @@
         private static final String DENSITY_PROP_EMULATOR = "qemu.sf.lcd_density";
 
         void setUnsupportedDensity() {
-            // Set device to 6x zoom. It doesn't matter that we're zooming in
+            // Set device to 0.85 zoom. It doesn't matter that we're zooming out
             // since the feature verifies that we're in a non-default density.
             final int stableDensity = getStableDensity();
-            final int targetDensity = (int) (stableDensity * 6);
+            final int targetDensity = (int) (stableDensity * 0.85);
             setDensity(targetDensity);
         }
 
diff --git a/tests/signature/intent-check/DynamicConfig.xml b/tests/signature/intent-check/DynamicConfig.xml
index bfa504e..8300b6d 100644
--- a/tests/signature/intent-check/DynamicConfig.xml
+++ b/tests/signature/intent-check/DynamicConfig.xml
@@ -36,6 +36,7 @@
     //is being sent.
     Bug: 129348724 android.intent.action.DEFINE (public in API 29)
     Bug: 129348724 android.intent.action.TRANSLATE (public in API 29)
+    Bug: 150153196 android.intent.action.LOAD_DATA (system in API 30)
 -->
 <dynamicConfig>
     <entry key ="intent_whitelist">
@@ -53,5 +54,6 @@
       <value>android.intent.action.TIMELINE_POST_VISIT_BADGE</value>
       <value>android.intent.action.DEFINE</value>
       <value>android.intent.action.TRANSLATE</value>
+      <value>android.intent.action.LOAD_DATA</value>
     </entry>
 </dynamicConfig>
diff --git a/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java b/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
index 4479a5d..97b0b8f 100644
--- a/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
+++ b/tests/tests/database/src/android/database/sqlite/cts/SQLiteQueryBuilderTest.java
@@ -18,7 +18,6 @@
 
 
 import android.content.Context;
-import android.content.ContentValues;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteCursor;
 import android.database.sqlite.SQLiteCursorDriver;
@@ -29,15 +28,12 @@
 import android.os.OperationCanceledException;
 import android.test.AndroidTestCase;
 
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Semaphore;
 
 public class SQLiteQueryBuilderTest extends AndroidTestCase {
     private SQLiteDatabase mDatabase;
-    private SQLiteQueryBuilder mStrictBuilder;
-
     private final String TEST_TABLE_NAME = "test";
     private final String EMPLOYEE_TABLE_NAME = "employee";
     private static final String DATABASE_FILE = "database_test.db";
@@ -49,9 +45,6 @@
         getContext().deleteDatabase(DATABASE_FILE);
         mDatabase = getContext().openOrCreateDatabase(DATABASE_FILE, Context.MODE_PRIVATE, null);
         assertNotNull(mDatabase);
-
-        createEmployeeTable();
-        createStrictQueryBuilder();
     }
 
     @Override
@@ -209,6 +202,8 @@
     }
 
     public void testQuery() {
+        createEmployeeTable();
+
         SQLiteQueryBuilder sqliteQueryBuilder = new SQLiteQueryBuilder();
         sqliteQueryBuilder.setTables("Employee");
         Cursor cursor = sqliteQueryBuilder.query(mDatabase,
@@ -281,6 +276,8 @@
     }
 
     public void testCancelableQuery_WhenNotCanceled_ReturnsResultSet() {
+        createEmployeeTable();
+
         CancellationSignal cancellationSignal = new CancellationSignal();
         SQLiteQueryBuilder sqliteQueryBuilder = new SQLiteQueryBuilder();
         sqliteQueryBuilder.setTables("Employee");
@@ -292,6 +289,8 @@
     }
 
     public void testCancelableQuery_WhenCanceledBeforeQuery_ThrowsImmediately() {
+        createEmployeeTable();
+
         CancellationSignal cancellationSignal = new CancellationSignal();
         SQLiteQueryBuilder sqliteQueryBuilder = new SQLiteQueryBuilder();
         sqliteQueryBuilder.setTables("Employee");
@@ -308,6 +307,8 @@
     }
 
     public void testCancelableQuery_WhenCanceledAfterQuery_ThrowsWhenExecuted() {
+        createEmployeeTable();
+
         CancellationSignal cancellationSignal = new CancellationSignal();
         SQLiteQueryBuilder sqliteQueryBuilder = new SQLiteQueryBuilder();
         sqliteQueryBuilder.setTables("Employee");
@@ -326,6 +327,8 @@
     }
 
     public void testCancelableQuery_WhenCanceledDueToContention_StopsWaitingAndThrows() {
+        createEmployeeTable();
+
         for (int i = 0; i < 5; i++) {
             final CancellationSignal cancellationSignal = new CancellationSignal();
             final Semaphore barrier1 = new Semaphore(0);
@@ -457,152 +460,6 @@
         fail("Could not prove that the query actually canceled midway during execution.");
     }
 
-    public void testStrictQuery() throws Exception {
-        final SQLiteQueryBuilder qb = mStrictBuilder;
-
-        // Should normally only be able to see one row
-        try (Cursor c = qb.query(mDatabase, null, null, null, null, null, null)) {
-            assertEquals(1, c.getCount());
-        }
-
-        // Trying sneaky queries should fail; even if they somehow succeed, we
-        // shouldn't get to see any other data.
-        try (Cursor c = qb.query(mDatabase, null, "1=1", null, null, null, null)) {
-            assertEquals(1, c.getCount());
-        } catch (Exception tolerated) {
-        }
-        try (Cursor c = qb.query(mDatabase, null, "1=1 --", null, null, null, null)) {
-            assertEquals(1, c.getCount());
-        } catch (Exception tolerated) {
-        }
-        try (Cursor c = qb.query(mDatabase, null, "1=1) OR (1=1", null, null, null, null)) {
-            assertEquals(1, c.getCount());
-        } catch (Exception tolerated) {
-        }
-        try (Cursor c = qb.query(mDatabase, null, "1=1)) OR ((1=1", null, null, null, null)) {
-            assertEquals(1, c.getCount());
-        } catch (Exception tolerated) {
-        }
-    }
-
-    private static final String[] COLUMNS_VALID = new String[] {
-            "_id",
-    };
-
-    private static final String[] COLUMNS_INVALID = new String[] {
-            "salary",
-            "MAX(salary)",
-            "undefined",
-            "(secret_column IN secret_table)",
-            "(SELECT secret_column FROM secret_table)",
-    };
-
-    public void testStrictQueryProjection() throws Exception {
-        for (String column : COLUMNS_VALID) {
-            assertStrictQueryValid(
-                    new String[] { column }, null, null, null, null, null, null);
-        }
-        for (String column : COLUMNS_INVALID) {
-            assertStrictQueryInvalid(
-                    new String[] { column }, null, null, null, null, null, null);
-        }
-    }
-
-    public void testStrictQueryWhere() throws Exception {
-        for (String column : COLUMNS_VALID) {
-            assertStrictQueryValid(
-                    null, column + ">0", null, null, null, null, null);
-            assertStrictQueryValid(
-                    null, "_id>" + column, null, null, null, null, null);
-        }
-        for (String column : COLUMNS_INVALID) {
-            assertStrictQueryInvalid(
-                    null, column + ">0", null, null, null, null, null);
-            assertStrictQueryInvalid(
-                    null, "_id>" + column, null, null, null, null, null);
-        }
-    }
-
-    public void testStrictQueryGroupBy() {
-        for (String column : COLUMNS_VALID) {
-            assertStrictQueryValid(
-                    null, null, null, column, null, null, null);
-            assertStrictQueryValid(
-                    null, null, null, "_id," + column, null, null, null);
-        }
-        for (String column : COLUMNS_INVALID) {
-            assertStrictQueryInvalid(
-                    null, null, null, column, null, null, null);
-            assertStrictQueryInvalid(
-                    null, null, null, "_id," + column, null, null, null);
-        }
-    }
-
-    public void testStrictQueryHaving() {
-        for (String column : COLUMNS_VALID) {
-            assertStrictQueryValid(
-                    null, null, null, "_id", column, null, null);
-        }
-        for (String column : COLUMNS_INVALID) {
-            assertStrictQueryInvalid(
-                    null, null, null, "_id", column, null, null);
-        }
-    }
-
-    public void testStrictQueryOrderBy() {
-        for (String column : COLUMNS_VALID) {
-            assertStrictQueryValid(
-                    null, null, null, null, null, column, null);
-            assertStrictQueryValid(
-                    null, null, null, null, null, column + " ASC", null);
-            assertStrictQueryValid(
-                    null, null, null, null, null, "_id COLLATE NOCASE ASC," + column, null);
-        }
-        for (String column : COLUMNS_INVALID) {
-            assertStrictQueryInvalid(
-                    null, null, null, null, null, column, null);
-            assertStrictQueryInvalid(
-                    null, null, null, null, null, column + " ASC", null);
-            assertStrictQueryInvalid(
-                    null, null, null, null, null, "_id COLLATE NOCASE ASC," + column, null);
-        }
-    }
-
-    public void testStrictQueryLimit() {
-        assertStrictQueryValid(
-                null, null, null, null, null, null, "32");
-        assertStrictQueryValid(
-                null, null, null, null, null, null, "0,32");
-        assertStrictQueryValid(
-                null, null, null, null, null, null, "32 OFFSET 0");
-
-        for (String column : COLUMNS_VALID) {
-            assertStrictQueryInvalid(
-                    null, null, null, null, null, null, column);
-        }
-        for (String column : COLUMNS_INVALID) {
-            assertStrictQueryInvalid(
-                    null, null, null, null, null, null, column);
-        }
-    }
-
-    private void assertStrictQueryValid(String[] projectionIn, String selection,
-            String[] selectionArgs, String groupBy, String having, String sortOrder, String limit) {
-        try (Cursor c = mStrictBuilder.query(mDatabase, projectionIn, selection, selectionArgs,
-                groupBy, having, sortOrder, limit, null)) {
-        }
-    }
-
-    private void assertStrictQueryInvalid(String[] projectionIn, String selection,
-            String[] selectionArgs, String groupBy, String having, String sortOrder, String limit) {
-        try (Cursor c = mStrictBuilder.query(mDatabase, projectionIn, selection, selectionArgs,
-                groupBy, having, sortOrder, limit, null)) {
-            fail(Arrays.asList(projectionIn, selection, selectionArgs,
-                    groupBy, having, sortOrder, limit).toString());
-        } catch (Exception expected) {
-        }
-    }
-
     private void createEmployeeTable() {
         mDatabase.execSQL("CREATE TABLE employee (_id INTEGER PRIMARY KEY, " +
                 "name TEXT, month INTEGER, salary INTEGER);");
@@ -619,17 +476,4 @@
         mDatabase.execSQL("INSERT INTO employee (name, month, salary) " +
                 "VALUES ('Jim', '3', '3500');");
     }
-
-    private void createStrictQueryBuilder() {
-        mStrictBuilder = new SQLiteQueryBuilder();
-        mStrictBuilder.setTables("employee");
-        mStrictBuilder.setStrict(true);
-        mStrictBuilder.appendWhere("month=2");
-
-        final Map<String, String> projectionMap = new HashMap<>();
-        projectionMap.put("_id", "_id");
-        projectionMap.put("name", "name");
-        projectionMap.put("month", "month");
-        mStrictBuilder.setProjectionMap(projectionMap);
-    }
 }
diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
index 6b925d4..b74dcb6 100644
--- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
@@ -50,6 +50,7 @@
 import static org.junit.matchers.JUnitMatchers.hasItems;
 
 import com.google.common.collect.ImmutableSet;
+import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.Context;
 import android.os.Build;
@@ -155,6 +156,10 @@
                 KM_PURPOSE_SIGN, KM_PURPOSE_VERIFY, KM_PURPOSE_SIGN | KM_PURPOSE_VERIFY
         };
 
+        // Skip the test if there is no secure lock screen
+        if (!hasSecureLockScreen()) {
+            return;
+        }
         for (int curveIndex = 0; curveIndex < curves.length; ++curveIndex) {
             for (int challengeIndex = 0; challengeIndex < challenges.length; ++challengeIndex) {
                 for (int purposeIndex = 0; purposeIndex < purposes.length; ++purposeIndex) {
@@ -280,6 +285,10 @@
                 },
         };
 
+        // Skip the test if there is no secure lock screen
+        if (!hasSecureLockScreen()) {
+            return;
+        }
         for (int keySize : keySizes) {
             for (byte[] challenge : challenges) {
                 for (int purpose : purposes) {
@@ -938,4 +947,15 @@
             }
         }
     }
+    /*
+     * Device that don't report android.software.device_admin doesn't have secure lock screen
+     * because device with secure lock screen MUST report android.software.device_admin .
+     *
+     * https://source.android.com/compatibility/7.0/android-7.0-cdd.html#3_9_device_administration
+     *
+     */
+    private boolean hasSecureLockScreen() {
+        PackageManager pm = getContext().getPackageManager();
+        return pm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN);
+    }
 }
diff --git a/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java b/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java
index 0a9d2b6..98d2049 100644
--- a/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssPseudorangeVerificationTest.java
@@ -41,20 +41,24 @@
   private static final int MIN_SATELLITES_REQUIREMENT = 4;
   private static final double SECONDS_PER_NANO = 1.0e-9;
 
-  // GPS/GLONASS: according to http://cdn.intechopen.com/pdfs-wm/27712.pdf, the pseudorange in time
-  // is 65-83 ms, which is 18 ms range.
-  // GLONASS: orbit is a bit closer than GPS, so we add 0.003ms to the range, hence deltaiSeconds
-  // should be in the range of [0.0, 0.021] seconds.
-  // QZSS and BEIDOU: they have higher orbit, which will result in a small svTime, the deltai can be
-  // calculated as follows:
-  // assume a = QZSS/BEIDOU orbit Semi-Major Axis(42,164km for QZSS);
-  // b = GLONASS orbit Semi-Major Axis (25,508km);
-  // c = Speed of light (299,792km/s);
-  // e = earth radius (6,378km);
-  // in the extremely case of QZSS is on the horizon and GLONASS is on the 90 degree top
-  // max difference should be (sqrt(a^2-e^2) - (b-e))/c,
-  // which is around 0.076s.
-  private static final double PSEUDORANGE_THRESHOLD_IN_SEC = 0.021;
+    // GPS/GLONASS: according to http://cdn.intechopen.com/pdfs-wm/27712.pdf, the pseudorange in
+    // time
+    // is 65-83 ms, which is 18 ms range.
+    // GLONASS: orbit is a bit closer than GPS, so we add 0.003ms to the range, hence deltaiSeconds
+    // should be in the range of [0.0, 0.021] seconds.
+    // QZSS and BEIDOU: they have higher orbit, which will result in a small svTime, the deltai
+    // can be
+    // calculated as follows:
+    // assume a = QZSS/BEIDOU orbit Semi-Major Axis(42,164km for QZSS);
+    // b = GLONASS orbit Semi-Major Axis (25,508km);
+    // c = Speed of light (299,792km/s);
+    // e = earth radius (6,378km);
+    // in the extremely case of QZSS is on the horizon and GLONASS is on the 90 degree top
+    // max difference should be (sqrt(a^2-e^2) - (b-e))/c,
+    // which is around 0.076s.
+    // 2 Galileo satellites (E14 & E18) have elliptical orbits, so Galileo can have up-to 48ms of
+    // spread.
+    private static final double PSEUDORANGE_THRESHOLD_IN_SEC = 0.048;
   // Geosync constellations have a longer range vs typical MEO orbits
   // that are the short end of the range.
   private static final double PSEUDORANGE_THRESHOLD_BEIDOU_QZSS_IN_SEC = 0.076;
@@ -177,23 +181,27 @@
     return measurementConstellationMap;
   }
 
-  private ArrayList<GnssMeasurement> filterMeasurements(Collection<GnssMeasurement> measurements) {
-    ArrayList<GnssMeasurement> filteredMeasurement = new ArrayList<>();
-    for (GnssMeasurement measurement: measurements){
-      int constellationType = measurement.getConstellationType();
-      if (constellationType == GnssStatus.CONSTELLATION_GLONASS) {
-        if ((measurement.getState()
-            & (measurement.STATE_GLO_TOD_DECODED | measurement.STATE_GLO_TOD_KNOWN)) != 0) {
-          filteredMeasurement.add(measurement);
+    private static ArrayList<GnssMeasurement> filterMeasurements(
+            Collection<GnssMeasurement> measurements) {
+        ArrayList<GnssMeasurement> filteredMeasurement = new ArrayList<>();
+        for (GnssMeasurement measurement : measurements) {
+            int constellationType = measurement.getConstellationType();
+            if ((measurement.getState() & GnssMeasurement.STATE_CODE_LOCK) == 0) {
+                continue;
+            }
+            if (constellationType == GnssStatus.CONSTELLATION_GLONASS) {
+                if ((measurement.getState()
+                        & (GnssMeasurement.STATE_GLO_TOD_DECODED
+                        | GnssMeasurement.STATE_GLO_TOD_KNOWN)) != 0) {
+                    filteredMeasurement.add(measurement);
+                }
+            } else if ((measurement.getState() & (GnssMeasurement.STATE_TOW_DECODED
+                    | GnssMeasurement.STATE_TOW_KNOWN)) != 0) {
+                filteredMeasurement.add(measurement);
+            }
         }
-      }
-      else if ((measurement.getState()
-            & (measurement.STATE_TOW_DECODED | measurement.STATE_TOW_KNOWN)) != 0) {
-          filteredMeasurement.add(measurement);
-        }
+        return filteredMeasurement;
     }
-    return filteredMeasurement;
-  }
 
   /**
    * Uses the common reception time approach to calculate pseudorange time
diff --git a/tests/tests/media/src/android/media/cts/AudioManagerTest.java b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
index 67111e9..8ba815f 100644
--- a/tests/tests/media/src/android/media/cts/AudioManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
@@ -609,6 +609,11 @@
         int maxMusicVolume = mAudioManager.getStreamMaxVolume(STREAM_MUSIC);
 
         for (int stream : streams) {
+
+            if (mIsSingleVolume && stream != AudioManager.STREAM_MUSIC) {
+                continue;
+            }
+
             // set ringer mode to back normal to not interfere with volume tests
             mAudioManager.setRingerMode(RINGER_MODE_NORMAL);
 
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
index d3235da..9fb7ac4 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiEnterpriseConfigTest.java
@@ -34,7 +34,6 @@
 
 public class WifiEnterpriseConfigTest extends AndroidTestCase {
     private  WifiManager mWifiManager;
-
     private static final String SSID = "\"TestSSID\"";
     private static final String IDENTITY = "identity";
     private static final String PASSWORD = "password";
@@ -684,6 +683,9 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+        if(!hasWifi()) {
+            return;
+        }
         mWifiManager = (WifiManager) mContext
                 .getSystemService(Context.WIFI_SERVICE);
         assertNotNull(mWifiManager);
@@ -802,6 +804,9 @@
     }
 
     public void testEnterpriseConfigDoesNotPrintPassword() {
+        if(!hasWifi()) {
+            return;
+        }
         WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
         final String identity = "IdentityIsOkayToBeDisplayedHere";
         final String password = "PasswordIsNotOkayToBeDisplayedHere";
diff --git a/tests/tests/os/Android.mk b/tests/tests/os/Android.mk
index 89eb444..cc14790 100644
--- a/tests/tests/os/Android.mk
+++ b/tests/tests/os/Android.mk
@@ -40,8 +40,7 @@
     src/android/os/cts/IEmptyService.aidl \
     src/android/os/cts/ISeccompIsolatedService.aidl \
     src/android/os/cts/ISecondary.aidl \
-    src/android/os/cts/ISharedMemoryService.aidl \
-    src/android/os/cts/IParcelExceptionService.aidl \
+    src/android/os/cts/ISharedMemoryService.aidl
 
 LOCAL_PACKAGE_NAME := CtsOsTestCases
 
diff --git a/tests/tests/os/AndroidManifest.xml b/tests/tests/os/AndroidManifest.xml
index 9407405..ef4893e 100644
--- a/tests/tests/os/AndroidManifest.xml
+++ b/tests/tests/os/AndroidManifest.xml
@@ -80,14 +80,6 @@
             android:name="android.os.cts.SharedMemoryService"
             android:process=":sharedmem"
             android:exported="false" />
-        <service
-            android:name="android.os.cts.ParcelExceptionService"
-            android:process=":remote"
-            android:exported="true" />
-        <service
-            android:name="android.os.cts.ParcelTest$ParcelObjectFreeService"
-            android:process=":remote"
-            android:exported="true" />
 
         <service android:name="android.os.cts.LocalService">
             <intent-filter>
diff --git a/tests/tests/os/src/android/os/cts/ExceptionalParcelable.aidl b/tests/tests/os/src/android/os/cts/ExceptionalParcelable.aidl
deleted file mode 100644
index 7d09693..0000000
--- a/tests/tests/os/src/android/os/cts/ExceptionalParcelable.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2019 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.os.cts;
-
-parcelable ExceptionalParcelable;
\ No newline at end of file
diff --git a/tests/tests/os/src/android/os/cts/ExceptionalParcelable.java b/tests/tests/os/src/android/os/cts/ExceptionalParcelable.java
deleted file mode 100644
index 333cf57..0000000
--- a/tests/tests/os/src/android/os/cts/ExceptionalParcelable.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2019 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.os.cts;
-
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-
-public class ExceptionalParcelable implements Parcelable {
-    private final IBinder mBinder;
-
-    ExceptionalParcelable(IBinder binder) {
-        mBinder = binder;
-    }
-
-    public int describeContents() {
-        return 0;
-    }
-
-    /**
-     * Write a binder to the Parcel and then throw an exception
-     */
-    public void writeToParcel(Parcel out, int flags) {
-        // Write a binder for the exception to overwrite
-        out.writeStrongBinder(mBinder);
-
-        // Throw an exception
-        throw new IllegalArgumentException("A truly exceptional message");
-    }
-
-    public static final Creator<ExceptionalParcelable> CREATOR =
-            new Creator<ExceptionalParcelable>() {
-                @Override
-                public ExceptionalParcelable createFromParcel(Parcel source) {
-                    return new ExceptionalParcelable(source.readStrongBinder());
-                }
-
-                @Override
-                public ExceptionalParcelable[] newArray(int size) {
-                    return new ExceptionalParcelable[size];
-                }
-            };
-}
diff --git a/tests/tests/os/src/android/os/cts/IParcelExceptionService.aidl b/tests/tests/os/src/android/os/cts/IParcelExceptionService.aidl
deleted file mode 100644
index ce7af6d..0000000
--- a/tests/tests/os/src/android/os/cts/IParcelExceptionService.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2019 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.os.cts;
-import android.os.cts.ExceptionalParcelable;
-
-interface IParcelExceptionService {
-//parcelable android.os.cts.ExceptionalParcelable;
-    ExceptionalParcelable writeBinderThrowException();
-}
diff --git a/tests/tests/os/src/android/os/cts/ParcelExceptionService.java b/tests/tests/os/src/android/os/cts/ParcelExceptionService.java
deleted file mode 100644
index d8387e3..0000000
--- a/tests/tests/os/src/android/os/cts/ParcelExceptionService.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2019 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.os.cts;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.Binder;
-import android.os.IBinder;
-import android.os.RemoteException;
-
-public class ParcelExceptionService extends Service {
-    @Override
-    public IBinder onBind(Intent intent) {
-        return new ParcelExceptionServiceImpl();
-    }
-
-    private static class ParcelExceptionServiceImpl extends IParcelExceptionService.Stub {
-        private final IBinder mBinder = new Binder();
-
-
-        @Override
-        public ExceptionalParcelable writeBinderThrowException() throws RemoteException {
-            return new ExceptionalParcelable(mBinder);
-        }
-    }
-}
diff --git a/tests/tests/os/src/android/os/cts/ParcelTest.java b/tests/tests/os/src/android/os/cts/ParcelTest.java
index 762a10e..987ab00 100644
--- a/tests/tests/os/src/android/os/cts/ParcelTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelTest.java
@@ -24,15 +24,7 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
-import android.app.Service;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
 import android.content.pm.Signature;
 import android.os.BadParcelableException;
 import android.os.Binder;
@@ -47,8 +39,6 @@
 import android.util.SparseArray;
 import android.util.SparseBooleanArray;
 
-import com.google.common.util.concurrent.AbstractFuture;
-
 public class ParcelTest extends AndroidTestCase {
 
     public void testObtain() {
@@ -3293,119 +3283,4 @@
             // good
         }
     }
-
-    public static class ParcelExceptionConnection extends AbstractFuture<IParcelExceptionService>
-            implements ServiceConnection {
-        @Override
-        public void onServiceConnected(ComponentName name, IBinder service) {
-            set(IParcelExceptionService.Stub.asInterface(service));
-        }
-
-        @Override
-        public void onServiceDisconnected(ComponentName name) {
-        }
-
-        @Override
-        public IParcelExceptionService get() throws InterruptedException, ExecutionException {
-            try {
-                return get(5, TimeUnit.SECONDS);
-            } catch (TimeoutException e) {
-                throw new RuntimeException(e);
-            }
-        }
-    }
-
-    public void testExceptionOverwritesObject() throws Exception {
-        final Intent intent = new Intent();
-        intent.setComponent(new ComponentName(
-                "android.os.cts", "android.os.cts.ParcelExceptionService"));
-
-        final ParcelExceptionConnection connection = new ParcelExceptionConnection();
-
-        mContext.startService(intent);
-        assertTrue(mContext.bindService(intent, connection,
-                Context.BIND_ABOVE_CLIENT | Context.BIND_EXTERNAL_SERVICE));
-
-
-        Parcel data = Parcel.obtain();
-        Parcel reply = Parcel.obtain();
-        data.writeInterfaceToken("android.os.cts.IParcelExceptionService");
-        IParcelExceptionService service = connection.get();
-        try {
-            assertTrue("Transaction failed", service.asBinder().transact(
-                    IParcelExceptionService.Stub.TRANSACTION_writeBinderThrowException, data, reply,
-                    0));
-        } catch (Exception e) {
-            fail("Exception caught from transaction: " + e);
-        }
-        reply.setDataPosition(0);
-        assertTrue("Exception should have occurred on service-side",
-                reply.readExceptionCode() != 0);
-        assertNull("Binder should have been overwritten by the exception",
-                reply.readStrongBinder());
-    }
-
-    public static class ParcelObjectFreeService extends Service {
-
-        @Override
-        public IBinder onBind(Intent intent) {
-            return new Binder();
-        }
-
-        @Override
-        public void onCreate() {
-            super.onCreate();
-
-            Parcel parcel = Parcel.obtain();
-
-            // Construct parcel with object in it.
-            parcel.writeInt(1);
-            final int pos = parcel.dataPosition();
-            parcel.writeStrongBinder(new Binder());
-
-            // wipe out the object by setting data size
-            parcel.setDataSize(pos);
-
-            // recycle the parcel. This should not cause a native segfault
-            parcel.recycle();
-        }
-
-        public static class Connection extends AbstractFuture<IBinder>
-                implements ServiceConnection {
-
-            @Override
-            public void onServiceConnected(ComponentName name, IBinder service) {
-                set(service);
-            }
-
-            @Override
-            public void onServiceDisconnected(ComponentName name) {
-            }
-
-            @Override
-            public IBinder get() throws InterruptedException, ExecutionException {
-                try {
-                    return get(5, TimeUnit.SECONDS);
-                } catch (TimeoutException e) {
-                    return null;
-                }
-            }
-        }
-    }
-
-    public void testObjectDoubleFree() throws Exception {
-
-        final Intent intent = new Intent();
-        intent.setComponent(new ComponentName(
-                "android.os.cts", "android.os.cts.ParcelTest$ParcelObjectFreeService"));
-
-        final ParcelObjectFreeService.Connection connection =
-                new ParcelObjectFreeService.Connection();
-
-        mContext.startService(intent);
-        assertTrue(mContext.bindService(intent, connection,
-                Context.BIND_ABOVE_CLIENT | Context.BIND_EXTERNAL_SERVICE));
-
-        assertNotNull("Service should have started without crashing.", connection.get());
-    }
 }
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index 627fc27..14efe46 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -97,17 +97,17 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_3829() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_3829);
+        doStagefrightTest(R.raw.cve_2016_3829, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testStagefright_cve_2017_0643() throws Exception {
-        doStagefrightTest(R.raw.cve_2017_0643);
+        doStagefrightTest(R.raw.cve_2017_0643, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testStagefright_cve_2017_0728() throws Exception {
-        doStagefrightTest(R.raw.cve_2017_0728);
+        doStagefrightTest(R.raw.cve_2017_0728, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -144,7 +144,7 @@
     }
 
     public void testStagefright_bug_35763994() throws Exception {
-        doStagefrightTest(R.raw.bug_35763994);
+        doStagefrightTest(R.raw.bug_35763994, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -154,7 +154,7 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_2507() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_2507);
+        doStagefrightTest(R.raw.cve_2016_2507, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -249,13 +249,14 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_2429_b_27211885() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_2429_b_27211885);
+        doStagefrightTest(R.raw.cve_2016_2429_b_27211885,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testStagefright_bug_34031018() throws Exception {
-        doStagefrightTest(R.raw.bug_34031018_32bit);
-        doStagefrightTest(R.raw.bug_34031018_64bit);
+        doStagefrightTest(R.raw.bug_34031018_32bit, new CrashUtils.Config().checkMinAddress(false));
+        doStagefrightTest(R.raw.bug_34031018_64bit, new CrashUtils.Config().checkMinAddress(false));
     }
 
     /***********************************************************
@@ -280,7 +281,8 @@
 
     @SecurityTest
     public void testStagefright_cve_2017_0852_b_62815506() throws Exception {
-        doStagefrightTest(R.raw.cve_2017_0852_b_62815506);
+        doStagefrightTest(R.raw.cve_2017_0852_b_62815506,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -306,7 +308,7 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_3920() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_3920);
+        doStagefrightTest(R.raw.cve_2016_3920, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -321,7 +323,7 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_3821() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_3821);
+        doStagefrightTest(R.raw.cve_2016_3821, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -341,12 +343,12 @@
 
     @SecurityTest
     public void testStagefright_bug_38115076() throws Exception {
-        doStagefrightTest(R.raw.bug_38115076);
+        doStagefrightTest(R.raw.bug_38115076, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testStagefright_bug_34618607() throws Exception {
-        doStagefrightTest(R.raw.bug_34618607);
+        doStagefrightTest(R.raw.bug_34618607, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -371,13 +373,14 @@
 
     @SecurityTest
     public void testStagefright_cve_2017_0600() throws Exception {
-        doStagefrightTest(R.raw.cve_2017_0600);
+        doStagefrightTest(R.raw.cve_2017_0600, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testBug_38014992() throws Exception {
         int[] frameSizes = getFrameSizes(R.raw.bug_38014992_framelen);
-        doStagefrightTestRawBlob(R.raw.bug_38014992_avc, "video/avc", 640, 480, frameSizes);
+        doStagefrightTestRawBlob(R.raw.bug_38014992_avc, "video/avc", 640, 480, frameSizes,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -407,7 +410,8 @@
     @SecurityTest
     public void testBug_33387820() throws Exception {
         int[] frameSizes = {45, 3202, 430, 2526};
-        doStagefrightTestRawBlob(R.raw.bug_33387820_avc, "video/avc", 320, 240, frameSizes);
+        doStagefrightTestRawBlob(R.raw.bug_33387820_avc, "video/avc", 320, 240, frameSizes,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -443,13 +447,15 @@
     @SecurityTest
     public void testBug_28816956() throws Exception {
         int[] frameSizes = getFrameSizes(R.raw.bug_28816956_framelen);
-        doStagefrightTestRawBlob(R.raw.bug_28816956_hevc, "video/hevc", 352, 288, frameSizes);
+        doStagefrightTestRawBlob(R.raw.bug_28816956_hevc, "video/hevc", 352, 288, frameSizes,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testBug_33818500() throws Exception {
         int[] frameSizes = getFrameSizes(R.raw.bug_33818500_framelen);
-        doStagefrightTestRawBlob(R.raw.bug_33818500_avc, "video/avc", 64, 32, frameSizes);
+        doStagefrightTestRawBlob(R.raw.bug_33818500_avc, "video/avc", 64, 32, frameSizes,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -478,7 +484,7 @@
 
     @SecurityTest
     public void testStagefright_cve_2017_0599() throws Exception {
-        doStagefrightTest(R.raw.cve_2017_0599);
+        doStagefrightTest(R.raw.cve_2017_0599, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -508,7 +514,7 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_6712() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_6712);
+        doStagefrightTest(R.raw.cve_2016_6712, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -534,12 +540,12 @@
 
     @SecurityTest
     public void testStagefright_bug_33818508() throws Exception {
-        doStagefrightTest(R.raw.bug_33818508);
+        doStagefrightTest(R.raw.bug_33818508, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testStagefright_bug_32873375() throws Exception {
-        doStagefrightTest(R.raw.bug_32873375);
+        doStagefrightTest(R.raw.bug_32873375, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -594,7 +600,7 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_2428() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_2428);
+        doStagefrightTest(R.raw.cve_2016_2428, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -604,7 +610,7 @@
 
     @SecurityTest
     public void testStagefright_bug_32322258() throws Exception {
-        doStagefrightTest(R.raw.bug_32322258);
+        doStagefrightTest(R.raw.bug_32322258, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -634,7 +640,8 @@
 
     @SecurityTest
     public void testStagefright_cve_2015_3862_b_22954006() throws Exception {
-        doStagefrightTest(R.raw.cve_2015_3862_b_22954006);
+        doStagefrightTest(R.raw.cve_2015_3862_b_22954006,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -694,12 +701,13 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_3755() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_3755);
+        doStagefrightTest(R.raw.cve_2016_3755, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testStagefright_cve_2016_3878_b_29493002() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_3878_b_29493002);
+        doStagefrightTest(R.raw.cve_2016_3878_b_29493002,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -719,11 +727,11 @@
 
     @SecurityTest
     public void testStagefright_bug_27855419_CVE_2016_2463() throws Exception {
-        doStagefrightTest(R.raw.bug_27855419);
+        doStagefrightTest(R.raw.bug_27855419, new CrashUtils.Config().checkMinAddress(false));
     }
 
     public void testStagefright_bug_19779574() throws Exception {
-        doStagefrightTest(R.raw.bug_19779574);
+        doStagefrightTest(R.raw.bug_19779574, new CrashUtils.Config().checkMinAddress(false));
     }
 
     /***********************************************************
@@ -754,7 +762,7 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_6764() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_6764);
+        doStagefrightTest(R.raw.cve_2016_6764, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -764,7 +772,7 @@
 
     @SecurityTest
     public void testStagefright_bug_35467107() throws Exception {
-        doStagefrightTest(R.raw.bug_35467107);
+        doStagefrightTest(R.raw.bug_35467107, new CrashUtils.Config().checkMinAddress(false));
     }
 
     /***********************************************************
@@ -817,12 +825,12 @@
 
     @SecurityTest
     public void testStagefright_cve_2016_6765() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_6765);
+        doStagefrightTest(R.raw.cve_2016_6765, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
     public void testStagefright_cve_2016_2508() throws Exception {
-        doStagefrightTest(R.raw.cve_2016_2508);
+        doStagefrightTest(R.raw.cve_2016_2508, new CrashUtils.Config().checkMinAddress(false));
     }
 
     @SecurityTest
@@ -831,9 +839,13 @@
     }
 
     private void doStagefrightTest(final int rid) throws Exception {
-        doStagefrightTestMediaPlayer(rid);
-        doStagefrightTestMediaCodec(rid);
-        doStagefrightTestMediaMetadataRetriever(rid);
+        doStagefrightTest(rid, null);
+    }
+
+    private void doStagefrightTest(final int rid, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaPlayer(rid, config);
+        doStagefrightTestMediaCodec(rid, config);
+        doStagefrightTestMediaMetadataRetriever(rid, config);
 
         Context context = getInstrumentation().getContext();
         Resources resources =  context.getResources();
@@ -841,9 +853,10 @@
         String rname = resources.getResourceEntryName(rid);
         String url = server.getAssetUrl("raw/" + rname);
         verifyServer(rid, url);
-        doStagefrightTestMediaPlayer(url);
-        doStagefrightTestMediaCodec(url);
-        doStagefrightTestMediaMetadataRetriever(url);
+
+        doStagefrightTestMediaPlayer(url, config);
+        doStagefrightTestMediaCodec(url, config);
+        doStagefrightTestMediaMetadataRetriever(url, config);
         server.shutdown();
     }
 
@@ -873,11 +886,16 @@
     }
 
     private void doStagefrightTest(final int rid, int timeout) throws Exception {
+        doStagefrightTest(rid, null, timeout);
+    }
+
+    private void doStagefrightTest(
+            final int rid, CrashUtils.Config config, int timeout) throws Exception {
         runWithTimeout(new Runnable() {
             @Override
             public void run() {
                 try {
-                  doStagefrightTest(rid);
+                  doStagefrightTest(rid, config);
                 } catch (Exception e) {
                   fail(e.toString());
                 }
@@ -886,7 +904,12 @@
     }
 
     private void doStagefrightTestANR(final int rid) throws Exception {
-        doStagefrightTestMediaPlayerANR(rid, null);
+        doStagefrightTestANR(rid, null);
+    }
+
+    private void doStagefrightTestANR(
+            final int rid, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaPlayerANR(rid, null, config);
     }
 
     private Surface getDummySurface() {
@@ -946,6 +969,8 @@
         MediaPlayer.OnPreparedListener,
         MediaPlayer.OnCompletionListener {
 
+        CrashUtils.Config config;
+
         private final Pattern[] validProcessPatterns = {
             Pattern.compile("adsprpcd"),
             Pattern.compile("android\\.hardware\\.cas@\\d+?\\.\\d+?-service"),
@@ -965,6 +990,19 @@
             Pattern.compile("vendor.*"),
         };
 
+        MediaPlayerCrashListener() {
+            this(null);
+        }
+
+        MediaPlayerCrashListener(CrashUtils.Config config) {
+            if (config == null) {
+                config = new CrashUtils.Config();
+            }
+            // if a different process is needed for a test, it should be added to the main list.
+            config.setProcessPatterns(validProcessPatterns);
+            this.config = config;
+        }
+
         @Override
         public boolean onError(MediaPlayer mp, int newWhat, int extra) {
             Log.i(TAG, "error: " + newWhat + "/" + extra);
@@ -1010,7 +1048,7 @@
                 if (crashes == null) {
                     Log.e(TAG, "Crash results not found for test " + getName());
                     return what;
-                } else if (CrashUtils.securityCrashDetected(crashes, true, validProcessPatterns)) {
+                } else if (CrashUtils.securityCrashDetected(crashes, config)) {
                     return what;
                 } else {
                     Log.i(TAG, "Crash ignored due to no security crash found for test " +
@@ -1058,11 +1096,21 @@
     }
 
     private void doStagefrightTestMediaPlayer(final int rid) throws Exception {
-        doStagefrightTestMediaPlayer(rid, null);
+        doStagefrightTestMediaPlayer(rid, null, null);
+    }
+
+    private void doStagefrightTestMediaPlayer(
+            final int rid, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaPlayer(rid, null, config);
     }
 
     private void doStagefrightTestMediaPlayer(final String url) throws Exception {
-        doStagefrightTestMediaPlayer(-1, url);
+        doStagefrightTestMediaPlayer(url, null);
+    }
+
+    private void doStagefrightTestMediaPlayer(
+            final String url, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaPlayer(-1, url, config);
     }
 
     private void closeQuietly(AutoCloseable closeable) {
@@ -1077,12 +1125,17 @@
     }
 
     private void doStagefrightTestMediaPlayer(final int rid, final String uri) throws Exception {
+        doStagefrightTestMediaPlayer(rid, uri, null);
+    }
+
+    private void doStagefrightTestMediaPlayer(final int rid, final String uri,
+            CrashUtils.Config config) throws Exception {
 
         String name = uri != null ? uri :
             getInstrumentation().getContext().getResources().getResourceEntryName(rid);
         Log.i(TAG, "start mediaplayer test for: " + name);
 
-        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
+        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener(config);
 
         LooperThread t = new LooperThread(new Runnable() {
             @Override
@@ -1127,16 +1180,31 @@
     }
 
     private void doStagefrightTestMediaCodec(final int rid) throws Exception {
-        doStagefrightTestMediaCodec(rid, null);
+        doStagefrightTestMediaCodec(rid, null, null);
+    }
+
+    private void doStagefrightTestMediaCodec(
+            final int rid, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaCodec(rid, null, config);
     }
 
     private void doStagefrightTestMediaCodec(final String url) throws Exception {
-        doStagefrightTestMediaCodec(-1, url);
+        doStagefrightTestMediaCodec(url, null);
+    }
+
+    private void doStagefrightTestMediaCodec(
+            final String url, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaCodec(-1, url, config);
     }
 
     private void doStagefrightTestMediaCodec(final int rid, final String url) throws Exception {
+        doStagefrightTestMediaCodec(rid, url, null);
+    }
 
-        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
+    private void doStagefrightTestMediaCodec(
+            final int rid, final String url, CrashUtils.Config config) throws Exception {
+
+        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener(config);
 
         LooperThread thr = new LooperThread(new Runnable() {
             @Override
@@ -1292,17 +1360,31 @@
     }
 
     private void doStagefrightTestMediaMetadataRetriever(final int rid) throws Exception {
-        doStagefrightTestMediaMetadataRetriever(rid, null);
+        doStagefrightTestMediaMetadataRetriever(rid, null, null);
+    }
+    private void doStagefrightTestMediaMetadataRetriever(
+            final int rid, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaMetadataRetriever(rid, null, config);
     }
 
     private void doStagefrightTestMediaMetadataRetriever(final String url) throws Exception {
-        doStagefrightTestMediaMetadataRetriever(-1, url);
+        doStagefrightTestMediaMetadataRetriever(url, null);
+    }
+
+    private void doStagefrightTestMediaMetadataRetriever(
+            final String url, CrashUtils.Config config) throws Exception {
+        doStagefrightTestMediaMetadataRetriever(-1, url, config);
     }
 
     private void doStagefrightTestMediaMetadataRetriever(
             final int rid, final String url) throws Exception {
+        doStagefrightTestMediaMetadataRetriever(rid, url, null);
+    }
 
-        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
+    private void doStagefrightTestMediaMetadataRetriever(
+            final int rid, final String url, CrashUtils.Config config) throws Exception {
+
+        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener(config);
 
         LooperThread thr = new LooperThread(new Runnable() {
             @Override
@@ -1375,11 +1457,13 @@
     }
 
     public void testBug36816007() throws Exception {
-        doStagefrightTestRawBlob(R.raw.bug_36816007, "video/avc", 320, 240);
+        doStagefrightTestRawBlob(R.raw.bug_36816007, "video/avc", 320, 240,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     public void testBug36895511() throws Exception {
-        doStagefrightTestRawBlob(R.raw.bug_36895511, "video/hevc", 320, 240);
+        doStagefrightTestRawBlob(R.raw.bug_36895511, "video/hevc", 320, 240,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     public void testBug64836894() throws Exception {
@@ -1403,7 +1487,8 @@
 
     @SecurityTest
     public void testBug_70897394() throws Exception {
-        doStagefrightTestRawBlob(R.raw.bug_70897394_avc, "video/avc", 320, 240);
+        doStagefrightTestRawBlob(R.raw.bug_70897394_avc, "video/avc", 320, 240,
+                new CrashUtils.Config().checkMinAddress(false));
     }
 
     private int[] getFrameSizes(int rid) throws IOException {
@@ -1443,9 +1528,15 @@
         }, 5000);
     }
 
-    private void doStagefrightTestRawBlob(int rid, String mime, int initWidth, int initHeight) throws Exception {
+    private void doStagefrightTestRawBlob(
+            int rid, String mime, int initWidth, int initHeight) throws Exception {
+        doStagefrightTestRawBlob(rid, mime, initWidth, initHeight, new CrashUtils.Config());
+    }
 
-        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
+    private void doStagefrightTestRawBlob(int rid, String mime, int initWidth, int initHeight,
+            CrashUtils.Config config) throws Exception {
+
+        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener(config);
         final Context context = getInstrumentation().getContext();
         final Resources resources =  context.getResources();
 
@@ -1558,9 +1649,14 @@
     }
 
     private void doStagefrightTestRawBlob(int rid, String mime, int initWidth, int initHeight,
-        int frameSizes[]) throws Exception {
+            int frameSizes[]) throws Exception {
+        doStagefrightTestRawBlob(rid, mime, initWidth, initHeight, frameSizes, null);
+    }
 
-        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener();
+    private void doStagefrightTestRawBlob(int rid, String mime, int initWidth, int initHeight,
+            int frameSizes[], CrashUtils.Config config) throws Exception {
+
+        final MediaPlayerCrashListener mpcl = new MediaPlayerCrashListener(config);
         final Context context = getInstrumentation().getContext();
         final Resources resources =  context.getResources();
 
@@ -1694,11 +1790,16 @@
     }
 
     private void doStagefrightTestMediaPlayerANR(final int rid, final String uri) throws Exception {
+        doStagefrightTestMediaPlayerANR(rid, uri, null);
+    }
+
+    private void doStagefrightTestMediaPlayerANR(final int rid, final String uri,
+            CrashUtils.Config config) throws Exception {
         String name = uri != null ? uri :
             getInstrumentation().getContext().getResources().getResourceEntryName(rid);
         Log.i(TAG, "start mediaplayerANR test for: " + name);
 
-        final MediaPlayerCrashListener mpl = new MediaPlayerCrashListener();
+        final MediaPlayerCrashListener mpl = new MediaPlayerCrashListener(config);
 
         LooperThread t = new LooperThread(new Runnable() {
             @Override
diff --git a/tests/tests/slice/src/android/slice/cts/SliceProviderTest.java b/tests/tests/slice/src/android/slice/cts/SliceProviderTest.java
deleted file mode 100644
index 2a2e8e4..0000000
--- a/tests/tests/slice/src/android/slice/cts/SliceProviderTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2019 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.slice.cts;
-
-import android.app.slice.Slice;
-import android.app.slice.SliceSpec;
-import android.content.ContentResolver;
-import android.net.Uri;
-import android.os.Bundle;
-
-import androidx.test.rule.ActivityTestRule;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.google.android.collect.Lists;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class SliceProviderTest {
-
-    private static final String VALID_AUTHORITY = "android.slice.cts";
-    private static final String SUSPICIOUS_AUTHORITY = "com.suspicious.www";
-    private static final String ACTION_BLUETOOTH = "/action/bluetooth";
-    private static final String VALID_BASE_URI_STRING = "content://" + VALID_AUTHORITY;
-    private static final String VALID_ACTION_URI_STRING =
-            "content://" + VALID_AUTHORITY + ACTION_BLUETOOTH;
-    private static final String SHADY_ACTION_URI_STRING =
-            "content://" + SUSPICIOUS_AUTHORITY + ACTION_BLUETOOTH;
-
-    @Rule
-    public ActivityTestRule<Launcher> mLauncherActivityTestRule = new ActivityTestRule<>(Launcher.class);
-
-    private Uri validBaseUri = Uri.parse(VALID_BASE_URI_STRING);
-    private Uri validActionUri = Uri.parse(VALID_ACTION_URI_STRING);
-    private Uri shadyActionUri = Uri.parse(SHADY_ACTION_URI_STRING);
-
-    private ContentResolver mContentResolver;
-
-    @Before
-    public void setUp() {
-        mContentResolver = mLauncherActivityTestRule.getActivity().getContentResolver();
-    }
-
-    @Test
-    public void testCallSliceUri_ValidAuthority() {
-        doQuery(validActionUri);
-    }
-
-    @Test(expected = SecurityException.class)
-    public void testCallSliceUri_ShadyAuthority() {
-        doQuery(shadyActionUri);
-    }
-
-    private Slice doQuery(Uri actionUri) {
-        Bundle extras = new Bundle();
-        extras.putParcelable("slice_uri", actionUri);
-        extras.putParcelableArrayList("supported_specs", Lists.newArrayList(
-                    new SliceSpec("androidx.slice.LIST", 1),
-                    new SliceSpec("androidx.app.slice.BASIC", 1),
-                    new SliceSpec("androidx.slice.BASIC", 1),
-                    new SliceSpec("androidx.app.slice.LIST", 1)
-            ));
-        Bundle result = mContentResolver.call(
-                validBaseUri,
-                SliceProvider.METHOD_SLICE,
-                null,
-                extras
-        );
-        return result.getParcelable(SliceProvider.EXTRA_SLICE);
-    }
-
-}
diff --git a/tests/tests/systemui/Android.mk b/tests/tests/systemui/Android.mk
index 5b519b2..68f2dd2 100644
--- a/tests/tests/systemui/Android.mk
+++ b/tests/tests/systemui/Android.mk
@@ -29,7 +29,8 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     ctstestrunner-axt \
     androidx.test.rules \
-    ub-uiautomator
+    ub-uiautomator \
+    compatibility-device-util
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
index 831c4de..f603c5f 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
@@ -40,6 +40,8 @@
 import org.junit.rules.TestName;
 import org.junit.runner.RunWith;
 
+import com.android.compatibility.common.util.CddTest;
+
 /**
  * Test for light status bar.
  *
@@ -57,7 +59,6 @@
      * margin to accommodate for that when comparing colors.
      */
     private static final int COLOR_COMPONENT_ERROR_MARGIN = 20;
-
     private final String NOTIFICATION_TAG = "TEST_TAG";
     private final String NOTIFICATION_CHANNEL_ID = "test_channel";
     private final String NOTIFICATION_GROUP_KEY = "test_group";
@@ -69,6 +70,7 @@
     @Rule
     public TestName mTestName = new TestName();
 
+    @CddTest(requirement="3.8.6/C-2-2")
     @Test
     @AppModeFull // Instant apps cannot create notifications
     public void testLightStatusBarIcons() throws Throwable {
diff --git a/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java b/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
index 6314ec5..27c388a 100644
--- a/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
+++ b/tests/tests/tv/src/android/media/tv/cts/TvContractTest.java
@@ -105,8 +105,7 @@
     private static final String WHITE_SPACES = " \r \n \t \f ";
 
     private static final String PARAM_CANONICAL_GENRE = "canonical_genre";
-    private static final String[] NON_EXISTING_COLUMN_NAMES =
-            {"non_existing_column", "another non-existing column --"};
+    private static final String NON_EXISTING_COLUMN_NAME = "non_existing_column";
 
     private String mInputId;
     private ContentResolver mContentResolver;
@@ -337,20 +336,15 @@
     private void verifyNonExistingColumn(Uri channelUri, long channelId) {
         String[] projection = {
                 Channels._ID,
-                NON_EXISTING_COLUMN_NAMES[0],
-                NON_EXISTING_COLUMN_NAMES[1]
+                NON_EXISTING_COLUMN_NAME
         };
         try (Cursor cursor = mContentResolver.query(channelUri, projection, null, null, null)) {
             assertNotNull(cursor);
             assertEquals(cursor.getCount(), 1);
             assertTrue(cursor.moveToNext());
             assertEquals(channelId, cursor.getLong(0));
-            assertEquals(NON_EXISTING_COLUMN_NAMES[0], cursor.getColumnName(1));
             assertNull(cursor.getString(1));
             assertEquals(0, cursor.getInt(1));
-            assertEquals(NON_EXISTING_COLUMN_NAMES[1], cursor.getColumnName(2));
-            assertNull(cursor.getString(2));
-            assertEquals(0, cursor.getInt(2));
         }
     }
 
@@ -539,8 +533,7 @@
             return;
         }
         ContentValues values = createDummyChannelValues(mInputId, false);
-        values.put(NON_EXISTING_COLUMN_NAMES[0], "dummy value 0");
-        values.put(NON_EXISTING_COLUMN_NAMES[1], "dummy value 1");
+        values.put(NON_EXISTING_COLUMN_NAME, "dummy value");
         Uri rowUri = mContentResolver.insert(mChannelsUri, values);
         long channelId = ContentUris.parseId(rowUri);
         Uri channelUri = TvContract.buildChannelUri(channelId);
diff --git a/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java b/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
index f1838e2..641d6c9 100644
--- a/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
+++ b/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
@@ -212,9 +212,9 @@
             display.getRealSize(size);
             display.getMetrics(metrics);
 
-            View decorView = getWindow().getDecorView();
-            Rect boundsToCheck = new Rect(0, 0, decorView.getWidth(), decorView.getHeight());
-            int[] topLeft = decorView.getLocationOnScreen();
+            View testAreaView = findViewById(android.R.id.content);
+            Rect boundsToCheck = new Rect(0, 0, testAreaView.getWidth(), testAreaView.getHeight());
+            int[] topLeft = testAreaView.getLocationOnScreen();
             boundsToCheck.offset(topLeft[0], topLeft[1]);
 
             if (boundsToCheck.width() < 90 || boundsToCheck.height() < 90) {