Merge "testLightNavigationBar case fail in mdpi device" into oreo-mr1-cts-dev
diff --git a/apps/CameraITS/tests/scene1/scene1_0.67_scaled.pdf b/apps/CameraITS/tests/scene1/scene1_0.67_scaled.pdf
new file mode 100644
index 0000000..3103cd8
--- /dev/null
+++ b/apps/CameraITS/tests/scene1/scene1_0.67_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene2/scene2_0.67_scaled.pdf b/apps/CameraITS/tests/scene2/scene2_0.67_scaled.pdf
new file mode 100644
index 0000000..7b64817
--- /dev/null
+++ b/apps/CameraITS/tests/scene2/scene2_0.67_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene3/scene3_0.67_scaled.pdf b/apps/CameraITS/tests/scene3/scene3_0.67_scaled.pdf
new file mode 100644
index 0000000..a3e18e2
--- /dev/null
+++ b/apps/CameraITS/tests/scene3/scene3_0.67_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene4/scene4_0.67_scaled.pdf b/apps/CameraITS/tests/scene4/scene4_0.67_scaled.pdf
new file mode 100644
index 0000000..7fb1e42
--- /dev/null
+++ b/apps/CameraITS/tests/scene4/scene4_0.67_scaled.pdf
Binary files differ
diff --git a/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py b/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
index f7f2003..95fc543 100644
--- a/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
+++ b/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
@@ -45,7 +45,7 @@
     THRES_LS_CN = 0.6    # len shading allowance for corner
     THRES_LS_HIGH = 0.2  # max allowed percentage for a patch to be brighter
                          # than center
-    THRES_UFMT = 0.1     # uniformity allowance
+    THRES_UFMT = 0.2     # uniformity allowance
     # Drawing color
     RED = (1, 0, 0)   # blocks failed the test
     GREEN = (0, 0.7, 0.3)   # blocks passed the test
diff --git a/apps/CameraITS/tools/load_scene.py b/apps/CameraITS/tools/load_scene.py
index 4e245f4..6255137 100644
--- a/apps/CameraITS/tools/load_scene.py
+++ b/apps/CameraITS/tools/load_scene.py
@@ -17,17 +17,20 @@
 import subprocess
 import sys
 import time
-
+import numpy as np
 
 def main():
     """Load charts on device and display."""
-    camera_id = -1
     scene = None
     for s in sys.argv[1:]:
         if s[:6] == 'scene=' and len(s) > 6:
             scene = s[6:]
         elif s[:7] == 'screen=' and len(s) > 7:
             screen_id = s[7:]
+        elif s[:5] == 'dist=' and len(s) > 5:
+            chart_distance = float(re.sub('cm', '', s[5:]))
+        elif s[:4] == 'fov=' and len(s) > 4:
+            camera_fov = float(s[4:])
 
     cmd = ('adb -s %s shell am force-stop com.google.android.apps.docs' %
            screen_id)
@@ -43,8 +46,13 @@
 
     remote_scene_file = '/sdcard/Download/%s.pdf' % scene
     local_scene_file = os.path.join(os.environ['CAMERA_ITS_TOP'], 'tests',
-                                    scene, scene+'.pdf')
-    print 'Loading %s on %s' % (remote_scene_file, screen_id)
+                                    scene)
+    if np.isclose(chart_distance, 22, rtol=0.1) and camera_fov < 90:
+        local_scene_file = os.path.join(local_scene_file,
+                                        scene+'_0.67_scaled.pdf')
+    else:
+        local_scene_file = os.path.join(local_scene_file, scene+'.pdf')
+    print 'Loading %s on %s' % (local_scene_file, screen_id)
     cmd = 'adb -s %s push %s /mnt%s' % (screen_id, local_scene_file,
                                         remote_scene_file)
     subprocess.Popen(cmd.split())
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index 47f7296..57e348a 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -13,8 +13,10 @@
 # limitations under the License.
 
 import copy
+import math
 import os
 import os.path
+import re
 import tempfile
 import subprocess
 import time
@@ -25,10 +27,26 @@
 from its.device import ItsSession
 
 CHART_DELAY = 1  # seconds
+CHART_DISTANCE = 30.0  # cm
 FACING_EXTERNAL = 2
 NUM_TRYS = 2
 SKIP_RET_CODE = 101  # note this must be same as tests/scene*/test_*
 
+def calc_camera_fov():
+    """Determine the camera field of view from internal params."""
+    with ItsSession() as cam:
+        props = cam.get_camera_properties()
+    try:
+        focal_l = props['android.lens.info.availableFocalLengths'][0]
+        sensor_size = props['android.sensor.info.physicalSize']
+        diag = math.sqrt(sensor_size['height'] ** 2 +
+                         sensor_size['width'] ** 2)
+        fov = str(round(2 * math.degrees(math.atan(diag / (2 * focal_l))), 2))
+    except ValueError:
+        fov = str(0)
+    print 'Calculated FoV: %s' % fov
+    return fov
+
 
 def evaluate_socket_failure(err_file_path):
     """Determine if test fails due to socket FAIL."""
@@ -79,6 +97,7 @@
         tmp_dir: location of temp directory for output files
         skip_scene_validation: force skip scene validation. Used when test scene
                  is setup up front and don't require tester validation.
+        dist:    [Experimental] chart distance in cm.
     """
 
     # Not yet mandated tests
@@ -139,6 +158,8 @@
     rot_rig_id = None
     tmp_dir = None
     skip_scene_validation = False
+    chart_distance = CHART_DISTANCE
+
     for s in sys.argv[1:]:
         if s[:7] == "camera=" and len(s) > 7:
             camera_ids = s[7:].split(',')
@@ -155,6 +176,8 @@
             tmp_dir = s[8:]
         elif s == 'skip_scene_validation':
             skip_scene_validation = True
+        elif s[:5] == 'dist=' and len(s) > 5:
+            chart_distance = float(re.sub('cm', '', s[5:]))
 
     auto_scene_switch = chart_host_id is not None
     merge_result_switch = result_device_id is not None
@@ -183,7 +206,7 @@
                     break
 
         if not valid_scenes:
-            print "Unknown scene specifiied:", s
+            print 'Unknown scene specified:', s
             assert False
         scenes = temp_scenes
 
@@ -245,6 +268,7 @@
             assert wake_code == 0
 
     for camera_id in camera_ids:
+        camera_fov = calc_camera_fov()
         # Loop capturing images until user confirm test scene is correct
         camera_id_arg = "camera=" + camera_id
         print "Preparing to run ITS on camera", camera_id
@@ -280,9 +304,11 @@
                     if (not merge_result_switch or
                             (merge_result_switch and camera_ids[0] == '0')):
                         scene_arg = 'scene=' + scene
+                        chart_dist_arg = 'dist= ' + str(chart_distance)
+                        fov_arg = 'fov=' + camera_fov
                         cmd = ['python',
                                os.path.join(os.getcwd(), 'tools/load_scene.py'),
-                               scene_arg, screen_id_arg]
+                               scene_arg, chart_dist_arg, fov_arg, screen_id_arg]
                     else:
                         time.sleep(CHART_DELAY)
                 else:
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 2b40fb5..d895ca7 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
       android:versionCode="5"
-      android:versionName="8.1_r7">
+      android:versionName="8.1_r8">
 
     <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27"/>
 
@@ -268,6 +268,8 @@
             <meta-data
                 android:name="test_parent"
                 android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data android:name="test_excluded_features"
+                android:value="android.hardware.type.watch" />
         </activity>
 
         <!--
@@ -291,6 +293,8 @@
             <meta-data
                 android:name="test_parent"
                 android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data android:name="test_excluded_features"
+                android:value="android.hardware.type.watch" />
         </activity>
 
         <!--
@@ -314,6 +318,8 @@
             <meta-data
                 android:name="test_parent"
                 android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data android:name="test_excluded_features"
+                android:value="android.hardware.type.watch" />
         </activity>
 
         <!--
@@ -337,6 +343,8 @@
             <meta-data
                 android:name="test_parent"
                 android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+            <meta-data android:name="test_excluded_features"
+                android:value="android.hardware.type.watch" />
         </activity>
 
         <!--
@@ -2671,7 +2679,7 @@
             </intent-filter>
             <meta-data android:name="test_category" android:value="@string/test_category_jobscheduler" />
             <meta-data android:name="test_excluded_features"
-                    android:value="android.hardware.type.television:android.software.leanback" />
+                    android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.automotive" />
         </activity>
 
         <activity android:name=".jobscheduler.ConnectivityConstraintTestActivity" android:label="@string/js_connectivity_test">
diff --git a/apps/CtsVerifier/res/layout/intent_driven_test.xml b/apps/CtsVerifier/res/layout/intent_driven_test.xml
index 794a6d6..4386392 100644
--- a/apps/CtsVerifier/res/layout/intent_driven_test.xml
+++ b/apps/CtsVerifier/res/layout/intent_driven_test.xml
@@ -9,7 +9,7 @@
     <ScrollView
         android:layout_width="match_parent"
         android:layout_height="0dp"
-        android:layout_weight="1">
+        android:layout_weight="3">
         <TextView android:id="@+id/info"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
@@ -18,15 +18,16 @@
             android:text="@string/dc_start_alarm_test_info"/>
     </ScrollView>
 
-    <LinearLayout android:id="@+id/buttons"
-        android:orientation="horizontal"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"/>
-
-    <LinearLayout
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+        android:layout_height="0dp"
+        android:layout_weight="2">
 
-        <include layout="@layout/pass_fail_buttons"/>
-    </LinearLayout>
+        <LinearLayout
+            android:id="@+id/buttons"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"/>
+    </ScrollView>
+    <include layout="@layout/pass_fail_buttons"/>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/provisioning_byod.xml b/apps/CtsVerifier/res/layout/provisioning_byod.xml
index 227d8d8..444bead 100644
--- a/apps/CtsVerifier/res/layout/provisioning_byod.xml
+++ b/apps/CtsVerifier/res/layout/provisioning_byod.xml
@@ -15,7 +15,7 @@
     android:orientation="vertical">
     <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="0dp"
         android:layout_weight="2">
         <TextView
             android:id="@+id/test_instructions"
@@ -26,12 +26,12 @@
     </ScrollView>
     <Button
         android:id="@+id/prepare_test_button"
-        android:layout_width="204dip"
+        android:layout_width="wrap_content"
         android:layout_height="wrap_content"/>
     <ListView
         android:id="@+id/android:list"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="0dp"
         android:layout_weight="3"/>
     <include layout="@layout/pass_fail_buttons"/>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/voicemail_broadcast.xml b/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
index 163da23..0cf1d39 100644
--- a/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
+++ b/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
@@ -58,6 +58,12 @@
       android:layout_height="wrap_content"
       android:text="@string/voicemail_set_default_dialer_button"/>
 
+    <Button
+      android:id="@+id/call_settings_check_not_applicable"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/visual_voicemail_service_remove_sim_not_applicable"/>
+
     <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml b/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml
index 4d7803b..cf1cc7c 100644
--- a/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml
+++ b/apps/CtsVerifier/res/layout/voicemail_hide_in_call_settings.xml
@@ -68,23 +68,25 @@
         android:layout_height="wrap_content"
         android:text="@string/open_call_settings"/>
 
-    <LinearLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/js_padding"
-        android:layout_marginBottom="@dimen/js_padding">
-        <Button
-            android:id="@+id/settings_hidden"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/voicemail_hidden"/>
-        <Button
-            android:id="@+id/settings_not_hidden"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/voicemail_not_hidden"
-        />
-    </LinearLayout>
+      <LinearLayout
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_marginTop="@dimen/js_padding"
+          android:layout_marginBottom="@dimen/js_padding"
+          android:orientation="vertical">
+
+          <Button
+              android:id="@+id/settings_hidden"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:text="@string/voicemail_hidden"/>
+
+          <Button
+              android:id="@+id/settings_not_hidden"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:text="@string/voicemail_not_hidden"/>
+      </LinearLayout>
 
     <LinearLayout
         android:layout_width="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml b/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml
index 9ccd909..47cd2f6 100644
--- a/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml
+++ b/apps/CtsVerifier/res/layout/voicemail_hide_ringtone_settings.xml
@@ -45,23 +45,25 @@
       android:layout_height="wrap_content"
       android:text="@string/open_voicemail_settings"/>
 
-    <LinearLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/js_padding"
-        android:layout_marginBottom="@dimen/js_padding">
-        <Button
-            android:id="@+id/settings_hidden"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/ringtone_hidden"/>
-        <Button
-            android:id="@+id/settings_not_hidden"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/ringtone_not_hidden"
-        />
-    </LinearLayout>
+      <LinearLayout
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_marginTop="@dimen/js_padding"
+          android:layout_marginBottom="@dimen/js_padding"
+          android:orientation="vertical">
+
+          <Button
+              android:id="@+id/settings_hidden"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:text="@string/ringtone_hidden"/>
+
+          <Button
+              android:id="@+id/settings_not_hidden"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:text="@string/ringtone_not_hidden"/>
+      </LinearLayout>
 
     <LinearLayout
         android:layout_width="wrap_content"
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 48e03b9..8286f1b 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1896,7 +1896,8 @@
         This test verifies that if a work profile is locked with a separate password, Recents views
         for applications in the work profile are redacted.\n
         Some devices may not lock as soon as the screen is turned off by default. On such devices,
-        use the button below when requested to lock the work profile.
+        use the button below when requested to lock the work profile. Please skip these tests if
+        "Recents" is absent.
     </string>
     <string name="provisioning_byod_recents_lock_now">Lock now</string>
 
@@ -2565,7 +2566,9 @@
         Please do the following:\n
         1) Open and fully expand Quick Settings.\n
         2) Verify that at the bottom of Quick Settings, you are not told the device is managed.\n
-        3) Close Quick Settings.
+        3) Close Quick Settings.\n
+        \n
+        If this device does not have quick settings, please skip this test and mark it passing
     </string>
     <string name="enterprise_privacy_keyguard_negative">Keyguard disclosure</string>
     <string name="enterprise_privacy_keyguard_negative_info">
@@ -3303,7 +3306,7 @@
         10) Tap the \"Learn more\" link.\n
         11) Verify that a screen informing you what your managing organization can do is shown.\n
         \n
-        Use the Back button to return to this page.
+        Use the Back button to return to this page. If this device does not have quick settings, please skip this test and mark it passing.
     </string>
     <string name="enterprise_privacy_keyguard">Keyguard disclosure</string>
     <string name="enterprise_privacy_keyguard_info">
@@ -3351,6 +3354,8 @@
         9) Close the dialog.\n
         10) Tap the right button below to disable network logging.\n
         11) Verify that the notification disappeared.\n
+        \n
+        If this device does not have quick settings, please skip this test and mark it passing.
     </string>
     <string name="device_owner_enable_network_logging_button">Enable Network Logging</string>
     <string name="device_owner_disable_network_logging_button">Disable Network Logging</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java
index 2661d42..95c99b7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java
@@ -31,10 +31,13 @@
 
 import java.util.List;
 
+import com.android.compatibility.common.util.CddTest;
+
 
 /**
  * Test that checks that the {@link CompanionDeviceManager} API is functional
  */
+@CddTest(requirement="3.16/C-1-2,C-1-3,H-1-1")
 public class CompanionDeviceTestActivity extends PassFailButtons.Activity {
 
     private static final String LOG_TAG = "CompanionDeviceTestActi";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
index 269f4fd..7f3bfc7 100755
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
@@ -32,6 +32,8 @@
 
 import com.android.cts.verifier.R;
 
+import com.android.compatibility.common.util.CddTest;
+
 import org.json.JSONException;
 import org.json.JSONObject;
 
@@ -45,6 +47,7 @@
 
 import static junit.framework.Assert.assertNotNull;
 
+@CddTest(requirement="3.8.3.2/C-1-1,C-1-2,C-2-1")
 public class NotificationListenerVerifierActivity extends InteractiveVerifierActivity
         implements Runnable {
     private static final String TAG = "NoListenerVerifier";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
index 3cf34fa..b54637b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
@@ -29,6 +29,8 @@
 import com.android.cts.verifier.R;
 import com.android.cts.verifier.voicemail.VoicemailBroadcastReceiver.ReceivedListener;
 
+import android.view.View.OnClickListener;
+import android.widget.Button;
 /**
  * This test ask the tester to set the CTS verifier as the default dialer and leave a voicemail. The
  * test will pass if the verifier is able to receive a broadcast for the incoming voicemail. This
@@ -38,7 +40,9 @@
 public class VoicemailBroadcastActivity extends PassFailButtons.Activity {
 
     private ImageView mLeaveVoicemailImage;
+    private ImageView mRestoreDefaultDialerImage;
     private TextView mLeaveVoicemailText;
+    private Button mNotApplicableButton;
 
     private DefaultDialerChanger mDefaultDialerChanger;
 
@@ -53,10 +57,23 @@
         getPassButton().setEnabled(false);
 
         mLeaveVoicemailImage = (ImageView) findViewById(R.id.leave_voicemail_image);
+        mRestoreDefaultDialerImage = (ImageView) findViewById(R.id.restore_default_dialer_image);
         mLeaveVoicemailText = (TextView) findViewById(R.id.leave_voicemail_text);
 
         mDefaultDialerChanger = new DefaultDialerChanger(this);
 
+        mNotApplicableButton = findViewById(R.id.call_settings_check_not_applicable);
+        mNotApplicableButton.setOnClickListener(
+                new OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        getPassButton().setEnabled(true);
+                        mLeaveVoicemailImage.setImageDrawable(getDrawable(R.drawable.fs_warning));
+                        mRestoreDefaultDialerImage.setImageDrawable(getDrawable(R.drawable.fs_warning));
+                    }
+                }
+        );
+
         VoicemailBroadcastReceiver.setListener(new ReceivedListener() {
             @Override
             public void onReceived() {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
index 9c60737..2f89ec6 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
@@ -31,6 +31,8 @@
 import android.widget.TextView;
 
 
+import com.android.compatibility.common.util.CddTest;
+
 import com.android.cts.verifier.PassFailButtons;
 import com.android.cts.verifier.R;
 
@@ -41,6 +43,7 @@
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
+@CddTest(requirement="7.9.1/H-2-1")
 public class VrListenerVerifierActivity extends PassFailButtons.Activity {
 
     private static final String TAG = "VrListenerActivity";
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
index 5ef3a93..5b3339b 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
@@ -139,8 +139,11 @@
         int numTests = countTestCases();
         long startTime = System.currentTimeMillis();
         listener.testRunStarted(getClass().getName(), numTests);
-        super.run(new HostTestListener(listener));
-        listener.testRunEnded(System.currentTimeMillis() - startTime, Collections.emptyMap());
+        try {
+            super.run(new HostTestListener(listener));
+        } finally {
+            listener.testRunEnded(System.currentTimeMillis() - startTime, Collections.emptyMap());
+        }
     }
 
     /**
diff --git a/hostsidetests/appsecurity/Android.mk b/hostsidetests/appsecurity/Android.mk
index 0ef5da3..2a8c819 100644
--- a/hostsidetests/appsecurity/Android.mk
+++ b/hostsidetests/appsecurity/Android.mk
@@ -32,7 +32,8 @@
 
 LOCAL_REQUIRED_MODULES := \
 	CtsCorruptApkTests_b71360999 \
-	CtsCorruptApkTests_b71361168
+	CtsCorruptApkTests_b71361168 \
+	CtsCorruptApkTests_b79488511
 
 include $(BUILD_CTS_HOST_JAVA_LIBRARY)
 
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
index bcf67b0..933b395 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
@@ -34,7 +34,8 @@
  */
 public class CorruptApkTests extends DeviceTestCase implements IBuildReceiver {
     private final String B71360999_PKG = "com.android.appsecurity.b71360999";
-    private final String B71361168_PKG = "com.example.helloworld";
+    private final String B71361168_PKG = "com.android.appsecurity.b71361168";
+    private final String B79488511_PKG = "com.android.appsecurity.b79488511";
 
     private IBuildInfo mBuildInfo;
 
@@ -49,6 +50,7 @@
         super.setUp();
         uninstall(B71360999_PKG);
         uninstall(B71361168_PKG);
+        uninstall(B79488511_PKG);
     }
 
     @After
@@ -57,6 +59,7 @@
         super.tearDown();
         uninstall(B71360999_PKG);
         uninstall(B71361168_PKG);
+        uninstall(B79488511_PKG);
     }
 
     /** Uninstall the apk if the test failed previously. */
@@ -72,7 +75,7 @@
      */
     public void testFailToInstallCorruptStringPoolHeader_b71360999() throws Exception {
         final String APK_PATH = "CtsCorruptApkTests_b71360999.apk";
-        assertFailsToInstall(APK_PATH, B71360999_PKG);
+        assertInstallNoFatalError(APK_PATH, B71360999_PKG);
     }
 
     /**
@@ -80,24 +83,34 @@
      */
     public void testFailToInstallCorruptStringPoolHeader_b71361168() throws Exception {
         final String APK_PATH = "CtsCorruptApkTests_b71361168.apk";
-        assertFailsToInstall(APK_PATH, B71361168_PKG);
+        assertInstallNoFatalError(APK_PATH, B71361168_PKG);
     }
 
     /**
-     * Assert that the app fails to install and the reason for failing is not caused by a buffer
-     * overflow nor a out of bounds read.
+     * Tests that apks described in b/79488511 do not install successfully.
+     */
+    public void testFailToInstallCorruptStringPoolHeader_b79488511() throws Exception {
+        final String APK_PATH = "CtsCorruptApkTests_b79488511.apk";
+        assertInstallNoFatalError(APK_PATH, B79488511_PKG);
+    }
+
+    /**
+     * Assert that installing the app does not cause a native error caused by a buffer overflow
+     * or an out-of-bounds read.
      **/
-    private void assertFailsToInstall(String filename, String pkg) throws Exception {
+    private void assertInstallNoFatalError(String filename, String pkg) throws Exception {
         ITestDevice device = getDevice();
         device.clearLogcat();
-
         final String result = device.installPackage(
                 new CompatibilityBuildHelper(mBuildInfo).getTestFile(filename),
                 true /*reinstall*/);
 
-        assertNotNull(result);
-        assertFalse(result.isEmpty());
-        assertFalse(device.getInstalledPackageNames().contains(pkg));
+        // Starting from P, corrupt apks should always fail to install
+        if (device.getApiLevel() >= 28) {
+            assertNotNull(result);
+            assertFalse(result.isEmpty());
+            assertFalse(device.getInstalledPackageNames().contains(pkg));
+        }
 
         // This catches if the device fails to install the app because a segmentation fault
         // or out of bounds read created by the bug occurs
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
index 2174fa0..ddec487 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
@@ -175,7 +175,7 @@
                     doTest = false;
                 }
                 getDevice().waitForDeviceNotAvailable(SHUTDOWN_TIME_MS);
-                getDevice().waitForDeviceOnline();
+                getDevice().waitForDeviceOnline(120000);
             } else {
                 getDevice().rebootUntilOnline();
             }
diff --git a/hostsidetests/appsecurity/test-apps/CorruptApkTests/Android.mk b/hostsidetests/appsecurity/test-apps/CorruptApkTests/Android.mk
index feaaa03..9fd8b98 100644
--- a/hostsidetests/appsecurity/test-apps/CorruptApkTests/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/CorruptApkTests/Android.mk
@@ -28,4 +28,12 @@
 LOCAL_SRC_FILES := b71361168.apk
 LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
 LOCAL_CERTIFICATE := PRESIGNED
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CtsCorruptApkTests_b79488511
+LOCAL_MODULE_CLASS := APPS
+LOCAL_SRC_FILES := b79488511.apk
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_CERTIFICATE := PRESIGNED
 include $(BUILD_PREBUILT)
\ No newline at end of file
diff --git a/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk
index ef1e2bf..dc00656 100644
--- a/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk
+++ b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b71361168.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/CorruptApkTests/b79488511.apk b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b79488511.apk
new file mode 100644
index 0000000..22af499
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/CorruptApkTests/b79488511.apk
Binary files differ
diff --git a/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java b/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java
index 9b69057..8470bbb 100644
--- a/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java
+++ b/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java
@@ -21,6 +21,7 @@
 import static com.android.cts.storageapp.Utils.CACHE_ALL;
 import static com.android.cts.storageapp.Utils.CODE_ALL;
 import static com.android.cts.storageapp.Utils.DATA_ALL;
+import static com.android.cts.storageapp.Utils.KB_IN_BYTES;
 import static com.android.cts.storageapp.Utils.MB_IN_BYTES;
 import static com.android.cts.storageapp.Utils.PKG_A;
 import static com.android.cts.storageapp.Utils.PKG_B;
@@ -140,7 +141,7 @@
         final StorageStats as = stats.queryStatsForUid(UUID_DEFAULT, a.uid);
         final StorageStats bs = stats.queryStatsForUid(UUID_DEFAULT, b.uid);
 
-        assertMostlyEquals(DATA_ALL * 2, as.getDataBytes());
+        assertMostlyEquals(DATA_ALL * 2, as.getDataBytes(), 600 * KB_IN_BYTES);
         assertMostlyEquals(CACHE_ALL * 2, as.getCacheBytes());
 
         assertMostlyEquals(DATA_ALL, bs.getDataBytes());
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
index 6c139aa..321f3d6 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
@@ -21,6 +21,8 @@
 import android.test.AndroidTestCase;
 import android.util.Log;
 
+import com.android.compatibility.common.util.CddTest;
+
 import java.lang.Math;
 
 public class VrTemperatureTest extends BaseDeviceOwnerTest {
@@ -78,6 +80,7 @@
     /**
      * Tests that temperature sensors return valid values.
      */
+    @CddTest(requirement="7.9.2/C-1-13")
     public void testVrTemperatures() throws InterruptedException, SecurityException {
         if (!supportsVrHighPerformance())
             return;
diff --git a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
index 153d552..8a82416 100644
--- a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
@@ -179,9 +179,11 @@
         startSimpleActivity();
         assertValueRange("st", "", STATE_TIME_FOREGROUND_SERVICE_INDEX, 0,
                 0); // No foreground service time before test
+        final long startTime = System.nanoTime();
         runDeviceTests(DEVICE_SIDE_TEST_PACKAGE, ".BatteryStatsProcessStateTests",
                 "testForegroundService");
-        assertValueRange("st", "", STATE_TIME_FOREGROUND_SERVICE_INDEX, (long) (2000 * 0.8), 4000);
+        assertValueRange("st", "", STATE_TIME_FOREGROUND_SERVICE_INDEX, (long) (2000 * 0.8),
+                (System.nanoTime() - startTime) / 1000000);
         batteryOffScreenOn();
     }
 
diff --git a/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java b/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
index 5d4b89e..4b4d3a5 100644
--- a/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
+++ b/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
@@ -29,7 +29,7 @@
 public class CreateUsersNoAppCrashesTest extends BaseMultiUserTest {
     private int mInitialUserId;
     private static final long LOGCAT_POLL_INTERVAL_MS = 5000;
-    private static final long BOOT_COMPLETED_TIMEOUT_MS = 120000;
+    private static final long BOOT_COMPLETED_TIMEOUT_MS = 180000;
 
     @Override
     protected void setUp() throws Exception {
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
old mode 100644
new mode 100755
index 51c2348..437a43c
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
@@ -29,10 +29,14 @@
 
     private boolean mReady;
 
+    private boolean mStarted;
+    private Bundle mExtras;
+
     @Override
     public void onReady() {
         super.onReady();
         mReady = true;
+        showSessionIfReady();
     }
 
     @Override
@@ -43,13 +47,18 @@
             stopSelf();
             return START_NOT_STICKY;
         }
-        if (mReady) {
-            Bundle extras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
-            showSession(extras, 0);
-        }
+        mExtras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
+        mStarted = true;
+        showSessionIfReady();
         return START_NOT_STICKY;
     }
 
+    private void showSessionIfReady() {
+        if (mReady && mStarted) {
+            showSession(mExtras, 0);
+        }
+    };
+
     /**
      * Starts the assistant voice interaction service, which initiates a new session that starts
      * the assistant activity.
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
index 011390a..518fb00 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
@@ -433,7 +433,7 @@
             // Go home and check the app transition
             assertNotSame(TRANSIT_WALLPAPER_OPEN, mAmWmState.getWmState().getLastTransition());
             pressHomeButton();
-            mAmWmState.computeState(mDevice, null);
+            mAmWmState.waitForHomeActivityVisible(mDevice);
             assertEquals(TRANSIT_WALLPAPER_OPEN, mAmWmState.getWmState().getLastTransition());
         }
     }
diff --git a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
index 925fa92..ca672e4 100755
--- a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
+++ b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
@@ -560,7 +560,8 @@
     protected boolean isHandheld() throws DeviceNotAvailableException {
         return !hasDeviceFeature("android.software.leanback")
                 && !hasDeviceFeature("android.hardware.type.watch")
-                && !hasDeviceFeature("android.hardware.type.embedded");
+                && !hasDeviceFeature("android.hardware.type.embedded")
+                && !hasDeviceFeature("android.hardware.type.automotive");
     }
 
     // TODO: Switch to using a feature flag, when available.
diff --git a/tests/app/src/android/app/cts/NotificationChannelTest.java b/tests/app/src/android/app/cts/NotificationChannelTest.java
index 70ec9cf..c54df84 100644
--- a/tests/app/src/android/app/cts/NotificationChannelTest.java
+++ b/tests/app/src/android/app/cts/NotificationChannelTest.java
@@ -28,6 +28,9 @@
 import android.provider.Settings;
 import android.test.AndroidTestCase;
 
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="3.8.3.1/C-1-1,C-1-4")
 public class NotificationChannelTest extends AndroidTestCase {
 
     @Override
diff --git a/tests/app/src/android/app/cts/NotificationManagerTest.java b/tests/app/src/android/app/cts/NotificationManagerTest.java
index b6077ca..4ee7eaf 100644
--- a/tests/app/src/android/app/cts/NotificationManagerTest.java
+++ b/tests/app/src/android/app/cts/NotificationManagerTest.java
@@ -36,6 +36,8 @@
 import android.test.AndroidTestCase;
 import android.util.Log;
 
+import com.android.compatibility.common.util.CddTest;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -43,6 +45,7 @@
 import java.util.Map;
 import java.util.UUID;
 
+@CddTest(requirement="3.8.3.1/C-1-3,C-1-4")
 public class NotificationManagerTest extends AndroidTestCase {
     final String TAG = NotificationManagerTest.class.getSimpleName();
     final boolean DEBUG = false;
@@ -173,6 +176,7 @@
         compareChannels(channel, mNotificationManager.getNotificationChannel(channel.getId()));
     }
 
+    @CddTest(requirement="3.8.3.1/C-1-3")
     public void testCreateChannelWithGroup() throws Exception {
         NotificationChannelGroup ncg = new NotificationChannelGroup("g", "n");
         mNotificationManager.createNotificationChannelGroup(ncg);
@@ -387,6 +391,7 @@
         checkNotificationExistence(id, false);
     }
 
+    @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
     public void testMediaStyle() throws Exception {
         mNotificationManager.cancelAll();
         final int id = 99;
@@ -438,6 +443,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
     public void testBigTextStyle() throws Exception {
         final int id = 101;
 
@@ -464,6 +470,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
     public void testBigPictureStyle() throws Exception {
         final int id = 102;
 
@@ -491,6 +498,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.3.1/C-1-3")
     public void testAutogrouping() throws Exception {
         sendNotification(1, R.drawable.black);
         sendNotification(2, R.drawable.blue);
@@ -501,6 +509,7 @@
         assertAllPostedNotificationsAutogrouped();
     }
 
+    @CddTest(requirement="3.8.3.1/C-1-3")
     public void testAutogrouping_autogroupStaysUntilAllNotificationsCanceled() throws Exception {
         sendNotification(1, R.drawable.black);
         sendNotification(2, R.drawable.blue);
diff --git a/tests/app/src/android/app/cts/NotificationTest.java b/tests/app/src/android/app/cts/NotificationTest.java
index 25c25e3..47ab3a1 100644
--- a/tests/app/src/android/app/cts/NotificationTest.java
+++ b/tests/app/src/android/app/cts/NotificationTest.java
@@ -29,8 +29,11 @@
 import android.test.AndroidTestCase;
 import android.widget.RemoteViews;
 
+import com.android.compatibility.common.util.CddTest;
+
 import org.mockito.internal.matchers.Not;
 
+@CddTest(requirement="3.8.3/H-0-1,3.8.3.1/C-1-4")
 public class NotificationTest extends AndroidTestCase {
     private static final String TEXT_RESULT_KEY = "text";
     private static final String DATA_RESULT_KEY = "data";
diff --git a/tests/app/src/android/app/cts/SystemFeaturesTest.java b/tests/app/src/android/app/cts/SystemFeaturesTest.java
index 53b1bf2..9b95c28 100644
--- a/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -42,6 +42,8 @@
 import android.telephony.TelephonyManager;
 import android.test.InstrumentationTestCase;
 
+import com.android.compatibility.common.util.CddTest;
+
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -231,6 +233,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.7/C-1-1")
     public void testLiveWallpaperFeature() {
         try {
             Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
@@ -283,6 +286,7 @@
         }
     }
 
+    @CddTest(requirement="7.1.3/C-0-1")
     public void testScreenFeatures() {
         assertTrue(mPackageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
                 || mPackageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT));
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
index ee38a29..e74e75a 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
@@ -15,8 +15,6 @@
  */
 package android.autofillservice.cts;
 
-import static android.autofillservice.cts.Helper.runShellCommand;
-
 import static com.google.common.truth.Truth.assertThat;
 
 import android.app.Activity;
@@ -64,16 +62,10 @@
      */
     @Test
     public final void testTapLink_changeOrientationThenTapBack() throws Exception {
-
-        // If the screen is too small and the devices shows an IME,
-        // it might not have space for all UI elements after the
-        // device is rotated to landscape.
-        sUiBot.assumeMinimumResolution(500);
+        sUiBot.setScreenResolution();
 
         sUiBot.setScreenOrientation(UiBot.PORTRAIT);
         try {
-            runShellCommand("wm size 1080x1920");
-            runShellCommand("wm density 420");
             saveUiRestoredAfterTappingLinkTest(
                     PostSaveLinkTappedAction.ROTATE_THEN_TAP_BACK_BUTTON);
         } finally {
@@ -81,8 +73,7 @@
             try {
                 cleanUpAfterScreenOrientationIsBackToPortrait();
             } finally {
-                runShellCommand("wm density reset");
-                runShellCommand("wm size reset");
+                sUiBot.resetScreenResolution();
             }
         }
     }
diff --git a/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java b/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
index fa233dd..5317d89 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
@@ -21,7 +21,9 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.util.SparseArray;
+import android.view.autofill.AutofillManager;
 import android.view.autofill.AutofillValue;
 import android.webkit.WebView;
 
@@ -33,10 +35,12 @@
  */
 public class MyWebView extends WebView {
 
+    private static final String TAG = "MyWebView";
     private FillExpectation mExpectation;
 
     public MyWebView(Context context, AttributeSet attrs) {
         super(context, attrs);
+        Log.d(TAG, "isAutofillEnabled() on constructor? " + isAutofillEnabled());
     }
 
     public void expectAutofill(String username, String password) {
@@ -80,6 +84,10 @@
         }
     }
 
+    boolean isAutofillEnabled() {
+        return getContext().getSystemService(AutofillManager.class).isEnabled();
+    }
+
     private class FillExpectation {
         private final CountDownLatch mLatch = new CountDownLatch(1);
         private final String mExpectedUsername;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
index bd26426..923b471 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
@@ -94,110 +94,116 @@
         // Set service.
         enableService();
 
-        // Start activity that is autofilled in a separate process so it can be killed
-        Intent outOfProcessAcvitityStartIntent = new Intent(getContext(),
-                OutOfProcessLoginActivity.class);
-        getContext().startActivity(outOfProcessAcvitityStartIntent);
+        sUiBot.setScreenResolution();
 
-        // Set expectations.
-        final Bundle extras = new Bundle();
-        extras.putString("numbers", "4815162342");
+        try {
+            // Start activity that is autofilled in a separate process so it can be killed
+            Intent outOfProcessAcvitityStartIntent = new Intent(getContext(),
+                    OutOfProcessLoginActivity.class);
+            getContext().startActivity(outOfProcessAcvitityStartIntent);
 
-        // Create the authentication intent (launching a full screen activity)
-        IntentSender authentication = PendingIntent.getActivity(getContext(), 0,
-                new Intent(getContext(), ManualAuthenticationActivity.class),
-                0).getIntentSender();
+            // Set expectations.
+            final Bundle extras = new Bundle();
+            extras.putString("numbers", "4815162342");
 
-        // Prepare the authenticated response
-        ManualAuthenticationActivity.setResponse(new CannedFillResponse.Builder()
-                .addDataset(new CannedFillResponse.CannedDataset.Builder()
-                        .setField(ID_USERNAME, AutofillValue.forText("autofilled username"))
-                        .setPresentation(createPresentation("dataset")).build())
-                .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
-                .setExtras(extras).build());
+            // Create the authentication intent (launching a full screen activity)
+            IntentSender authentication = PendingIntent.getActivity(getContext(), 0,
+                    new Intent(getContext(), ManualAuthenticationActivity.class),
+                    0).getIntentSender();
 
-        CannedFillResponse response = new CannedFillResponse.Builder()
-                .setAuthentication(authentication, ID_USERNAME, ID_PASSWORD)
-                .setPresentation(createPresentation("authenticate"))
-                .build();
-        sReplier.addResponse(response);
+            // Prepare the authenticated response
+            ManualAuthenticationActivity.setResponse(new CannedFillResponse.Builder()
+                    .addDataset(new CannedFillResponse.CannedDataset.Builder()
+                            .setField(ID_USERNAME, AutofillValue.forText("autofilled username"))
+                            .setPresentation(createPresentation("dataset")).build())
+                    .setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
+                    .setExtras(extras).build());
 
-        // Trigger autofill on username
-        sUiBot.selectById(USERNAME_FULL_ID);
+            CannedFillResponse response = new CannedFillResponse.Builder()
+                    .setAuthentication(authentication, ID_USERNAME, ID_PASSWORD)
+                    .setPresentation(createPresentation("authenticate"))
+                    .build();
+            sReplier.addResponse(response);
 
-        // Wait for fill request to be processed
-        sReplier.getNextFillRequest();
+            // Trigger autofill on username
+            sUiBot.selectById(USERNAME_FULL_ID);
 
-        // Wait until authentication is shown
-        sUiBot.assertDatasets("authenticate");
+            // Wait for fill request to be processed
+            sReplier.getNextFillRequest();
 
-        // Change orientation which triggers a destroy -> create in the app as the activity
-        // cannot deal with such situations
-        sUiBot.setScreenOrientation(LANDSCAPE);
+            // Wait until authentication is shown
+            sUiBot.assertDatasets("authenticate");
 
-        // Delete stopped marker
-        getStoppedMarker(getContext()).delete();
+            // Change orientation which triggers a destroy -> create in the app as the activity
+            // cannot deal with such situations
+            sUiBot.setScreenOrientation(LANDSCAPE);
 
-        // Authenticate
-        sUiBot.selectDataset("authenticate");
+            // Delete stopped marker
+            getStoppedMarker(getContext()).delete();
 
-        // Kill activity that is in the background
-        killOfProcessLoginActivityProcess();
+            // Authenticate
+            sUiBot.selectDataset("authenticate");
 
-        // Change orientation which triggers a destroy -> create in the app as the activity
-        // cannot deal with such situations
-        sUiBot.setScreenOrientation(PORTRAIT);
+            // Kill activity that is in the background
+            killOfProcessLoginActivityProcess();
 
-        // Approve authentication
-        sUiBot.selectById(BUTTON_FULL_ID);
+            // Change orientation which triggers a destroy -> create in the app as the activity
+            // cannot deal with such situations
+            sUiBot.setScreenOrientation(PORTRAIT);
 
-        // Wait for dataset to be shown
-        sUiBot.assertDatasets("dataset");
+            // Approve authentication
+            sUiBot.selectById(BUTTON_FULL_ID);
 
-        // Change orientation which triggers a destroy -> create in the app as the activity
-        // cannot deal with such situations
-        sUiBot.setScreenOrientation(LANDSCAPE);
+            // Wait for dataset to be shown
+            sUiBot.assertDatasets("dataset");
 
-        // Select dataset
-        sUiBot.selectDataset("dataset");
+            // Change orientation which triggers a destroy -> create in the app as the activity
+            // cannot deal with such situations
+            sUiBot.setScreenOrientation(LANDSCAPE);
 
-        // Check the results.
-        eventually(() -> assertThat(sUiBot.getTextById(USERNAME_FULL_ID)).isEqualTo(
-                "autofilled username"));
+            // Select dataset
+            sUiBot.selectDataset("dataset");
 
-        // Set password
-        sUiBot.setTextById(PASSWORD_FULL_ID, "new password");
+            // Check the results.
+            eventually(() -> assertThat(sUiBot.getTextById(USERNAME_FULL_ID)).isEqualTo(
+                    "autofilled username"));
 
-        // Login
-        sUiBot.selectById(LOGIN_FULL_ID);
+            // Set password
+            sUiBot.setTextById(PASSWORD_FULL_ID, "new password");
 
-        // Wait for save UI to be shown
-        sUiBot.assertShownById("android:id/autofill_save_yes");
+            // Login
+            sUiBot.selectById(LOGIN_FULL_ID);
 
-        // Change orientation to make sure save UI can handle this
-        sUiBot.setScreenOrientation(PORTRAIT);
+            // Wait for save UI to be shown
+            sUiBot.assertShownById("android:id/autofill_save_yes");
 
-        // Tap "Save".
-        sUiBot.selectById("android:id/autofill_save_yes");
+            // Change orientation to make sure save UI can handle this
+            sUiBot.setScreenOrientation(PORTRAIT);
 
-        // Get save request
-        InstrumentedAutoFillService.SaveRequest saveRequest = sReplier.getNextSaveRequest();
-        assertWithMessage("onSave() not called").that(saveRequest).isNotNull();
+            // Tap "Save".
+            sUiBot.selectById("android:id/autofill_save_yes");
 
-        // Make sure data is correctly saved
-        final AssistStructure.ViewNode username = findNodeByResourceId(saveRequest.structure,
-                ID_USERNAME);
-        assertTextAndValue(username, "autofilled username");
-        final AssistStructure.ViewNode password = findNodeByResourceId(saveRequest.structure,
-                ID_PASSWORD);
-        assertTextAndValue(password, "new password");
+            // Get save request
+            InstrumentedAutoFillService.SaveRequest saveRequest = sReplier.getNextSaveRequest();
+            assertWithMessage("onSave() not called").that(saveRequest).isNotNull();
 
-        // Make sure extras were passed back on onSave()
-        assertThat(saveRequest.data).isNotNull();
-        final String extraValue = saveRequest.data.getString("numbers");
-        assertWithMessage("extras not passed on save").that(extraValue).isEqualTo("4815162342");
+            // Make sure data is correctly saved
+            final AssistStructure.ViewNode username = findNodeByResourceId(saveRequest.structure,
+                    ID_USERNAME);
+            assertTextAndValue(username, "autofilled username");
+            final AssistStructure.ViewNode password = findNodeByResourceId(saveRequest.structure,
+                    ID_PASSWORD);
+            assertTextAndValue(password, "new password");
 
-        eventually(() -> assertNoDanglingSessions());
+            // Make sure extras were passed back on onSave()
+            assertThat(saveRequest.data).isNotNull();
+            final String extraValue = saveRequest.data.getString("numbers");
+            assertWithMessage("extras not passed on save").that(extraValue).isEqualTo("4815162342");
+
+            eventually(() -> assertNoDanglingSessions());
+        } finally {
+            sUiBot.resetScreenResolution();
+        }
     }
 
     @Test
diff --git a/tests/autofillservice/src/android/autofillservice/cts/UiBot.java b/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
index 436f59f..82d4700 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
@@ -20,6 +20,7 @@
 import static android.autofillservice.cts.Helper.SAVE_TIMEOUT_MS;
 import static android.autofillservice.cts.Helper.UI_RECENTS_SWITCH_TIMEOUT_MS;
 import static android.autofillservice.cts.Helper.UI_TIMEOUT_MS;
+import static android.autofillservice.cts.Helper.runShellCommand;
 import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_ADDRESS;
 import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_CREDIT_CARD;
 import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_EMAIL_ADDRESS;
@@ -676,4 +677,27 @@
     public void dumpScreen() throws IOException {
         mDevice.dumpWindowHierarchy(System.out);
     }
+
+    /**
+     * Sets screen resolution.
+     *
+     * <p>If the screen is too small and the devices shows an IME, it might not have space for all
+     * UI elements after the device is rotated to landscape.
+     *
+     * <p>{@link #resetScreenResolution()} should always be called too.
+     */
+    void setScreenResolution() {
+        assumeMinimumResolution(500);
+
+        runShellCommand("wm size 1080x1920");
+        runShellCommand("wm density 420");
+    }
+
+    /**
+     * Resets screen resolution.
+     */
+    void resetScreenResolution() {
+        runShellCommand("wm density reset");
+        runShellCommand("wm size reset");
+    }
 }
diff --git a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
index d3b2d82..cf2ecfc 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
@@ -25,6 +25,7 @@
 import android.autofillservice.cts.InstrumentedAutoFillService.FillRequest;
 import android.autofillservice.cts.InstrumentedAutoFillService.SaveRequest;
 import android.support.test.uiautomator.UiObject2;
+import android.util.Log;
 import android.view.ViewStructure.HtmlInfo;
 
 import org.junit.AfterClass;
@@ -35,19 +36,34 @@
 
 public class WebViewActivityTest extends AutoFillServiceTestCase {
 
+    private static final String TAG = "WebViewActivityTest";
+
     // TODO(b/64951517): WebView currently does not trigger the autofill callbacks when values are
     // set using accessibility.
     private static final boolean INJECT_EVENTS = true;
 
     @Rule
     public final AutofillActivityTestRule<WebViewActivity> mActivityRule =
-            new AutofillActivityTestRule<WebViewActivity>(WebViewActivity.class);
+            new AutofillActivityTestRule<WebViewActivity>(WebViewActivity.class) {
+    // TODO(b/111838239): latest WebView implementation calls AutofillManager.isEnabled() to
+    // disable autofill for optimization when it returns false, and unfortunately the value
+    // returned by that method does not change when the service is enabled / disabled, so we
+    // need to start enable the service before launching the activity.
+    // Once that's fixed, remove this overridden method.
+                @Override
+                protected void beforeActivityLaunched() {
+                    super.beforeActivityLaunched();
+                    Log.i(TAG, "Setting service before launching the activity");
+                    enableService();
+                }
+            };
 
     private WebViewActivity mActivity;
 
     @Before
     public void setActivity() {
         mActivity = mActivityRule.getActivity();
+        assertAutofillEnabledOnWebView();
     }
 
     @BeforeClass
@@ -276,4 +292,8 @@
             Helper.assertTextAndValue(passwordNode2, "SWEET");
         }
     }
+
+    private void assertAutofillEnabledOnWebView() {
+        assertThat(mActivity.mWebView.isAutofillEnabled()).isTrue();
+    }
 }
diff --git a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
index d2da516..378e39c 100755
--- a/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistStructureTest.java
@@ -89,8 +89,8 @@
     }
 
     public void testAssistStructure() throws Throwable {
-        if (mActivityManager.isLowRamDevice()) {
-            Log.d(TAG, "Not running assist tests on low-RAM device.");
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_VOICE_RECOGNIZERS)) {
+            Log.d(TAG, "Not running assist tests - voice_recognizers feature is not supported");
             return;
         }
         mTestActivity.start3pApp(TEST_CASE_TYPE);
diff --git a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
index 33a7758..461f5d0 100644
--- a/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
+++ b/tests/tests/assist/src/android/assist/cts/AssistTestBase.java
@@ -48,6 +48,7 @@
 public class AssistTestBase extends ActivityInstrumentationTestCase2<TestStartActivity> {
     private static final String TAG = "AssistTestBase";
 
+    protected static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
     protected ActivityManager mActivityManager;
     protected TestStartActivity mTestActivity;
     protected AssistContent mAssistContent;
diff --git a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
index 3c5a0fb..20437eb 100644
--- a/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
+++ b/tests/tests/assist/src/android/assist/cts/DisableContextTest.java
@@ -49,8 +49,8 @@
     }
 
     public void testContextAndScreenshotOff() throws Exception {
-        if (mActivityManager.isLowRamDevice()) {
-            Log.d(TAG, "Not running assist tests on low-RAM device.");
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_VOICE_RECOGNIZERS)) {
+            Log.d(TAG, "Not running assist tests - voice_recognizers feature is not supported");
             return;
         }
         // Both settings off
diff --git a/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java b/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
index fc7c8fb..43364f8 100644
--- a/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
+++ b/tests/tests/assist/src/android/assist/cts/FlagSecureTest.java
@@ -77,8 +77,8 @@
     }
 
     public void testSecureActivity() throws Exception {
-        if (mActivityManager.isLowRamDevice()) {
-            Log.d(TAG, "Not running assist tests on low-RAM device.");
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_VOICE_RECOGNIZERS)) {
+            Log.d(TAG, "Not running assist tests - voice_recognizers feature is not supported");
             return;
         }
         mTestActivity.startTest(TEST_CASE_TYPE);
diff --git a/tests/tests/assist/src/android/assist/cts/LifecycleTest.java b/tests/tests/assist/src/android/assist/cts/LifecycleTest.java
index 237fe6e..a4a1606 100644
--- a/tests/tests/assist/src/android/assist/cts/LifecycleTest.java
+++ b/tests/tests/assist/src/android/assist/cts/LifecycleTest.java
@@ -121,8 +121,8 @@
     }
 
     public void testLayerDoesNotTriggerLifecycleMethods() throws Exception {
-        if (mActivityManager.isLowRamDevice()) {
-            Log.d(TAG, "Not running assist tests on low-RAM device.");
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_VOICE_RECOGNIZERS)) {
+            Log.d(TAG, "Not running assist tests - voice_recognizers feature is not supported");
             return;
         }
         mTestActivity.startTest(Utils.LIFECYCLE);
diff --git a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
index 3a016bc..2e6acc7 100644
--- a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
@@ -332,29 +332,4 @@
         assertCanBeHandled(new Intent(StorageManager.ACTION_MANAGE_STORAGE));
     }
 
-    public void testVoiceCommand() {
-        if (FeatureUtil.isLowRam()) {
-            // Low ram devices do not support voice command, skip this test
-            return;
-        }
-        PackageManager packageManager = mContext.getPackageManager();
-        if (packageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
-            Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
-            assertCanBeHandled(intent);
-            assertDefaultHandlerValidPriority(intent);
-        }
-    }
-
-    public void testVoiceSearchHandsFree() {
-        if (FeatureUtil.isLowRam()) {
-            // Low ram devices do not support hands-free hot word, skip this test
-            return;
-        }
-        PackageManager packageManager = mContext.getPackageManager();
-        if (packageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
-            Intent intent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
-            assertCanBeHandled(intent);
-            assertDefaultHandlerValidPriority(intent);
-        }
-    }
 }
diff --git a/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java b/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
index e771461..5cfd532 100644
--- a/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentProviderCursorWindowTest.java
@@ -17,14 +17,13 @@
 package android.content.cts;
 
 import android.database.Cursor;
+import android.database.CursorWindowAllocationException;
 import android.database.sqlite.SQLiteException;
 import android.net.Uri;
 import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 import android.util.Log;
 
-import java.io.IOException;
-
 /**
  * Test {@link CursorWindowContentProvider} .
  */
@@ -32,11 +31,20 @@
 public class ContentProviderCursorWindowTest extends AndroidTestCase {
     private static final String TAG = "ContentProviderCursorWindowTest";
 
-    public void testQuery() throws IOException {
-        Cursor cursor = getContext().getContentResolver().query(
-                Uri.parse("content://cursorwindow.provider/hello"),
-                null, null, null, null
-        );
+    public void testQuery() {
+        // First check if the system has a patch for enforcing protected Parcel data
+        Cursor cursor;
+        try {
+            cursor = getContext().getContentResolver().query(
+                    Uri.parse("content://cursorwindow.provider/hello"),
+                    null, null, null, null);
+        } catch (CursorWindowAllocationException expected) {
+            Log.i(TAG, "Expected exception: " + expected);
+            return;
+        }
+
+        // If the system has no patch for protected Parcel data,
+        // it should still fail while reading from the cursor
         try {
             cursor.moveToFirst();
 
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
index 0d70947..f0d5cb8 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
@@ -51,6 +51,8 @@
 
 import java.util.Locale;
 
+import com.android.compatibility.common.util.CddTest;
+
 @SmallTest
 @RunWith(AndroidJUnit4.class)
 public class PaintTest {
@@ -1226,6 +1228,7 @@
         new Paint().getTextPath("HIJKLMN", 3, 9, 0, 0, new Path());
     }
 
+    @CddTest(requirement="3.8.13/C-1-2")
     @Test
     public void testHasGlyph() {
         Paint p = new Paint();
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
index d2b7f23..ff8efc7 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
@@ -207,6 +207,7 @@
         boolean playedSuccessfully = false;
         for (int i = 0; i < STREAM_RETRIES; i++) {
           try {
+            mMediaPlayer.reset();
             mMediaPlayer.setDataSource(path);
             playLoadedVideo(width, height, playTime);
             playedSuccessfully = true;
@@ -239,6 +240,7 @@
         boolean playedSuccessfully = false;
         for (int i = 0; i < STREAM_RETRIES; i++) {
             try {
+                mMediaPlayer.reset();
                 mMediaPlayer.setDataSource(getInstrumentation().getTargetContext(),
                         uri, headers, cookies);
                 playLoadedVideo(width, height, playTime);
diff --git a/tests/tests/media/src/android/media/cts/MediaRouterTest.java b/tests/tests/media/src/android/media/cts/MediaRouterTest.java
index 8f2060d..4b91a79 100644
--- a/tests/tests/media/src/android/media/cts/MediaRouterTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRouterTest.java
@@ -155,24 +155,11 @@
         Object tag = new Object();
         route.setTag(tag);
         assertEquals(tag, route.getTag());
-
         assertEquals(AudioManager.STREAM_MUSIC, route.getPlaybackStream());
-        if (RouteInfo.PLAYBACK_VOLUME_VARIABLE == route.getVolumeHandling()) {
-            int curVolume = route.getVolume();
-            int maxVolume = route.getVolumeMax();
-            assertTrue(curVolume <= maxVolume);
-            if (!mContext.getResources().getBoolean(
-                    com.android.internal.R.bool.config_safe_media_volume_enabled)) {
-                route.requestSetVolume(maxVolume);
-                assertEquals(maxVolume, route.getVolume());
-                route.requestUpdateVolume(-maxVolume);
-            } else {
-                route.requestSetVolume(0);
-            }
-            assertEquals(0, route.getVolume());
-            route.requestUpdateVolume(curVolume);
-            assertEquals(curVolume, route.getVolume());
-        }
+
+        int curVolume = route.getVolume();
+        int maxVolume = route.getVolumeMax();
+        assertTrue(curVolume <= maxVolume);
     }
 
     /**
diff --git a/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java b/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
index 94b25fb..aa6275f 100644
--- a/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
+++ b/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
@@ -19,11 +19,14 @@
 import android.content.pm.PackageManager;
 import android.test.AndroidTestCase;
 
+import com.android.compatibility.common.util.CddTest;
+
 /**
  * Check AHardwareBuffer functionality.
  *
  * This is the place to implement AHardwareBuffer NDK CTS tests.
  */
+@CddTest(requirement="7.9.2/C-1-10")
 public class AHardwareBufferNativeTest extends AndroidTestCase {
     protected native long nativeSetUp();
     protected native void nativeTearDown(long instance);
diff --git a/tests/tests/os/src/android/os/cts/SecurityPatchTest.java b/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
index d6fb646..7afeaa9 100644
--- a/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
+++ b/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
@@ -31,10 +31,6 @@
     private static final String TAG = SecurityPatchTest.class.getSimpleName();
     private static final String SECURITY_PATCH_ERROR =
             "ro.build.version.security_patch should be in the format \"YYYY-MM-DD\". Found \"%s\"";
-    private static final String SECURITY_PATCH_DATE_ERROR =
-            "ro.build.version.security_patch should be \"%d-%02d\" or later. Found \"%s\"";
-    private static final int SECURITY_PATCH_YEAR = 2016;
-    private static final int SECURITY_PATCH_MONTH = 12;
 
     private boolean mSkipTests = false;
 
@@ -77,32 +73,4 @@
         assertTrue(error, Character.isDigit(buildSecurityPatch.charAt(8)));
         assertTrue(error, Character.isDigit(buildSecurityPatch.charAt(9)));
     }
-
-    /** Security patch should no older than the month this test was updated in M or higher **/
-    public void testSecurityPatchDate() {
-        if (mSkipTests) {
-            Log.w(TAG, "Skipping M+ Test.");
-            return;
-        }
-
-        String buildSecurityPatch = Build.VERSION.SECURITY_PATCH;
-        String error = String.format(SECURITY_PATCH_DATE_ERROR,
-                                     SECURITY_PATCH_YEAR,
-                                     SECURITY_PATCH_MONTH,
-                                     buildSecurityPatch);
-
-        int declaredYear = 0;
-        int declaredMonth = 0;
-
-        try {
-            declaredYear = Integer.parseInt(buildSecurityPatch.substring(0,4));
-            declaredMonth = Integer.parseInt(buildSecurityPatch.substring(5,7));
-        } catch (Exception e) {
-            assertTrue(error, false);
-        }
-
-        assertTrue(error, declaredYear >= SECURITY_PATCH_YEAR);
-        assertTrue(error, (declaredYear > SECURITY_PATCH_YEAR) ||
-                          (declaredMonth >= SECURITY_PATCH_MONTH));
-    }
 }
diff --git a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
index 1b1e669..2f155d8 100644
--- a/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/ProtectedBroadcastsTest.java
@@ -86,7 +86,6 @@
         "android.intent.action.NETWORK_SET_TIME",
         "android.intent.action.NETWORK_SET_TIMEZONE",
         "com.android.internal.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS",
-        "android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED",
     };
 
     /**
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index d096d25..af6034a 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -244,7 +244,7 @@
      ***********************************************************/
 
     @SecurityTest
-    public void testStagefright_b72165027() throws Exception {
+    public void testStagefright_bug_72165027() throws Exception {
         doStagefrightTest(R.raw.bug_72165027);
     }
 
diff --git a/tests/tests/systemintents/Android.mk b/tests/tests/systemintents/Android.mk
index 573e2ee..ba284f5 100644
--- a/tests/tests/systemintents/Android.mk
+++ b/tests/tests/systemintents/Android.mk
@@ -27,7 +27,7 @@
 
 LOCAL_PACKAGE_NAME := CtsSystemIntentTestCases
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner legacy-android-test compatibility-device-util
 
 LOCAL_SDK_VERSION := test_current
 
diff --git a/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java b/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java
index c572629..c490c5d 100644
--- a/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java
+++ b/tests/tests/systemintents/src/android/systemintents/cts/TestSystemIntents.java
@@ -26,6 +26,8 @@
 import android.test.AndroidTestCase;
 import android.util.Log;
 
+import com.android.compatibility.common.util.CddTest;
+
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -74,6 +76,7 @@
                     new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS))
     };
 
+    @CddTest(requirement="3.8.3.3/C-1-1")
     @Test
     public void testSystemIntents() {
         final PackageManager pm = getContext().getPackageManager();
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
index 434c4ee..ed0e02f 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
@@ -116,8 +116,10 @@
         PackageManager pm = getInstrumentation().getContext().getPackageManager();
         if (pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
                 || pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
-                || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
+                || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
+                || pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
             // No navigation bar on TVs and watches.
+            // Car navigation is not transparent.
             return;
         }
 
@@ -259,7 +261,7 @@
         float eps = 0.005f;
 
         for (int c : pixels) {
-            if (c == background) {
+            if (isColorSame(c, background)) {
                 s.backgroundPixels++;
                 continue;
             }
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java b/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java
index 8498578..1ce3c1b 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarThemeTest.java
@@ -24,6 +24,7 @@
 import android.support.test.rule.ActivityTestRule;
 import android.support.test.runner.AndroidJUnit4;
 import android.support.test.uiautomator.UiDevice;
+import android.content.pm.PackageManager;
 import android.view.View;
 
 import org.junit.Before;
@@ -60,6 +61,11 @@
 
     @Test
     public void testNavigationBarDivider() throws Exception {
+        PackageManager pm = getInstrumentation().getContext().getPackageManager();
+        if (pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+            // Car navigation is not transparent
+            return;
+        }
 
         if (!hasVirtualNavigationBar()) {
             // No virtual navigation bar, so no effect.
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
old mode 100644
new mode 100755
index 0b70f1b..38f2673
--- a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
@@ -118,10 +118,37 @@
         waitOnAllHandlers(getInstrumentation());
 
         AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
-        assertEquals(AudioManager.MODE_IN_COMMUNICATION, audioManager.getMode());
+        waitUntilConditionIsTrueOrTimeout(
+                new Condition() {
+                    @Override
+                    public Object expected() {
+                        return AudioManager.MODE_IN_COMMUNICATION;
+                    }
+
+                    @Override
+                    public Object actual() {
+                        return audioManager.getMode();
+                    }
+                },
+                WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, "wait for mode in-communication"
+        );
+
         connection.setAudioModeIsVoip(false);
         waitOnAllHandlers(getInstrumentation());
-        assertEquals(AudioManager.MODE_IN_CALL, audioManager.getMode());
+        waitUntilConditionIsTrueOrTimeout(
+                new Condition() {
+                    @Override
+                    public Object expected() {
+                        return AudioManager.MODE_IN_CALL;
+                    }
+
+                    @Override
+                    public Object actual() {
+                        return audioManager.getMode();
+                    }
+                },
+                WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, "wait for mode in-call"
+        );
     }
 
     public void testGetAllConnections() {
diff --git a/tests/tests/text/src/android/text/cts/FontCoverageTest.java b/tests/tests/text/src/android/text/cts/FontCoverageTest.java
index 4f66ee7..837c209 100644
--- a/tests/tests/text/src/android/text/cts/FontCoverageTest.java
+++ b/tests/tests/text/src/android/text/cts/FontCoverageTest.java
@@ -26,12 +26,15 @@
 import android.support.test.filters.LargeTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.compatibility.common.util.CddTest;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.util.HashMap;
 import java.util.Locale;
 
+@CddTest(requirement="3.8.13/C-1-1")
 @LargeTest
 @RunWith(AndroidJUnit4.class)
 public class FontCoverageTest {
diff --git a/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java b/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
index a27633a..e7dafa2 100644
--- a/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
+++ b/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
@@ -20,6 +20,8 @@
 import android.opengl.GLES32;
 import android.test.ActivityInstrumentationTestCase2;
 
+import com.android.compatibility.common.util.CddTest;
+
 public class VrExtensionBehaviorTest extends ActivityInstrumentationTestCase2<OpenGLESActivity> {
     static {
         System.loadLibrary("ctsvrextensions_jni");
@@ -53,6 +55,7 @@
     /**
      * Tests that protected content contexts and surfaces can be created.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testProtectedContent() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 1, 0, 0);
         if (!mActivity.supportsVrHighPerformance())
@@ -77,6 +80,7 @@
     /**
      * Tests that textures can be marked as protected.
      */
+    @CddTest(requirement="7.9.2/C-1-8")
     public void testProtectedTextures() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_PROTECTEDTEXTURES, 1, 0, 0);
         if (!mActivity.supportsVrHighPerformance())
@@ -104,6 +108,7 @@
     /**
      * Tests that context priority can be set to high.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testContextPriorityHigh() throws Throwable {
         runContextPriorityTest(EGL_CONTEXT_PRIORITY_HIGH_IMG);
     }
@@ -111,6 +116,7 @@
     /**
      * Tests that context priority can be set to medium.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testContextPriorityMedium() throws Throwable {
         runContextPriorityTest(EGL_CONTEXT_PRIORITY_MEDIUM_IMG);
     }
@@ -118,6 +124,7 @@
     /**
      * Tests that context priority can be set to low.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testContextPriorityLow() throws Throwable {
         runContextPriorityTest(EGL_CONTEXT_PRIORITY_LOW_IMG);
     }
@@ -125,6 +132,7 @@
     /**
      * Tests that context priority can be set to low.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testMutableRenderBuffer() throws Throwable {
 
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 1);
@@ -160,6 +168,7 @@
      * For more information, see the EGL_image_array spec:
      * https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_EGL_image_array.txt
      */
+    @CddTest(requirement="7.9.2/C-1-8,C-1-10")
     public void testEglImageArray() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 0);
         if (!mActivity.supportsVrHighPerformance())
@@ -179,6 +188,7 @@
      * For more information, see the GL_EXT_external_buffer spec:
      * https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_external_buffer.txt
      */
+    @CddTest(requirement="7.9.2/C-1-8")
     public void testExternalBuffer() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 0);
         if (!mActivity.supportsVrHighPerformance())
diff --git a/tools/cts-tradefed/Android.mk b/tools/cts-tradefed/Android.mk
index 3950cb0..03c963b 100644
--- a/tools/cts-tradefed/Android.mk
+++ b/tools/cts-tradefed/Android.mk
@@ -29,7 +29,7 @@
 LOCAL_SUITE_TARGET_ARCH := $(TARGET_ARCH)
 LOCAL_SUITE_NAME := CTS
 LOCAL_SUITE_FULLNAME := "Compatibility Test Suite"
-LOCAL_SUITE_VERSION := 8.1_r7
+LOCAL_SUITE_VERSION := 8.1_r8
 LOCAL_STATIC_JAVA_LIBRARIES += cts-tradefed-harness
 
 LOCAL_MODULE := cts-tradefed