Merge "[CTS] Add EasyConnectStatusCallback tests" into rvc-dev
diff --git a/apps/CameraITS/tests/scene_change/test_scene_change.py b/apps/CameraITS/tests/scene_change/test_scene_change.py
index 2304759..626c224 100644
--- a/apps/CameraITS/tests/scene_change/test_scene_change.py
+++ b/apps/CameraITS/tests/scene_change/test_scene_change.py
@@ -31,7 +31,7 @@
 #             3: PASSIVE_UNFOCUSED, 4: ACTIVE_SCAN, 5: FOCUS_LOCKED,
 #             6: NOT_FOCUSED_LOCKED}
 # AWB_STATES: {0: INACTIVE, 1: SEARCHING, 2: CONVERGED, 3: LOCKED}
-DELAY_CAPTURE = 0.55  # delay in first capture to sync events (sec)
+DELAY_CAPTURE = 1.5  # delay in first capture to sync events (sec)
 DELAY_DISPLAY = 3.0  # time when display turns OFF (sec)
 FPS = 30
 FRAME_SHIFT = 5.0  # number of frames to shift to try and find scene change
@@ -56,17 +56,16 @@
             converged_frame = i
             break
     print 'Frames index where 3A converges: %d' % converged_frame
-    assert converged_frame != -1, '3A does not converge'
     return converged_frame
 
 
 def determine_if_scene_changed(cap_data, converged_frame):
     scene_changed = False
     bright_changed = False
-    settled_frame_brightness = cap_data[converged_frame]['avg']
+    start_frame_brightness = cap_data[0]['avg']
     for i in range(converged_frame, len(cap_data)):
         if cap_data[i]['avg'] <= (
-                settled_frame_brightness * (1.0 - BRIGHT_CHANGE_TOL)):
+                start_frame_brightness * (1.0 - BRIGHT_CHANGE_TOL)):
             bright_changed = True
         if cap_data[i]['flag'] == 1:
             scene_changed = True
@@ -75,7 +74,6 @@
 
 def toggle_screen(chart_host_id, state, delay):
     t0 = time.time()
-    print 'tablet event start'
     screen_id_arg = ('screen=%s' % chart_host_id)
     state_id_arg = 'state=%s' % state
     delay_arg = 'delay=%.3f' % delay
@@ -88,49 +86,48 @@
     print 'tablet event %s: %.3f' % (state, t)
 
 
-def capture_frames(delay, burst):
+def capture_frames(cam, delay, burst):
     """Capture frames."""
     cap_data_list = []
-    with its.device.ItsSession() as cam:
-        req = its.objects.auto_capture_request()
-        req['android.control.afMode'] = CONTINUOUS_PICTURE_MODE
-        fmt = {'format': 'yuv', 'width': W, 'height': H}
-        t0 = time.time()
-        time.sleep(delay)
-        print 'cap event start:', time.time() - t0
-        caps = cam.do_capture([req]*NUM_FRAMES, fmt)
-        print 'cap event stop:', time.time() - t0
-        # extract frame metadata and frame
-        for i, cap in enumerate(caps):
-            cap_data = {}
-            md = cap['metadata']
-            exp = md['android.sensor.exposureTime']
-            iso = md['android.sensor.sensitivity']
-            fd = md['android.lens.focalLength']
-            ae_state = md['android.control.aeState']
-            af_state = md['android.control.afState']
-            awb_state = md['android.control.awbState']
-            fd_str = 'infinity'
-            if fd != 0.0:
-                fd_str = str(round(1.0E2/fd, 2)) + 'cm'
-            scene_change_flag = md['android.control.afSceneChange']
-            assert scene_change_flag in [0, 1], 'afSceneChange not in [0,1]'
-            img = its.image.convert_capture_to_rgb_image(cap)
-            its.image.write_image(img, '%s_%d_%d.jpg' % (NAME, burst+1, i))
-            tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
-            g = its.image.compute_image_means(tile)[1]
-            print '%d, iso: %d, exp: %.2fms, fd: %s, avg: %.3f' % (
-                    i, iso, exp*1E-6, fd_str, g),
-            print '[ae,af,awb]: [%d,%d,%d], change: %d' % (
-                    ae_state, af_state, awb_state, scene_change_flag)
-            cap_data['exp'] = exp
-            cap_data['iso'] = iso
-            cap_data['fd'] = fd
-            cap_data['3a_state'] = [ae_state, af_state, awb_state]
-            cap_data['avg'] = g
-            cap_data['flag'] = scene_change_flag
-            cap_data_list.append(cap_data)
-        return cap_data_list
+    req = its.objects.auto_capture_request()
+    req['android.control.afMode'] = CONTINUOUS_PICTURE_MODE
+    fmt = {'format': 'yuv', 'width': W, 'height': H}
+    t0 = time.time()
+    time.sleep(delay)
+    print 'cap event start:', time.time() - t0
+    caps = cam.do_capture([req]*NUM_FRAMES, fmt)
+    print 'cap event stop:', time.time() - t0
+    # extract frame metadata and frame
+    for i, cap in enumerate(caps):
+        cap_data = {}
+        md = cap['metadata']
+        exp = md['android.sensor.exposureTime']
+        iso = md['android.sensor.sensitivity']
+        fd = md['android.lens.focalLength']
+        ae_state = md['android.control.aeState']
+        af_state = md['android.control.afState']
+        awb_state = md['android.control.awbState']
+        fd_str = 'infinity'
+        if fd != 0.0:
+            fd_str = str(round(1.0E2/fd, 2)) + 'cm'
+        scene_change_flag = md['android.control.afSceneChange']
+        assert scene_change_flag in [0, 1], 'afSceneChange not in [0,1]'
+        img = its.image.convert_capture_to_rgb_image(cap)
+        its.image.write_image(img, '%s_%d_%d.jpg' % (NAME, burst, i))
+        tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
+        g = its.image.compute_image_means(tile)[1]
+        print '%d, iso: %d, exp: %.2fms, fd: %s, avg: %.3f' % (
+                i, iso, exp*1E-6, fd_str, g),
+        print '[ae,af,awb]: [%d,%d,%d], change: %d' % (
+                ae_state, af_state, awb_state, scene_change_flag)
+        cap_data['exp'] = exp
+        cap_data['iso'] = iso
+        cap_data['fd'] = fd
+        cap_data['3a_state'] = [ae_state, af_state, awb_state]
+        cap_data['avg'] = g
+        cap_data['flag'] = scene_change_flag
+        cap_data_list.append(cap_data)
+    return cap_data_list
 
 
 def main():
@@ -148,52 +145,72 @@
                              its.caps.read_3a(props))
         cam.do_3a()
 
-    # do captures with scene change
-    chart_host_id = get_cmd_line_args()
-    cap_delay = DELAY_CAPTURE
-    scene_delay = DELAY_DISPLAY
-    for burst in range(NUM_BURSTS):
-        if chart_host_id:
-            print '\nToggling tablet. Scene change at %.3fs.' % scene_delay
-            multiprocessing.Process(name='p1', target=toggle_screen,
-                                    args=(chart_host_id, 'OFF',
-                                          scene_delay,)).start()
-        else:
-            print '\nWave hand in front of camera to create scene change.'
-        cap_data = capture_frames(cap_delay, burst+1)
-
-        # find frame where 3A converges
-        converged_frame = mask_3a_settling_frames(cap_data)
-
-        # turn tablet back on to return to baseline scene state
-        if chart_host_id:
-            toggle_screen(chart_host_id, 'ON', 0)
-
-        # determine if brightness changed and/or scene change flag asserted
-        scene_changed, bright_changed = determine_if_scene_changed(
-                cap_data, converged_frame)
-        if not scene_changed:
-            if bright_changed:
-                print ' No scene change, but brightness change.'
-                scene_delay -= FRAME_SHIFT/FPS  # tablet-off earlier
+        # do captures with scene change
+        chart_host_id = get_cmd_line_args()
+        scene_delay = DELAY_DISPLAY
+        for burst in range(NUM_BURSTS):
+            print 'burst number: %d' % burst
+            # create scene change by turning off chart display & capture frames
+            if chart_host_id:
+                print '\nToggling tablet. Scene change at %.3fs.' % scene_delay
+                multiprocessing.Process(name='p1', target=toggle_screen,
+                                        args=(chart_host_id, 'OFF',
+                                              scene_delay,)).start()
             else:
-                print ' No scene change, no brightness change.'
-                if cap_data[NUM_FRAMES-1]['avg'] < 0.1:
-                    print ' Scene dark entire capture. Shift later.'
-                    scene_delay += FRAME_SHIFT/FPS  # tablet-off later
+                print '\nWave hand in front of camera to create scene change.'
+            cap_data = capture_frames(cam, DELAY_CAPTURE, burst)
+
+            # find frame where 3A converges
+            converged_frame = mask_3a_settling_frames(cap_data)
+
+            # turn tablet back on to return to baseline scene state
+            if chart_host_id:
+                toggle_screen(chart_host_id, 'ON', 0)
+
+            # determine if brightness changed and/or scene change flag asserted
+            scene_changed, bright_changed = determine_if_scene_changed(
+                    cap_data, converged_frame)
+
+            # handle different capture cases
+            if converged_frame > -1:  # 3A converges
+                if scene_changed:
+                    if bright_changed:
+                        print ' scene & brightness change on burst %d.' % burst
+                        sys.exit(0)
+                    else:
+                        msg = ' scene change, but no brightness change.'
+                        assert False, msg
+                else:  # shift scene change timing if no scene change
+                    scene_shift = FRAME_SHIFT / FPS
+                    if bright_changed:
+                        print ' No scene change, but brightness change.'
+                        print 'Shift %.3fs earlier' % scene_shift
+                        scene_delay -= scene_shift  # tablet-off earlier
+                    else:
+                        scene_shift = FRAME_SHIFT / FPS * NUM_BURSTS
+                        print ' No scene change, no brightness change.'
+                        if cap_data[NUM_FRAMES-1]['avg'] < 0.2:
+                            print ' Scene dark entire capture.',
+                            print 'Shift %.3fs later.' % scene_shift
+                            scene_delay += scene_shift  # tablet-off later
+                        else:
+                            print ' Scene light entire capture.',
+                            print 'Shift %.3fs earlier.' % scene_shift
+                            scene_delay -= scene_shift  # tablet-off earlier
+
+            else:  # 3A does not converge
+                if bright_changed:
+                    scene_shift = FRAME_SHIFT / FPS
+                    print ' 3A does not converge, but brightness change.',
+                    print 'Shift %.3fs later' % scene_shift
+                    scene_delay += scene_shift  # tablet-off earlier
                 else:
-                    print ' Scene light entire capture. Shift earlier.'
-                    scene_delay -= FRAME_SHIFT/FPS  # tablet-off earlier
-            print ' Retry with tablet turning OFF earlier.'
-        elif scene_changed and bright_changed:
-            print ' scene & brightness change on burst %d.' % (burst+1)
-            break
-        elif scene_changed and not bright_changed:
-            msg = ' scene change, but no brightness change.'
-            assert False, msg
-        if burst == NUM_BURSTS - 1:
-            msg = 'No scene change in %dx tries' % NUM_BURSTS
-            assert False, msg
+                    msg = ' 3A does not converge with no brightness change.'
+                    assert False, msg
+
+        # fail out if too many tries
+        msg = 'No scene change in %dx tries' % NUM_BURSTS
+        assert False, msg
 
 
 if __name__ == '__main__':
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/wifi/testcase/NetworkSuggestionTestCase.java b/apps/CtsVerifier/src/com/android/cts/verifier/wifi/testcase/NetworkSuggestionTestCase.java
index 7c7c399..395142d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/wifi/testcase/NetworkSuggestionTestCase.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/wifi/testcase/NetworkSuggestionTestCase.java
@@ -155,19 +155,18 @@
         long startTimeMillis = SystemClock.elapsedRealtime();
         while (SystemClock.elapsedRealtime()
                 < startTimeMillis + CAPABILITIES_CHANGED_FOR_METERED_TIMEOUT_MS) {
+            // Network marked metered.
+            if (!mNetworkCallback.getNetworkCapabilities()
+                    .hasCapability(NET_CAPABILITY_NOT_METERED)) {
+                return true;
+            } else {
+                Log.w(TAG, "Network meteredness check failed. "
+                        + mNetworkCallback.getNetworkCapabilities());
+            }
             // Wait for the suggestion to be marked metered now.
             if (!mNetworkCallback.waitForCapabilitiesChanged()) {
-                Log.e(TAG, "Network capabilities did not change");
-                continue;
+                Log.w(TAG, "Network capabilities did not change");
             }
-            if (mNetworkCallback.getNetworkCapabilities()
-                    .hasCapability(NET_CAPABILITY_NOT_METERED)) {
-                Log.e(TAG, "Network meteredness check failed "
-                        + mNetworkCallback.getNetworkCapabilities());
-                continue;
-            }
-            // Network marked metered.
-            return true;
         }
         return false;
     }
diff --git a/hostsidetests/blobstore/Android.bp b/hostsidetests/blobstore/Android.bp
index aab448e..2baec7f 100644
--- a/hostsidetests/blobstore/Android.bp
+++ b/hostsidetests/blobstore/Android.bp
@@ -42,7 +42,7 @@
       "testng",
   ],
   manifest : "test-apps/BlobStoreHostTestHelper/AndroidManifest.xml",
-  platform_apis: true,
+  sdk_version: "test_current",
   // Tag this module as a cts test artifact
   test_suites: [
     "cts",
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DeviceIdentifiersTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DeviceIdentifiersTest.java
index 855958c..c44b406 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DeviceIdentifiersTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/DeviceIdentifiersTest.java
@@ -15,8 +15,6 @@
  */
 package com.android.cts.deviceandprofileowner;
 
-import static org.testng.Assert.assertThrows;
-
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.Build;
@@ -50,24 +48,24 @@
         try {
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getDeviceId"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getDeviceId()), telephonyManager.getDeviceId());
+                            TelephonyManager::getDeviceId), telephonyManager.getDeviceId());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getImei"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getImei()), telephonyManager.getImei());
+                            TelephonyManager::getImei), telephonyManager.getImei());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getMeid"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getMeid()), telephonyManager.getMeid());
+                            TelephonyManager::getMeid), telephonyManager.getMeid());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getSubscriberId"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getSubscriberId()), telephonyManager.getSubscriberId());
+                            TelephonyManager::getSubscriberId), telephonyManager.getSubscriberId());
             assertEquals(
                     String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getSimSerialNumber"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getSimSerialNumber()),
+                            TelephonyManager::getSimSerialNumber),
                     telephonyManager.getSimSerialNumber());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getNai"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getNai()), telephonyManager.getNai());
+                            TelephonyManager::getNai), telephonyManager.getNai());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "Build#getSerial"),
                     ShellIdentityUtils.invokeStaticMethodWithShellPermissions(Build::getSerial),
                     Build.getSerial());
@@ -90,7 +88,7 @@
         }
     }
 
-    public void testProfileOwnerCannotGetDeviceIdentifiersWithoutPermission() throws Exception {
+    public void testProfileOwnerCannotGetDeviceIdentifiersWithoutPermission() {
         // The profile owner without the READ_PHONE_STATE permission should still receive a
         // SecurityException when querying for device identifiers.
         TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
@@ -98,22 +96,35 @@
         // Allow the APIs to also return null if the telephony feature is not supported.
         boolean hasTelephonyFeature =
                 mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
-        if (hasTelephonyFeature) {
-            assertThrows(SecurityException.class, telephonyManager::getDeviceId);
-            assertThrows(SecurityException.class, telephonyManager::getImei);
-            assertThrows(SecurityException.class, telephonyManager::getMeid);
-            assertThrows(SecurityException.class, telephonyManager::getSubscriberId);
-            assertThrows(SecurityException.class, telephonyManager::getSimSerialNumber);
-            assertThrows(SecurityException.class, telephonyManager::getNai);
-            assertThrows(SecurityException.class, Build::getSerial);
-        } else {
-            assertNull(telephonyManager.getDeviceId());
-            assertNull(telephonyManager.getImei());
-            assertNull(telephonyManager.getMeid());
-            assertNull(telephonyManager.getSubscriberId());
-            assertNull(telephonyManager.getSimSerialNumber());
-            assertNull(telephonyManager.getNai());
-            assertNull(Build.getSerial());
+
+        boolean mayReturnNull = !hasTelephonyFeature;
+
+        assertAccessDenied(telephonyManager::getDeviceId, mayReturnNull);
+        assertAccessDenied(telephonyManager::getImei, mayReturnNull);
+        assertAccessDenied(telephonyManager::getMeid, mayReturnNull);
+        assertAccessDenied(telephonyManager::getSubscriberId, mayReturnNull);
+        assertAccessDenied(telephonyManager::getSimSerialNumber, mayReturnNull);
+        assertAccessDenied(telephonyManager::getNai, mayReturnNull);
+        assertAccessDenied(Build::getSerial, mayReturnNull);
+    }
+
+    private static <T> void assertAccessDenied(ThrowingProvider<T> provider,
+            boolean mayReturnNull) {
+        try {
+            T object = provider.get();
+            if (mayReturnNull) {
+                assertNull(object);
+            } else {
+                fail("Expected SecurityException, received " + object);
+            }
+        } catch (SecurityException ignored) {
+            // assertion succeeded
+        } catch (Throwable th) {
+            fail("Expected SecurityException but was: " + th);
         }
     }
+
+    private interface ThrowingProvider<T> {
+        T get() throws Throwable;
+    }
 }
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp b/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
index 34040d9..70d59d6 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
@@ -35,7 +35,6 @@
         "compatibility-device-util-axt",
         "androidx.test.rules",
         "cts-security-test-support-library",
-        "testng",
         "truth-prebuilt",
         "androidx.legacy_legacy-support-v4",
     ],
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceIdentifiersTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceIdentifiersTest.java
index 2370cd0..296cf6e 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceIdentifiersTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceIdentifiersTest.java
@@ -15,8 +15,6 @@
  */
 package com.android.cts.deviceowner;
 
-import static org.testng.Assert.assertThrows;
-
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.Build;
@@ -35,7 +33,7 @@
             "An unexpected value was received by the device owner with the READ_PHONE_STATE "
                     + "permission when invoking %s";
 
-    public void testDeviceOwnerCanGetDeviceIdentifiersWithPermission() throws Exception {
+    public void testDeviceOwnerCanGetDeviceIdentifiersWithPermission() {
         // The device owner with the READ_PHONE_STATE permission should have access to all device
         // identifiers. However since the TelephonyManager methods can return null this method
         // verifies that the device owner with the READ_PHONE_STATE permission receives the same
@@ -45,25 +43,25 @@
         try {
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getDeviceId"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getDeviceId()), telephonyManager.getDeviceId());
+                            TelephonyManager::getDeviceId), telephonyManager.getDeviceId());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getImei"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getImei()), telephonyManager.getImei());
+                            TelephonyManager::getImei), telephonyManager.getImei());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getMeid"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getMeid()), telephonyManager.getMeid());
+                            TelephonyManager::getMeid), telephonyManager.getMeid());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getSubscriberId"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getSubscriberId()), telephonyManager.getSubscriberId());
+                            TelephonyManager::getSubscriberId), telephonyManager.getSubscriberId());
             assertEquals(
                     String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getSimSerialNumber"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getSimSerialNumber()),
+                            TelephonyManager::getSimSerialNumber),
                     telephonyManager.getSimSerialNumber());
             assertEquals(
                     String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "getNai"),
                     ShellIdentityUtils.invokeMethodWithShellPermissions(telephonyManager,
-                            (tm) -> tm.getNai()), telephonyManager.getNai());
+                            TelephonyManager::getNai), telephonyManager.getNai());
             assertEquals(String.format(DEVICE_ID_WITH_PERMISSION_ERROR_MESSAGE, "Build#getSerial"),
                     ShellIdentityUtils.invokeStaticMethodWithShellPermissions(Build::getSerial),
                     Build.getSerial());
@@ -86,7 +84,7 @@
         }
     }
 
-    public void testDeviceOwnerCannotGetDeviceIdentifiersWithoutPermission() throws Exception {
+    public void testDeviceOwnerCannotGetDeviceIdentifiersWithoutPermission() {
         // The device owner without the READ_PHONE_STATE permission should still receive a
         // SecurityException when querying for device identifiers.
         TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
@@ -94,22 +92,35 @@
         // Allow the APIs to also return null if the telephony feature is not supported.
         boolean hasTelephonyFeature =
                 mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
-        if (hasTelephonyFeature) {
-            assertThrows(SecurityException.class, telephonyManager::getDeviceId);
-            assertThrows(SecurityException.class, telephonyManager::getImei);
-            assertThrows(SecurityException.class, telephonyManager::getMeid);
-            assertThrows(SecurityException.class, telephonyManager::getSubscriberId);
-            assertThrows(SecurityException.class, telephonyManager::getSimSerialNumber);
-            assertThrows(SecurityException.class, telephonyManager::getNai);
-            assertThrows(SecurityException.class, Build::getSerial);
-        } else {
-            assertNull(telephonyManager.getDeviceId());
-            assertNull(telephonyManager.getImei());
-            assertNull(telephonyManager.getMeid());
-            assertNull(telephonyManager.getSubscriberId());
-            assertNull(telephonyManager.getSimSerialNumber());
-            assertNull(telephonyManager.getNai());
-            assertNull(Build.getSerial());
+
+        boolean mayReturnNull = !hasTelephonyFeature;
+
+        assertAccessDenied(telephonyManager::getDeviceId, mayReturnNull);
+        assertAccessDenied(telephonyManager::getImei, mayReturnNull);
+        assertAccessDenied(telephonyManager::getMeid, mayReturnNull);
+        assertAccessDenied(telephonyManager::getSubscriberId, mayReturnNull);
+        assertAccessDenied(telephonyManager::getSimSerialNumber, mayReturnNull);
+        assertAccessDenied(telephonyManager::getNai, mayReturnNull);
+        assertAccessDenied(Build::getSerial, mayReturnNull);
+    }
+
+    private static <T> void assertAccessDenied(ThrowingProvider<T> provider,
+            boolean mayReturnNull) {
+        try {
+            T object = provider.get();
+            if (mayReturnNull) {
+                assertNull(object);
+            } else {
+                fail("Expected SecurityException, received " + object);
+            }
+        } catch (SecurityException ignored) {
+            // assertion succeeded
+        } catch (Throwable th) {
+            fail("Expected SecurityException but was: " + th);
         }
     }
+
+    private interface ThrowingProvider<T> {
+        T get() throws Throwable;
+    }
 }
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DeviceIdentifiersTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DeviceIdentifiersTest.java
index 68c4d3c..efa4a35 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DeviceIdentifiersTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DeviceIdentifiersTest.java
@@ -15,8 +15,6 @@
  */
 package com.android.cts.managedprofile;
 
-import static org.testng.Assert.assertThrows;
-
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.Build;
@@ -27,7 +25,7 @@
  */
 public class DeviceIdentifiersTest extends BaseManagedProfileTest {
 
-    public void testProfileOwnerOnPersonalDeviceCannotGetDeviceIdentifiers() throws Exception {
+    public void testProfileOwnerOnPersonalDeviceCannotGetDeviceIdentifiers() {
         // The profile owner with the READ_PHONE_STATE permission should still receive a
         // SecurityException when querying for device identifiers if it's not on an
         // organization-owned device.
@@ -36,22 +34,35 @@
         // Allow the APIs to also return null if the telephony feature is not supported.
         boolean hasTelephonyFeature =
                 mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
-        if (hasTelephonyFeature) {
-            assertThrows(SecurityException.class, telephonyManager::getDeviceId);
-            assertThrows(SecurityException.class, telephonyManager::getImei);
-            assertThrows(SecurityException.class, telephonyManager::getMeid);
-            assertThrows(SecurityException.class, telephonyManager::getSubscriberId);
-            assertThrows(SecurityException.class, telephonyManager::getSimSerialNumber);
-            assertThrows(SecurityException.class, telephonyManager::getNai);
-            assertThrows(SecurityException.class, Build::getSerial);
-        } else {
-            assertNull(telephonyManager.getDeviceId());
-            assertNull(telephonyManager.getImei());
-            assertNull(telephonyManager.getMeid());
-            assertNull(telephonyManager.getSubscriberId());
-            assertNull(telephonyManager.getSimSerialNumber());
-            assertNull(telephonyManager.getNai());
-            assertNull(Build.getSerial());
+
+        boolean mayReturnNull = !hasTelephonyFeature;
+
+        assertAccessDenied(telephonyManager::getDeviceId, mayReturnNull);
+        assertAccessDenied(telephonyManager::getImei, mayReturnNull);
+        assertAccessDenied(telephonyManager::getMeid, mayReturnNull);
+        assertAccessDenied(telephonyManager::getSubscriberId, mayReturnNull);
+        assertAccessDenied(telephonyManager::getSimSerialNumber, mayReturnNull);
+        assertAccessDenied(telephonyManager::getNai, mayReturnNull);
+        assertAccessDenied(Build::getSerial, mayReturnNull);
+    }
+
+    private static <T> void assertAccessDenied(ThrowingProvider<T> provider,
+            boolean mayReturnNull) {
+        try {
+            T object = provider.get();
+            if (mayReturnNull) {
+                assertNull(object);
+            } else {
+                fail("Expected SecurityException, received " + object);
+            }
+        } catch (SecurityException ignored) {
+            // assertion succeeded
+        } catch (Throwable th) {
+            fail("Expected SecurityException but was: " + th);
         }
     }
+
+    private interface ThrowingProvider<T> {
+        T get() throws Throwable;
+    }
 }
diff --git a/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService4.java b/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService4.java
index 6ae368c..43fb201 100644
--- a/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService4.java
+++ b/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService4.java
@@ -59,6 +59,8 @@
     static final String METHOD_EXIT = "exit";
     static final int EXIT_CODE = 123;
 
+    private static final int WAITFOR_SETTLE_DOWN = 2000;
+
     private static final int CMD_PID = 1;
     private Handler mHandler;
     private ContentProviderClient mProviderClient;
@@ -71,8 +73,10 @@
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
         sendPidBack(intent);
-        // perform the action after return from here.
-        mHandler.post(() -> doAction(intent));
+        // perform the action after return from here,
+        // make a delay, otherwise the system might try to restart the service
+        // if the process dies before the system realize it's asking for START_NOT_STICKY.
+        mHandler.postDelayed(() -> doAction(intent), WAITFOR_SETTLE_DOWN);
         return START_NOT_STICKY;
     }
 
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_04.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_04.java
index 25c1373..b0f0ddc 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_04.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_04.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -16,13 +16,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_04 extends SecurityTestCase {
 
     /**
      * b/26323455
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-04")
     public void testPocCVE_2016_2419() throws Exception {
         AdbUtils.runCommandLine("logcat -c" , getDevice());
@@ -34,6 +40,7 @@
     /**
     *  b/26324307
     */
+    @Test
     @SecurityTest(minPatchLevel = "2016-04")
     public void testPocCVE_2016_0844() throws Exception {
         AdbUtils.runPoc("CVE-2016-0844", getDevice(), 60);
@@ -42,6 +49,7 @@
     /**
      * b/26593930
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-04")
     public void testPocCVE_2016_2412() throws Exception {
         AdbUtils.runPocAssertNoCrashes("CVE-2016-2412", getDevice(), "system_server");
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_05.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_05.java
index d8df1c6..0895607 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_05.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_05.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,12 +17,18 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_05 extends SecurityTestCase {
     /**
      *  b/27555981
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-05")
     public void testPocCVE_2016_2460() throws Exception {
         AdbUtils.runCommandLine("logcat -c" , getDevice());
@@ -35,6 +41,7 @@
     /**
      *  b/27275324
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-05")
     public void testPocCVE_2015_1805() throws Exception {
       AdbUtils.runPoc("CVE-2015-1805", getDevice(), TIMEOUT_NONDETERMINISTIC);
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java
index b414a55..58c604e 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_06.java
@@ -1,27 +1,34 @@
 /**
-* 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.
-*/
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_06 extends SecurityTestCase {
     /**
      *  b/27661749
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-06")
     public void testPocCVE_2016_2482() throws Exception {
         AdbUtils.runPocAssertNoCrashes("CVE-2016-2482", getDevice(), "mediaserver");
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java
index b634645..4367a61 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -13,15 +13,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_07 extends SecurityTestCase {
     /**
      *  b/28740702
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-07")
     public void testPocCVE_2016_3818() throws Exception {
         AdbUtils.runPoc("CVE-2016-3818", getDevice(), 60);
@@ -30,6 +37,7 @@
     /**
      *  b/27890802
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-07")
     public void testPocCVE_2016_3746() throws Exception {
         AdbUtils.runPocAssertNoCrashes("CVE-2016-3746", getDevice(), "mediaserver");
@@ -38,6 +46,7 @@
     /**
      *  b/28557020
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-07")
     public void testPocCVE_2014_9803() throws Exception {
         AdbUtils.runPocAssertExitStatusNotVulnerable("CVE-2014-9803", getDevice(), 60);
@@ -46,6 +55,7 @@
     /**
      * b/27903498
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-07")
     public void testPocCVE_2016_3747() throws Exception {
         getOomCatcher().setHighMemoryTest();
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_09.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_09.java
index 3280a68..a253619 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_09.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_09.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -13,15 +13,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_09 extends SecurityTestCase {
     /**
      * b/27773913
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-09")
     public void testPocCVE_2016_2471() throws Exception {
         AdbUtils.runPoc("CVE-2016-2471", getDevice(), 60);
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_10.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_10.java
index 6daa385..d1550d2 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_10.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_10.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_10 extends SecurityTestCase {
 
     /**
      *  b/30204103
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-10")
     public void testPocCVE_2016_3913() throws Exception {
         AdbUtils.runPocAssertNoCrashes("CVE-2016-3913", getDevice(), "mediaserver");
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_11.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_11.java
index bb18b0d..60a15e6 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_11.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_11.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_11 extends SecurityTestCase {
 
     /**
      *  b/29149404
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2012_6702() throws Exception {
         AdbUtils.runCommandLine("logcat -c", getDevice());
@@ -35,6 +41,7 @@
     /**
      *  b/30904789
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2016_6730() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -45,6 +52,7 @@
     /**
      *  b/30906023
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2016_6731() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -55,6 +63,7 @@
     /**
      *  b/30906599
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2016_6732() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -65,6 +74,7 @@
     /**
      *  b/30906694
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2016_6733() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -75,6 +85,7 @@
     /**
      *  b/30907120
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2016_6734() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -85,6 +96,7 @@
     /**
      *  b/30907701
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2016_6735() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -95,6 +107,7 @@
     /**
      *  b/30953284
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-11")
     public void testPocCVE_2016_6736() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_12.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_12.java
index 65a6931..4e2031b 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_12.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_12.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,14 +17,20 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc16_12 extends SecurityTestCase {
 
     //Criticals
     /**
      *  b/31796940
      */
+    @Test
     @SecurityTest(minPatchLevel = "2016-12")
     public void testPocCVE_2016_8406() throws Exception {
         assertNotKernelPointer(() -> {
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java
index 107ac45..a7ae370 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,14 +17,20 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_01 extends SecurityTestCase {
 
     //Criticals
     /**
      *  b/31797770
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8425() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvhost-vic")) {
@@ -35,6 +41,7 @@
     /**
      *  b/31799206
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8426() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvhost-gpu")) {
@@ -45,6 +52,7 @@
     /**
      *  b/31799885
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8427() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvhost-gpu") ||
@@ -56,6 +64,7 @@
     /**
      *  b/31993456
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8428() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvmap")) {
@@ -66,6 +75,7 @@
     /**
      *  b/32160775
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8429() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvmap")) {
@@ -76,6 +86,7 @@
     /**
      *  b/32225180
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8430() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvhost-vic")) {
@@ -86,6 +97,7 @@
    /**
      *  b/32402179
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8431() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -96,6 +108,7 @@
     /**
      *  b/32447738
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8432() throws Exception {
         if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -106,6 +119,7 @@
     /**
      *  b/32125137
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8434() throws Exception {
         if(containsDriver(getDevice(), "/dev/kgsl-3d0")) {
@@ -117,6 +131,7 @@
     /**
      *  b/31668540
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2016_8460() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvmap")) {
@@ -128,6 +143,7 @@
     /**
      *  b/32255299
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-01")
     public void testPocCVE_2017_0386() throws Exception {
         AdbUtils.runPocAssertExitStatusNotVulnerable("CVE-2017-0386", getDevice(), 60);
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_02.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_02.java
index f9d4e1d..3f94a62 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_02.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_02.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,30 +17,39 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_02 extends SecurityTestCase {
-  /**
-   *  b/32799236
-   */
-  @SecurityTest(minPatchLevel = "2017-02")
-  public void testPocCVE_2017_0426() throws Exception {
-      AdbUtils.runCommandLine("logcat -c", getDevice());
-      AdbUtils.runPoc("CVE-2017-0426", getDevice(), 60);
-      String logcatOut = AdbUtils.runCommandLine("logcat -d", getDevice());
-      assertNotMatchesMultiLine("Bugreports file in wrong path", logcatOut);
-  }
+    /**
+     *  b/32799236
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2017-02")
+    public void testPocCVE_2017_0426() throws Exception {
+        AdbUtils.runCommandLine("logcat -c", getDevice());
+        AdbUtils.runPoc("CVE-2017-0426", getDevice(), 60);
+        String logcatOut = AdbUtils.runCommandLine("logcat -d", getDevice());
+        assertNotMatchesMultiLine("Bugreports file in wrong path", logcatOut);
+    }
 
-   /**
-   *  b/32706020
-   */
-  @SecurityTest(minPatchLevel = "2017-02")
-  public void testPocCVE_2017_0415() throws Exception {
-      AdbUtils.runPocAssertNoCrashes("CVE-2017-0415", getDevice(), "mediaserver");
-  }
+    /**
+     *  b/32706020
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2017-02")
+    public void testPocCVE_2017_0415() throws Exception {
+        AdbUtils.runPocAssertNoCrashes("CVE-2017-0415", getDevice(), "mediaserver");
+    }
 
     /**
      *  b/31799863
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-02")
     public void testPocCVE_2016_8482() throws Exception {
         if(containsDriver(getDevice(), "/dev/nvmap")) {
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java
index f61e843..3dacc96 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -16,14 +16,22 @@
 
 package android.security.cts;
 
-import android.platform.test.annotations.SecurityTest;
 import java.util.concurrent.Callable;
 
+import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_03 extends SecurityTestCase {
 
     /**
      *  b/31824853
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-03")
     public void testPocCVE_2016_8479() throws Exception {
         if (containsDriver(getDevice(), "/dev/kgsl-3d0")) {
@@ -37,6 +45,7 @@
     /**
      *  b/33940449
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-03")
     public void testPocCVE_2017_0508() throws Exception {
         if (containsDriver(getDevice(), "/dev/ion") &&
@@ -51,6 +60,7 @@
     /**
      *  b/33899363
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-03")
     public void testPocCVE_2017_0333() throws Exception {
         if (containsDriver(getDevice(), "/dev/dri/renderD128")) {
@@ -63,6 +73,7 @@
     /**
      *  b/33245849
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-03")
     public void testPocCVE_2017_0334() throws Exception {
         if (containsDriver(getDevice(), "/dev/dri/renderD129")) {
@@ -92,6 +103,7 @@
     /**
      * b/32707507
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-03")
     public void testPocCVE_2017_0479() throws Exception {
         AdbUtils.runPocAssertNoCrashes("CVE-2017-0479", getDevice(), "audioserver");
@@ -100,6 +112,7 @@
     /*
      *  b/33178389
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-03")
     public void testPocCVE_2017_0490() throws Exception {
         String bootCountBefore =
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_04.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_04.java
index 248e257..f5c8fe3 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_04.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_04.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,42 +17,51 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_04 extends SecurityTestCase {
 
-  /**
-   * b/32342065
-   */
-  @SecurityTest(minPatchLevel = "2017-04")
-  public void testPocCVE_2017_0553() throws Exception {
-    // Error code of 139 represents segmentation fault
-    getDevice().executeShellCommand("chmod +x /data/local/tmp/CVE-2017-0553");
-    assertFalse("Segfault found",
-        AdbUtils.runCommandGetExitCode("/data/local/tmp/CVE-2017-0553", getDevice())==139);
-  }
+    /**
+     * b/32342065
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2017-04")
+    public void testPocCVE_2017_0553() throws Exception {
+      // Error code of 139 represents segmentation fault
+      getDevice().executeShellCommand("chmod +x /data/local/tmp/CVE-2017-0553");
+      assertFalse("Segfault found",
+          AdbUtils.runCommandGetExitCode("/data/local/tmp/CVE-2017-0553", getDevice())==139);
+    }
 
-  /**
-   * b/72460737
-   */
-  @SecurityTest(minPatchLevel = "2017-04")
-  public void testPocCVE_2014_3145() throws Exception {
-    assertFalse("VULNERABLE DEVICE DETECTED",
-                AdbUtils.runPocCheckExitCode("CVE-2014-3145", getDevice(), 60));
-  }
+    /**
+     * b/72460737
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2017-04")
+    public void testPocCVE_2014_3145() throws Exception {
+      assertFalse("VULNERABLE DEVICE DETECTED",
+                  AdbUtils.runPocCheckExitCode("CVE-2014-3145", getDevice(), 60));
+    }
 
-  /**
-   * b/32813456
-   */
-  @SecurityTest(minPatchLevel = "2017-04")
-  public void testPocCVE_2016_10229() throws Exception {
-    String out = AdbUtils.runPoc("CVE-2016-10229", getDevice());
-    assertNotMatchesMultiLine("OVERWRITE", out);
-  }
+    /**
+     * b/32813456
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2017-04")
+    public void testPocCVE_2016_10229() throws Exception {
+      String out = AdbUtils.runPoc("CVE-2016-10229", getDevice());
+      assertNotMatchesMultiLine("OVERWRITE", out);
+    }
 
     /**
      * b/33621647
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-04")
     public void testPocCVE_2017_0477() throws Exception {
         AdbUtils.pushResource("/CVE-2017-0477.gif", "/data/local/tmp/CVE-2017-0477.gif",
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
index 70e224a..1ec6d89 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -16,16 +16,23 @@
 
 package android.security.cts;
 
-import android.platform.test.annotations.SecurityTest;
 import java.util.Arrays;
 import java.util.concurrent.Callable;
 
-@SecurityTest
+import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_05 extends SecurityTestCase {
 
     /**
      *  b/34277115
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-05")
     public void testPocCVE_2017_0630() throws Exception {
         if (containsDriver(getDevice(), "/sys/kernel/debug/tracing/printk_formats")) {
@@ -54,6 +61,7 @@
     /*
      * CVE-2016-5862
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-05")
     public void testPocCVE_2016_5862() throws Exception {
         if (containsDriver(getDevice(), "/dev/snd/controlC0")) {
@@ -64,6 +72,7 @@
     /**
      * CVE-2016-5867
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-05")
     public void testPocCVE_2016_5867() throws Exception {
         if (containsDriver(getDevice(), "/dev/snd/controlC0")) {
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_06.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_06.java
index c2c3e29..1f7e5e9 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_06.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_06.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,14 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
-import java.util.concurrent.TimeUnit;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_06 extends SecurityTestCase {
 
     /**
      * b/36392138
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-06")
     public void testPocCVE_2017_0647() throws Exception {
         AdbUtils.pushResource("/CVE-2017-0647.zip", "/data/local/tmp/CVE-2017-0647.zip",
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_07.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_07.java
index 29b7a39..d3a086a 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_07.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_07.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_07 extends SecurityTestCase {
 
     /**
      * b/35443725
      **/
+    @Test
     @SecurityTest(minPatchLevel = "2017-07")
     public void testPocCVE_2016_2109() throws Exception {
       assertFalse("Overallocation detected!",
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_09.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_09.java
index 1659397..de7381e 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_09.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_09.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_09 extends SecurityTestCase {
 
     /**
      * b/63852675
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-09")
     public void testPocCve_2017_6983() throws Exception {
       // Error code of 139 represents segmentation fault
@@ -53,14 +59,15 @@
                                       )==139);
     }
 
-  /**
-   * b/38195738
-   * b/36590192
-   */
-  @SecurityTest(minPatchLevel = "2017-09")
-  public void testPocBug_38195738() throws Exception {
-    if(containsDriver(getDevice(), "/dev/kgsl-3d0")) {
-      AdbUtils.runPocNoOutput("Bug-38195738", getDevice(), 60);
+    /**
+     * b/38195738
+     * b/36590192
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2017-09")
+    public void testPocBug_38195738() throws Exception {
+        if(containsDriver(getDevice(), "/dev/kgsl-3d0")) {
+            AdbUtils.runPocNoOutput("Bug-38195738", getDevice(), 60);
+        }
     }
-  }
 }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java
index 3fbf3d2..e592d0f 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_11 extends SecurityTestCase {
 
     /**
      * b/36075131
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-11")
     public void testPocCVE_2017_0859() throws Exception {
         AdbUtils.runCommandLine("logcat -c", getDevice());
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_12.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_12.java
index fed0ab5..71607c8 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_12.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_12.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_12 extends SecurityTestCase {
 
     /**
      * b/38045794
      */
+    @Test
     @SecurityTest(minPatchLevel = "2017-12")
     public void testPocCVE_2017_6262() throws Exception {
         if(containsDriver(getDevice(),"/dev/dri/renderD128")) {
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_02.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_02.java
index c9f48f9..377e219 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_02.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_02.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,26 +17,33 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_02 extends SecurityTestCase {
 
     /**
      * b/68953950
      */
-     @SecurityTest(minPatchLevel = "2018-02")
-     public void testPocCVE_2017_13232() throws Exception {
-       AdbUtils.runCommandLine("logcat -c" , getDevice());
-       AdbUtils.runPocNoOutput("CVE-2017-13232", getDevice(), 60);
-       String logcatOutput = AdbUtils.runCommandLine("logcat -d", getDevice());
-       assertNotMatchesMultiLine("APM_AudioPolicyManager: getOutputForAttr\\(\\) " +
-                                 "invalid attributes: usage=.{1,15} content=.{1,15} " +
-                                 "flags=.{1,15} tags=\\[A{256,}\\]", logcatOutput);
-     }
+    @Test
+    @SecurityTest(minPatchLevel = "2018-02")
+    public void testPocCVE_2017_13232() throws Exception {
+        AdbUtils.runCommandLine("logcat -c" , getDevice());
+        AdbUtils.runPocNoOutput("CVE-2017-13232", getDevice(), 60);
+        String logcatOutput = AdbUtils.runCommandLine("logcat -d", getDevice());
+        assertNotMatchesMultiLine("APM_AudioPolicyManager: getOutputForAttr\\(\\) " +
+                                  "invalid attributes: usage=.{1,15} content=.{1,15} " +
+                                  "flags=.{1,15} tags=\\[A{256,}\\]", logcatOutput);
+    }
 
     /**
      *  b/65853158
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-02")
     public void testPocCVE_2017_13273() throws Exception {
         AdbUtils.runCommandLine("dmesg -c" ,getDevice());
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_03.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_03.java
index f916d7e..d5e2b90 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_03.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_03.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,14 +17,21 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_03 extends SecurityTestCase {
 
-  /**
-   * CVE-2017-13253
-   */
-  @SecurityTest(minPatchLevel = "2018-03")
-  public void testPocCVE_2017_13253() throws Exception {
-    AdbUtils.runPocAssertExitStatusNotVulnerable("CVE-2017-13253", getDevice(), 300);
-  }
+    /**
+     * b/71389378
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2018-03")
+    public void testPocCVE_2017_13253() throws Exception {
+        AdbUtils.runPocAssertExitStatusNotVulnerable("CVE-2017-13253", getDevice(), 300);
+    }
 }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_04.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_04.java
index 99a4692..44b0d89 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_04.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_04.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,14 +17,20 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
 import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_04 extends SecurityTestCase {
     /**
      * b/69683251
      * Does not require root but must be a hostside test to avoid
      * a race condition
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-04")
     public void testPocCVE_2017_13286() throws Exception {
         getOomCatcher().setHighMemoryTest();
@@ -35,6 +41,7 @@
      * b/69634768
      * Does not require root but must be a hostside test to avoid a race condition
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-04")
     public void testPocCVE_2017_13288() throws Exception {
         getOomCatcher().setHighMemoryTest();
@@ -45,6 +52,7 @@
      * b/70398564
      * Does not require root but must be a hostside test to avoid a race condition
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-04")
     public void testPocCVE_2017_13289() throws Exception {
         getOomCatcher().setHighMemoryTest();
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_05.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_05.java
index 69a4ed5..6b51f0a 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_05.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_05.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,14 +17,20 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_05 extends SecurityTestCase {
     /**
      * b/70721937
      * Does not require root but must be a hostside test to avoid a race
      * condition
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-05")
     public void testPocCVE_2017_13315() throws Exception {
         getOomCatcher().setHighMemoryTest();
@@ -35,6 +41,7 @@
      * b/73085795
      * Does not require root but must be a hostside test to avoid a race condition
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-05")
     public void testPocCVE_2017_13312() throws Exception {
         getOomCatcher().setHighMemoryTest();
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_06.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_06.java
index b270c69..c0aab3b 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_06.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_06.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,31 +17,38 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_06 extends SecurityTestCase {
 
-  /**
-   * CVE-2018-5884
-   */
-  @SecurityTest(minPatchLevel = "2018-06")
-  public void testPocCVE_2018_5884() throws Exception {
-    String wfd_service = AdbUtils.runCommandLine(
-        "pm list package com.qualcomm.wfd.service", getDevice());
-    if (wfd_service.contains("com.qualcomm.wfd.service")) {
-      String result = AdbUtils.runCommandLine(
-          "am broadcast -a qualcomm.intent.action.WIFI_DISPLAY_BITRATE --ei format 3 --ei value 32",
-          getDevice());
-      assertNotMatchesMultiLine("Broadcast completed", result);
+    /**
+     * CVE-2018-5884
+     */
+    @Test
+    @SecurityTest(minPatchLevel = "2018-06")
+    public void testPocCVE_2018_5884() throws Exception {
+        String wfd_service = AdbUtils.runCommandLine(
+                "pm list package com.qualcomm.wfd.service", getDevice());
+        if (wfd_service.contains("com.qualcomm.wfd.service")) {
+            String result = AdbUtils.runCommandLine(
+                    "am broadcast -a qualcomm.intent.action.WIFI_DISPLAY_BITRATE --ei format 3 --ei value 32",
+            getDevice());
+            assertNotMatchesMultiLine("Broadcast completed", result);
+        }
     }
-  }
 
-  /**
-   *  b/73172817
-   */
-  @SecurityTest
-  public void testPocCVE_2018_9344() throws Exception {
-      AdbUtils.runPocAssertNoCrashes(
-          "CVE-2018-9344", getDevice(), "android\\.hardware\\.drm@\\d\\.\\d-service");
-  }
+    /**
+     *  b/73172817
+     */
+    @Test
+    @SecurityTest
+    public void testPocCVE_2018_9344() throws Exception {
+        AdbUtils.runPocAssertNoCrashes("CVE-2018-9344", getDevice(),
+                "android\\.hardware\\.cas@\\d+?\\.\\d+?-service");
+    }
 }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_07.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_07.java
index 173508c..172f0fc 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_07.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_07.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -14,17 +14,22 @@
  * limitations under the License.
  */
 
-
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_07 extends SecurityTestCase {
 
    /**
     * b/76221123
     */
+    @Test
     @SecurityTest(minPatchLevel = "2018-07")
     public void testPocCVE_2018_9424() throws Exception {
         AdbUtils.runPocAssertNoCrashes(
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_10.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_10.java
index dfc3de0..ef5b726 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_10.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_10.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_10 extends SecurityTestCase {
 
     /**
      *  b/111641492
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-10")
     public void testPocCVE_2018_9515() throws Exception {
         AdbUtils.runCommandLine("rm /sdcard/Android/data/CVE-2018-9515", getDevice());
@@ -40,6 +46,7 @@
     /**
      *  b/111274046
      */
+    @Test
     @SecurityTest
     public void testPocCVE_2018_9490() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("CVE-2018-9490", getDevice());
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_11.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_11.java
index 81911ed..9699b17 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc18_11.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_11.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,15 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
 import static org.junit.Assert.*;
 
-@SecurityTest
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc18_11 extends SecurityTestCase {
 
     /**
      *  b/111330641
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-11")
     public void testPocCVE_2018_9525() throws Exception {
         assertTrue(AdbUtils.runCommandGetExitCode(
@@ -35,6 +39,7 @@
     /**
      *  b/113027383
      */
+    @Test
     @SecurityTest(minPatchLevel = "2018-11")
     public void testPocCVE_2018_9539() throws Exception {
         AdbUtils.runPocAssertExitStatusNotVulnerable("CVE-2018-9539", getDevice(), 300);
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java
index 520c9fc..5977b4a 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_03.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,16 +17,18 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
-import static org.junit.Assert.assertFalse;
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc19_03 extends SecurityTestCase {
     /**
      * b/115739809
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-03")
     public void testPocBug_115739809() throws Exception {
         assertFalse(AdbUtils.runPocCheckExitCode("Bug-115739809", getDevice(), 30));
@@ -35,6 +37,7 @@
     /**
      * b/116855682
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-03")
     public void testPocCVE_2019_2025() throws Exception {
         AdbUtils.runPocNoOutput("CVE-2019-2025", getDevice(), 300);
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_05.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_05.java
index b9be0af..fd3b638 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_05.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_05.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -18,15 +18,18 @@
 
 import android.platform.test.annotations.SecurityTest;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.*;
 
-@SecurityTest
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc19_05 extends SecurityTestCase {
 
     /**
      * b/129556464
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-05")
     public void testPocCVE_2019_2052() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("CVE-2019-2052", getDevice());
@@ -36,6 +39,7 @@
     /**
      * b/129556111
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-05")
     public void testPocCVE_2019_2045() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("CVE-2019-2045", getDevice());
@@ -45,6 +49,7 @@
     /*
      * b/129556718
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-05")
     public void testPocCVE_2019_2047() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("CVE-2019-2047", getDevice());
@@ -54,6 +59,7 @@
     /**
      * CVE-2019-2257
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-05")
     public void testPocCVE_2019_2257() throws Exception {
         String result = AdbUtils.runCommandLine(
@@ -65,6 +71,7 @@
     /**
      * b/117555811
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-05")
     public void testPocCVE_2019_2051() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("CVE-2019-2051", getDevice());
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_06.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_06.java
index c3651fb..67986fe 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_06.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_06.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc19_06 extends SecurityTestCase {
 
     /**
      * b/129556445
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-06")
     public void testPocCVE_2019_2097() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("CVE-2019-2097", getDevice());
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_07.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_07.java
index 77400a7..3d729f6 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_07.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_07.java
@@ -16,15 +16,19 @@
 
 package android.security.cts;
 
-import static org.junit.Assert.assertTrue;
-
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc19_07 extends SecurityTestCase {
     /**
      * Bug-137282168
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-07")
     public void testPocBug_137282168() throws Exception {
         assertFalse("Heap buffer overflow encountered",
@@ -34,6 +38,7 @@
     /**
      * Bug-137878930
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-07")
     public void testPocBug_137878930() throws Exception {
         assertFalse("Heap use after free encountered",
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_08.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_08.java
index b7fd2f2..c2ce29d 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_08.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_08.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -17,13 +17,19 @@
 package android.security.cts;
 
 import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-@SecurityTest
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc19_08 extends SecurityTestCase {
 
     /**
      * b/129556445
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-08")
     public void testPocCVE_2019_2130() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("CVE-2019-2130", getDevice());
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java
index 07257fa..a79e2b1 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -18,15 +18,18 @@
 
 import android.platform.test.annotations.SecurityTest;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.*;
 
-@SecurityTest
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc19_11 extends SecurityTestCase {
 
     /**
      * b/138441919
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-11")
     public void testPocBug_138441919() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("bug_138441919", getDevice());
@@ -36,6 +39,7 @@
     /**
      * b/139806216
      */
+    @Test
     @SecurityTest(minPatchLevel = "2019-11")
     public void testPocBug_139806216() throws Exception {
         int code = AdbUtils.runProxyAutoConfig("bug_139806216", getDevice());
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java b/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
index ee38deb..a605358 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
@@ -16,19 +16,27 @@
 
 package android.security.cts;
 
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.device.NativeDevice;
-import com.android.tradefed.testtype.DeviceTestCase;
 import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.ddmlib.Log;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
 
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
-import com.android.ddmlib.Log;
 import java.util.concurrent.Callable;
 import java.math.BigInteger;
 
-public class SecurityTestCase extends DeviceTestCase {
+import static org.junit.Assert.*;
+import static org.junit.Assume.*;
+
+public class SecurityTestCase extends BaseHostJUnit4Test {
 
     private static final String LOG_TAG = "SecurityTestCase";
     private static final int RADIX_HEX = 16;
@@ -45,10 +53,8 @@
     /**
      * Waits for device to be online, marks the most recent boottime of the device
      */
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
-
         getDevice().waitForDeviceAvailable();
         getDevice().disableAdbRoot();
         updateKernelStartTime();
@@ -62,7 +68,7 @@
      * Makes sure the phone is online, and the ensure the current boottime is within 2 seconds
      * (due to rounding) of the previous boottime to check if The phone has crashed.
      */
-    @Override
+    @After
     public void tearDown() throws Exception {
         oomCatcher.stop(getDevice().getSerialNumber());
 
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
index 4dcb055..03a49b7 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 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
@@ -18,10 +18,15 @@
 
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.log.LogUtil.CLog;
-import android.platform.test.annotations.SecurityTest;
-import java.util.regex.Pattern;
 
-@SecurityTest
+import android.platform.test.annotations.SecurityTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import static org.junit.Assert.*;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
 public class TestMedia extends SecurityTestCase {
 
 
@@ -30,7 +35,6 @@
      * existing test methods
      ******************************************************************************/
 
-
     /******************************************************************************
      * To prevent merge conflicts, add tests for O below this comment, before any
      * existing test methods
diff --git a/tests/BlobStore/src/com/android/cts/blob/BlobStoreManagerTest.java b/tests/BlobStore/src/com/android/cts/blob/BlobStoreManagerTest.java
index ded2f52..7c39970 100644
--- a/tests/BlobStore/src/com/android/cts/blob/BlobStoreManagerTest.java
+++ b/tests/BlobStore/src/com/android/cts/blob/BlobStoreManagerTest.java
@@ -134,12 +134,12 @@
     }
 
     @Test
-    public void testDeleteSession_invalidArguments() throws Exception {
-        assertThrows(IllegalArgumentException.class, () -> mBlobStoreManager.openSession(-1));
+    public void testAbandonSession_invalidArguments() throws Exception {
+        assertThrows(IllegalArgumentException.class, () -> mBlobStoreManager.abandonSession(-1));
     }
 
     @Test
-    public void testDeleteSession() throws Exception {
+    public void testAbandonSession() throws Exception {
         final DummyBlobData blobData = new DummyBlobData(mContext);
         blobData.prepare();
         try {
@@ -148,7 +148,7 @@
             // Verify that session can be opened.
             assertThat(mBlobStoreManager.openSession(sessionId)).isNotNull();
 
-            mBlobStoreManager.deleteSession(sessionId);
+            mBlobStoreManager.abandonSession(sessionId);
             // Verify that trying to open session after it is deleted will throw.
             assertThrows(SecurityException.class, () -> mBlobStoreManager.openSession(sessionId));
         } finally {
@@ -205,7 +205,7 @@
     }
 
     @Test
-    public void testAbandonSession() throws Exception {
+    public void testOpenSessionAndAbandon() throws Exception {
         final DummyBlobData blobData = new DummyBlobData(mContext);
         blobData.prepare();
         try {
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java
index ca59377..b2fc2c5 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityTextActionTest.java
@@ -495,9 +495,9 @@
                 EXTRA_DATA_RENDERING_INFO_KEY , arg));
         assertNotNull(info.getExtraRenderingInfo());
         extraRenderingInfo = info.getExtraRenderingInfo();
-        assertNotNull(extraRenderingInfo.getLayoutParams());
-        assertEquals(expectedWidthInPx, extraRenderingInfo.getLayoutParams().getWidth());
-        assertEquals(expectedHeightInPx, extraRenderingInfo.getLayoutParams().getHeight());
+        assertNotNull(extraRenderingInfo.getLayoutSize());
+        assertEquals(expectedWidthInPx, extraRenderingInfo.getLayoutSize().getWidth());
+        assertEquals(expectedHeightInPx, extraRenderingInfo.getLayoutSize().getHeight());
         assertEquals(expectedTextSize, extraRenderingInfo.getTextSizeInPx(), 0f);
         assertEquals(TypedValue.COMPLEX_UNIT_DIP, extraRenderingInfo.getTextSizeUnit());
 
@@ -523,8 +523,8 @@
         assertTrue("Refresh failed", info.refreshWithExtraData(
                 EXTRA_DATA_RENDERING_INFO_KEY, new Bundle()));
         assertNotNull(info.getExtraRenderingInfo());
-        assertNotNull(info.getExtraRenderingInfo().getLayoutParams());
-        final Size size = info.getExtraRenderingInfo().getLayoutParams();
+        assertNotNull(info.getExtraRenderingInfo().getLayoutSize());
+        final Size size = info.getExtraRenderingInfo().getLayoutSize();
         assertEquals(ViewGroup.LayoutParams.MATCH_PARENT, size.getWidth());
         assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, size.getHeight());
     }
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java
index eb5e2b4..3e253a7 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java
@@ -261,22 +261,29 @@
             // Window manager changed the behavior of focused window at a virtual display. A window
             // at virtual display needs to be touched then it becomes to be focused one. Adding this
             // touch event on the activity window of the virtual display to pass this test case.
-            final DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics();
-            final int xOnScreen = displayMetrics.widthPixels / 2;
-            final int yOnScreen = displayMetrics.heightPixels / 2;
-            final long downEventTime = SystemClock.uptimeMillis();
-            final MotionEvent downEvent = MotionEvent.obtain(downEventTime, downEventTime,
-                    MotionEvent.ACTION_DOWN, xOnScreen, yOnScreen, 0);
-            downEvent.setSource(InputDevice.SOURCE_TOUCHSCREEN);
-            downEvent.setDisplayId(virtualDisplayId);
-            sUiAutomation.injectInputEvent(downEvent, true);
+            sUiAutomation.executeAndWaitForEvent(
+                    () -> {
+                        final DisplayMetrics displayMetrics =
+                                mActivity.getResources().getDisplayMetrics();
+                        final int xOnScreen = displayMetrics.widthPixels / 2;
+                        final int yOnScreen = displayMetrics.heightPixels / 2;
+                        final long downEventTime = SystemClock.uptimeMillis();
+                        final MotionEvent downEvent = MotionEvent.obtain(downEventTime,
+                                downEventTime, MotionEvent.ACTION_DOWN, xOnScreen, yOnScreen, 0);
+                        downEvent.setSource(InputDevice.SOURCE_TOUCHSCREEN);
+                        downEvent.setDisplayId(virtualDisplayId);
+                        sUiAutomation.injectInputEvent(downEvent, true);
 
-            final long upEventTime = downEventTime + 10;
-            final MotionEvent upEvent = MotionEvent.obtain(downEventTime, upEventTime,
-                    MotionEvent.ACTION_UP, xOnScreen, yOnScreen, 0);
-            upEvent.setSource(InputDevice.SOURCE_TOUCHSCREEN);
-            upEvent.setDisplayId(virtualDisplayId);
-            sUiAutomation.injectInputEvent(upEvent, true);
+                        final long upEventTime = downEventTime + 10;
+                        final MotionEvent upEvent = MotionEvent.obtain(downEventTime, upEventTime,
+                                MotionEvent.ACTION_UP, xOnScreen, yOnScreen, 0);
+                        upEvent.setSource(InputDevice.SOURCE_TOUCHSCREEN);
+                        upEvent.setDisplayId(virtualDisplayId);
+                        sUiAutomation.injectInputEvent(upEvent, true);
+                    },
+                    filterWindowsChangedWithChangeTypes(WINDOWS_CHANGE_FOCUSED |
+                            WINDOWS_CHANGE_ACTIVE),
+                    TIMEOUT_ASYNC_PROCESSING);
 
             final CharSequence activityTitle = getActivityTitle(sInstrumentation,
                     activityOnVirtualDisplay);
@@ -428,4 +435,4 @@
         });
         return params;
     }
-}
\ No newline at end of file
+}
diff --git a/tests/app/AppExitTest/AndroidTest.xml b/tests/app/AppExitTest/AndroidTest.xml
index 2e2db13..0fdb0a7 100644
--- a/tests/app/AppExitTest/AndroidTest.xml
+++ b/tests/app/AppExitTest/AndroidTest.xml
@@ -29,7 +29,7 @@
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
         <option name="package" value="android.app.cts.appexit" />
-        <option name="runtime-hint" value="1m9s" />
+        <option name="runtime-hint" value="2m9s" />
         <option name="hidden-api-checks" value="false"/>
     </test>
 
diff --git a/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java b/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java
index 549419c..b815cc0 100644
--- a/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java
+++ b/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java
@@ -26,7 +26,6 @@
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.os.Bundle;
-import android.os.Debug;
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.Looper;
@@ -42,6 +41,7 @@
 import android.system.OsConstants;
 import android.test.InstrumentationTestCase;
 import android.text.TextUtils;
+import android.util.DebugUtils;
 import android.util.Log;
 
 import com.android.compatibility.common.util.ShellIdentityUtils;
@@ -472,6 +472,9 @@
         // Start a process and block its main thread
         startService(ACTION_ANR, STUB_SERVICE_NAME, false, false);
 
+        // Sleep for a while to make sure it's already blocking its main thread.
+        sleep(WAITFOR_MSEC);
+
         Monitor monitor = new Monitor(mInstrumentation);
 
         Intent intent = new Intent();
@@ -514,13 +517,17 @@
         // Start a process and do nothing
         startService(ACTION_FINISH, STUB_SERVICE_NAME, false, false);
 
+        // Enable high frequency memory sampling
+        executeShellCmd("dumpsys procstats --start-testing");
+        // Sleep for a while to wait for the sampling of memory info
+        sleep(10000);
+        // Stop the high frequency memory sampling
+        executeShellCmd("dumpsys procstats --stop-testing");
         // Get the memory info from it.
-        Debug.MemoryInfo[] meminfo =
-                ShellIdentityUtils.invokeMethodWithShellPermissions(
-                        new int[] {mStubPackagePid},
-                        mActivityManager::getProcessMemoryInfo,
-                        android.Manifest.permission.REAL_GET_TASKS);
-        assertTrue(meminfo != null && meminfo.length == 1);
+        String dump = executeShellCmd("dumpsys activity processes " + STUB_PACKAGE_NAME);
+        assertNotNull(dump);
+        final String lastPss = extractMemString(dump, " lastPss=", ' ');
+        final String lastRss = extractMemString(dump, " lastRss=", '\n');
 
         // Disable the compat feature
         executeShellCmd("am compat disable " + PackageManager.FILTER_APPLICATION_QUERY
@@ -541,8 +548,19 @@
                 ApplicationExitInfo.REASON_OTHER, null, "PlatformCompat overrides", now, now2);
 
         // Also verify that we get the expected meminfo
-        assertEquals(meminfo[0].getTotalPss(), info.getPss());
-        assertEquals(meminfo[0].getTotalRss(), info.getRss());
+        assertEquals(lastPss, DebugUtils.sizeValueToString(
+                info.getPss() * 1024, new StringBuilder()));
+        assertEquals(lastRss, DebugUtils.sizeValueToString(
+                info.getRss() * 1024, new StringBuilder()));
+    }
+
+    private String extractMemString(String dump, String prefix, char nextSep) {
+        int start = dump.indexOf(prefix);
+        assertTrue(start >= 0);
+        start += prefix.length();
+        int end = dump.indexOf(nextSep, start);
+        assertTrue(end > start);
+        return dump.substring(start, end);
     }
 
     public void testPermissionChange() throws Exception {
diff --git a/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
index 0a3c795..b105b92 100644
--- a/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
+++ b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
@@ -1863,7 +1863,7 @@
             CommandReceiver.sendCommand(mContext, CommandReceiver.COMMAND_BIND_SERVICE,
                     STUB_PACKAGE_NAME, mAppInfo[0].packageName, 0, null);
             mWatchers[0].waitFor(WatchUidRunner.CMD_PROCSTATE, WatchUidRunner.STATE_BOUND_TOP,
-                    new Integer(PROCESS_CAPABILITY_ALL_IMPLICIT));
+                    new Integer(PROCESS_CAPABILITY_NONE));
 
             // Bind Stub -> App 1, include capability (TOP)
             Bundle bundle = new Bundle();
diff --git a/tests/app/src/android/app/cts/NotificationManagerTest.java b/tests/app/src/android/app/cts/NotificationManagerTest.java
index 459e01b..73e02c2 100644
--- a/tests/app/src/android/app/cts/NotificationManagerTest.java
+++ b/tests/app/src/android/app/cts/NotificationManagerTest.java
@@ -3048,6 +3048,7 @@
                     .setShortLabel(BUBBLE_SHORTCUT_ID_DYNAMIC)
                     .setIcon(Icon.createWithResource(mContext, R.drawable.icon_black))
                     .setIntent(shortcutIntent)
+                    .setLongLived(true)
                     .build();
             scmanager.addDynamicShortcuts(Arrays.asList(shortcut));
 
@@ -3158,6 +3159,7 @@
                     .setShortLabel(BUBBLE_SHORTCUT_ID_DYNAMIC)
                     .setIcon(Icon.createWithResource(mContext, R.drawable.icon_black))
                     .setIntent(shortcutIntent)
+                    .setLongLived(true)
                     .build();
             scmanager.addDynamicShortcuts(Arrays.asList(shortcut));
 
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsTest.java b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsTest.java
index b817d2f..d931e25 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsTest.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsTest.java
@@ -29,6 +29,7 @@
 import android.platform.test.annotations.Presubmit;
 import android.view.DisplayCutout;
 import android.view.WindowInsets;
+import android.view.WindowInsets.Type;
 
 import androidx.test.filters.SmallTest;
 import androidx.test.runner.AndroidJUnit4;
@@ -72,6 +73,7 @@
         assertEquals(Insets.of(13, 14, 15, 16), insets.getMandatorySystemGestureInsets());
         assertEquals(Insets.of(17, 18, 19, 20), insets.getTappableElementInsets());
         assertSame(CUTOUT, insets.getDisplayCutout());
+        assertEquals(getCutoutSafeInsets(insets), insets.getInsets(Type.displayCutout()));
     }
 
     @Test
@@ -114,6 +116,7 @@
         assertNull(insets.getDisplayCutout());
         assertFalse(insets.isConsumed());
         assertTrue(insets.consumeDisplayCutout().isConsumed());
+        assertEquals(Insets.NONE, insets.getInsets(Type.displayCutout()));
     }
 
     @Test
@@ -137,6 +140,7 @@
         assertEquals(Insets.of(1, 2, 3, 4), insets.getSystemWindowInsets());
         assertEquals(Insets.of(5, 6, 7, 8), insets.getStableInsets());
         assertSame(CUTOUT, insets.getDisplayCutout());
+        assertEquals(getCutoutSafeInsets(insets), insets.getInsets(Type.displayCutout()));
     }
 
     @Test
@@ -197,6 +201,7 @@
         assertEquals(Insets.NONE, consumed.getSystemGestureInsets());
         assertEquals(Insets.NONE, consumed.getMandatorySystemGestureInsets());
         assertEquals(Insets.NONE, consumed.getTappableElementInsets());
+        assertEquals(Insets.NONE, consumed.getInsets(Type.displayCutout()));
     }
 
     @Test
@@ -217,6 +222,7 @@
         assertEquals(Insets.NONE, consumed.getSystemGestureInsets());
         assertEquals(Insets.NONE, consumed.getMandatorySystemGestureInsets());
         assertEquals(Insets.NONE, consumed.getTappableElementInsets());
+        assertEquals(Insets.NONE, consumed.getInsets(Type.displayCutout()));
     }
 
     @Test
@@ -237,6 +243,8 @@
         assertEquals(insets.getSystemGestureInsets(), consumed.getSystemGestureInsets());
         assertEquals(insets.getMandatorySystemGestureInsets(), consumed.getMandatorySystemGestureInsets());
         assertEquals(insets.getTappableElementInsets(), consumed.getTappableElementInsets());
+        assertEquals(
+                insets.getInsets(Type.displayCutout()), consumed.getInsets(Type.displayCutout()));
     }
 
     @Test
@@ -395,6 +403,8 @@
         assertEquals(applyInset(insets.getTappableElementInsets()),
                 insetInsets.getTappableElementInsets());
         assertEquals(applyInset(getCutoutSafeInsets(insets)), getCutoutSafeInsets(insetInsets));
+        assertEquals(applyInset(getCutoutSafeInsets(insets)),
+                insetInsets.getInsets(Type.displayCutout()));
     }
 
     @Test
@@ -415,6 +425,7 @@
         assertEquals(Insets.NONE, insetInsets.getMandatorySystemGestureInsets());
         assertEquals(Insets.NONE, insetInsets.getTappableElementInsets());
         assertNull(insetInsets.getDisplayCutout());
+        assertEquals(Insets.NONE, insetInsets.getInsets(Type.displayCutout()));
     }
 
     @Test
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/WindowMetricsTests.java b/tests/framework/base/windowmanager/src/android/server/wm/WindowMetricsTests.java
index 1b04e13..684d10e 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/WindowMetricsTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/WindowMetricsTests.java
@@ -16,6 +16,9 @@
 
 package android.server.wm;
 
+import static android.view.WindowInsets.Type.displayCutout;
+import static android.view.WindowInsets.Type.navigationBars;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeFalse;
@@ -27,7 +30,6 @@
 import android.platform.test.annotations.Presubmit;
 import android.util.Size;
 import android.view.Display;
-import android.view.DisplayCutout;
 import android.view.View;
 import android.view.WindowInsets;
 import android.view.WindowMetrics;
@@ -103,26 +105,14 @@
 
     private static Size getLegacySize(WindowMetrics windowMetrics) {
         WindowInsets windowInsets = windowMetrics.getWindowInsets();
-        final Insets insetsWithCutout = getProperInsetsWithCutout(windowInsets.getStableInsets(),
-                windowInsets.getDisplayCutout());
-        final int insetsInWidth = insetsWithCutout.left + insetsWithCutout.right;
-        final int insetsInHeight = insetsWithCutout.top + insetsWithCutout.bottom;
+        final Insets insetsWithCutout =
+                windowInsets.getInsetsIgnoringVisibility(navigationBars() | displayCutout());
+
+        final int insetsWidth = insetsWithCutout.left + insetsWithCutout.right;
+        final int insetsHeight = insetsWithCutout.top + insetsWithCutout.bottom;
 
         Size size = windowMetrics.getSize();
-        return new Size(size.getWidth() - insetsInWidth, size.getHeight() - insetsInHeight);
-    }
-
-    private static Insets getProperInsetsWithCutout(Insets stableInsets, DisplayCutout cutout) {
-        final Insets excludingStatusBar = Insets.of(stableInsets.left, 0,
-                stableInsets.right, stableInsets.bottom);
-        if (cutout == null) {
-            return excludingStatusBar;
-        } else {
-            final Insets unionInsetsWithCutout = Insets.max(excludingStatusBar,
-                    Insets.of(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(),
-                            cutout.getSafeInsetRight(), cutout.getSafeInsetBottom()));
-            return unionInsetsWithCutout;
-        }
+        return new Size(size.getWidth() - insetsWidth, size.getHeight() - insetsHeight);
     }
 
     public static class MetricsActivity extends Activity implements View.OnLayoutChangeListener {
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
index 87688f5..b226c0d 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
@@ -51,6 +51,7 @@
 import androidx.annotation.Nullable;
 
 import com.android.server.wm.nano.AppTransitionProto;
+import com.android.server.wm.nano.DisplayAreaProto;
 import com.android.server.wm.nano.DisplayFramesProto;
 import com.android.server.wm.nano.IdentifierProto;
 import com.android.server.wm.nano.KeyguardControllerProto;
@@ -60,9 +61,11 @@
 import com.android.server.wm.nano.PinnedStackControllerProto;
 import com.android.server.wm.nano.RootWindowContainerProto;
 import com.android.server.wm.nano.TaskProto;
+import com.android.server.wm.nano.WindowContainerChildProto;
 import com.android.server.wm.nano.WindowContainerProto;
 import com.android.server.wm.nano.WindowFramesProto;
 import com.android.server.wm.nano.WindowManagerServiceDumpProto;
+import com.android.server.wm.nano.WindowTokenProto;
 import com.android.server.wm.nano.WindowStateAnimatorProto;
 import com.android.server.wm.nano.WindowStateProto;
 import com.android.server.wm.nano.WindowSurfaceControllerProto;
@@ -119,6 +122,7 @@
     // Must be kept in sync with 'default_minimal_size_resizable_task' dimen from frameworks/base.
     private static final int DEFAULT_RESIZABLE_TASK_SIZE_DP = 220;
 
+    private RootWindowContainer mRoot = null;
     // Displays in z-order with the top most at the front of the list, starting with primary.
     private final List<DisplayContent> mDisplays = new ArrayList<>();
     // Stacks in z-order with the top most at the front of the list, starting with primary display.
@@ -243,6 +247,47 @@
         mSanityCheckFocusedWindow = sanityCheckFocusedWindow;
     }
 
+    /**
+     * For a given WindowContainer, traverse down the hierarchy and add all children of type
+     * {@code T} to {@code outChildren}.
+     */
+    private static <T extends WindowContainer> void collectDescendantsOfType(Class<T> clazz,
+            WindowContainer root, List<T> outChildren) {
+        collectDescendantsOfTypeIf(clazz, t -> true, root, outChildren);
+    }
+
+    /**
+     * For a given WindowContainer, traverse down the hierarchy and add all children of type
+     * {@code T} to {@code outChildren} if the child passes the test {@code predicate}.
+     */
+    private static <T extends WindowContainer> void collectDescendantsOfTypeIf(Class<T> clazz,
+            Predicate<T> predicate, WindowContainer root, List<T> outChildren) {
+        // Traverse top to bottom
+        for (int i = root.mChildren.size()-1; i >= 0; i--) {
+            final WindowContainer child = root.mChildren.get(i);
+            if (clazz.isInstance(child)) {
+                if(predicate.test(clazz.cast(child))) {
+                    outChildren.add(clazz.cast(child));
+                }
+            }
+            collectDescendantsOfTypeIf(clazz, predicate, child, outChildren);
+        }
+    }
+
+    /**
+     * For a given WindowContainer, traverse down the hierarchy and add all immediate children of
+     * type {@code T} to {@code outChildren}.
+     */
+    private static <T extends WindowContainer> void collectChildrenOfType(Class<T> clazz,
+            WindowContainer root, List<T> outChildren) {
+        for (int i = root.mChildren.size()-1; i >= 0; i--) {
+            final WindowContainer child = root.mChildren.get(i);
+            if (clazz.isInstance(child)) {
+                outChildren.add(clazz.cast(child));
+            }
+        }
+    }
+
     public void computeState() {
         // It is possible the system is in the middle of transition to the right state when we get
         // the dump. We try a few times to get the information we need before giving up.
@@ -316,6 +361,26 @@
         }
     }
 
+    /** Update WindowManagerState state for a newly added DisplayContent. */
+    private void updateForDisplayContent(DisplayContent display) {
+        if (display.mResumedActivity != null) {
+            mResumedActivitiesInDisplays.add(display.mResumedActivity);
+        }
+
+        for (int i = 0; i < display.mRootTasks.size(); i++) {
+            ActivityTask task = display.mRootTasks.get(i);
+            mRootTasks.add(task);
+            if (task.mResumedActivity != null) {
+                mResumedActivitiesInStacks.add(task.mResumedActivity);
+            }
+        }
+
+        if (display.mDefaultPinnedStackBounds != null) {
+            mDefaultPinnedStackBounds = display.mDefaultPinnedStackBounds;
+            mPinnedStackMovementBounds = display.mPinnedStackMovementBounds;
+        }
+    }
+
     private void parseSysDumpProto(byte[] sysDump) throws InvalidProtocolBufferNanoException {
         reset();
 
@@ -324,10 +389,11 @@
         if (state.focusedWindow != null) {
             mFocusedWindow = state.focusedWindow.title;
         }
-
-        for (int i = 0; i < root.displays.length; i++) {
-            final DisplayContentProto display = root.displays[i];
-            mDisplays.add(new DisplayContent(display, this));
+        mRoot = new RootWindowContainer(root);
+        collectDescendantsOfType(DisplayContent.class, mRoot, mDisplays);
+        for (int i = 0; i < mDisplays.size(); i++) {
+            DisplayContent display = mDisplays.get(i);
+            updateForDisplayContent(display);
         }
         mKeyguardControllerState = new KeyguardControllerState(root.keyguardController);
         mFocusedApp = state.focusedApp;
@@ -343,9 +409,7 @@
             mPendingActivities.add(root.pendingActivities[i].title);
         }
 
-        for (int i = 0; i < root.windows.length; i++) {
-            mWindowStates.add(new WindowState(root.windows[i]));
-        }
+        collectDescendantsOfType(WindowState.class, mRoot, mWindowStates);
 
         if (state.inputMethodWindow != null) {
             mInputMethodWindowAppToken = Integer.toHexString(state.inputMethodWindow.hashCode);
@@ -356,6 +420,7 @@
     }
 
     private void reset() {
+        mRoot = null;
         mDisplays.clear();
         mRootTasks.clear();
         mWindowStates.clear();
@@ -917,12 +982,16 @@
     }
 
     public static class DisplayContent extends ActivityContainer {
+        static Predicate<ActivityTask> isRootAndNotTaskOrganized
+                = t -> !t.mCreatedByOrganizer && t.isRootTask();
 
         public int mId;
         ArrayList<ActivityTask> mRootTasks = new ArrayList<>();
         int mFocusedRootTaskId;
         String mResumedActivity;
         boolean mSingleTaskInstance;
+        Rect mDefaultPinnedStackBounds = null;
+        Rect mPinnedStackMovementBounds = null;
 
         private Rect mDisplayRect = new Rect();
         private Rect mAppRect = new Rect();
@@ -935,30 +1004,19 @@
         private String mLastTransition;
         private String mAppTransitionState;
 
-        DisplayContent(DisplayContentProto proto, WindowManagerState amState) {
+        DisplayContent(DisplayContentProto proto) {
             super(proto.windowContainer);
             mId = proto.id;
             mFocusedRootTaskId = proto.focusedRootTaskId;
             mSingleTaskInstance = proto.singleTaskInstance;
             if (proto.resumedActivity != null) {
                 mResumedActivity = proto.resumedActivity.title;
-                amState.mResumedActivitiesInDisplays.add(mResumedActivity);
             }
-            for (int i = 0; i < proto.tasks.length; i++) {
-                ActivityTask task = new ActivityTask(proto.tasks[i]);
-                if (task.mCreatedByOrganizer) {
-                    // TODO(b/149338177): figure out how CTS tests deal with organizer. For now,
-                    //                    don't treat them as regular stacks
-                    // Skip tasks created by an organizer
-                    continue;
-                }
-                mRootTasks.add(task);
-                // Also update activity manager state
-                amState.mRootTasks.add(task);
-                if (task.mResumedActivity != null) {
-                    amState.mResumedActivitiesInStacks.add(task.mResumedActivity);
-                }
-            }
+            // TODO(b/149338177): figure out how CTS tests deal with organizer. For now,
+            //                    don't treat them as regular stacks
+            // Skip tasks created by an organizer
+            collectDescendantsOfTypeIf(ActivityTask.class, isRootAndNotTaskOrganized, this,
+                                       mRootTasks);
 
             mDpi = proto.dpi;
             DisplayInfoProto infoProto = proto.displayInfo;
@@ -987,8 +1045,8 @@
 
             PinnedStackControllerProto pinnedStackProto = proto.pinnedStackController;
             if (pinnedStackProto != null) {
-                amState.mDefaultPinnedStackBounds = extract(pinnedStackProto.defaultBounds);
-                amState.mPinnedStackMovementBounds = extract(pinnedStackProto.movementBounds);
+                mDefaultPinnedStackBounds = extract(pinnedStackProto.defaultBounds);
+                mPinnedStackMovementBounds = extract(pinnedStackProto.movementBounds);
             }
 
         }
@@ -1084,12 +1142,8 @@
                 mResumedActivity = proto.resumedActivity.title;
             }
 
-            for (int i = 0;  i < proto.tasks.length; i++) {
-                mTasks.add(new ActivityTask(proto.tasks[i]));
-            }
-            for (int i = 0;  i < proto.activities.length; i++) {
-                mActivities.add(new Activity(proto.activities[i], this));
-            }
+            collectChildrenOfType(ActivityTask.class, this, mTasks);
+            collectChildrenOfType(Activity.class, this, mActivities);
         }
 
         public int getResizeMode() {
@@ -1099,6 +1153,9 @@
         public int getTaskId() {
             return mTaskId;
         }
+        boolean isRootTask() {
+            return mTaskId == mRootTaskId;
+        }
 
         public int getRootTaskId() {
             return mRootTaskId;
@@ -1180,9 +1237,9 @@
         public boolean translucent;
         ActivityTask task;
 
-        Activity(ActivityRecordProto proto, ActivityTask parent) {
+        Activity(ActivityRecordProto proto, WindowContainer parent) {
             super(proto.windowToken.windowContainer);
-            task = parent;
+            task = (ActivityTask) parent;
             name = proto.name;
             state = proto.state;
             visible = proto.visible;
@@ -1295,16 +1352,82 @@
         }
     }
 
+    public static class RootWindowContainer extends WindowContainer {
+        RootWindowContainer(RootWindowContainerProto proto) {
+            super(proto.windowContainer);
+        }
+    }
+    public static class DisplayArea extends WindowContainer {
+        DisplayArea(DisplayAreaProto proto) {
+            super(proto.windowContainer);
+        }
+    }
+    public static class WindowToken extends WindowContainer {
+        WindowToken(WindowTokenProto proto) {
+            super(proto.windowContainer);
+        }
+    }
+
+    /**
+     * Represents WindowContainer classes such as DisplayContent.WindowContainers and
+     * DisplayContent.NonAppWindowContainers. This can be expanded into a specific class
+     * if we need track and assert some state in the future.
+     */
+    public static class GenericWindowContainer extends WindowContainer {
+        GenericWindowContainer(WindowContainerProto proto) {
+            super(proto);
+        }
+    }
+
+    static WindowContainer getWindowContainer(WindowContainerChildProto proto,
+            WindowContainer parent) {
+        if (proto.displayContent != null) {
+           return new DisplayContent(proto.displayContent);
+        }
+
+        if (proto.displayArea != null) {
+           return new DisplayArea(proto.displayArea);
+        }
+
+        if (proto.task != null) {
+           return new ActivityTask(proto.task);
+        }
+
+        if (proto.activity != null) {
+           return new Activity(proto.activity, parent);
+        }
+
+        if (proto.windowToken != null) {
+           return new WindowToken(proto.windowToken);
+        }
+
+        if (proto.window != null) {
+           return new WindowState(proto.window);
+        }
+
+        if (proto.windowContainer != null) {
+           return new GenericWindowContainer(proto.windowContainer);
+        }
+        return null;
+    }
+
     static abstract class WindowContainer extends ConfigurationContainer {
 
         protected boolean mFullscreen;
         protected Rect mBounds;
         protected int mOrientation;
         protected List<WindowState> mSubWindows = new ArrayList<>();
+        protected List<WindowContainer> mChildren = new ArrayList<>();
 
         WindowContainer(WindowContainerProto proto) {
             super(proto.configurationContainer);
             mOrientation = proto.orientation;
+            for (int i = 0; i < proto.children.length; i++) {
+                final WindowContainer child = getWindowContainer(proto.children[i], this);
+                if (child != null) {
+                    mChildren.add(child);
+                }
+            }
         }
 
         Rect getBounds() {
@@ -1385,12 +1508,7 @@
             } else {
                 mWindowType = 0;
             }
-            for (int i = 0; i < proto.childWindows.length; i++) {
-                WindowStateProto childProto = proto.childWindows[i];
-                WindowState childWindow = new WindowState(childProto);
-                mSubWindows.add(childWindow);
-                mSubWindows.addAll(childWindow.getWindows());
-            }
+            collectDescendantsOfType(WindowState.class, this, mSubWindows);
         }
 
         @NonNull
diff --git a/tests/tests/appenumeration/AndroidTest.xml b/tests/tests/appenumeration/AndroidTest.xml
index d5ad14c..8db021f 100644
--- a/tests/tests/appenumeration/AndroidTest.xml
+++ b/tests/tests/appenumeration/AndroidTest.xml
@@ -32,6 +32,7 @@
         <option name="test-file-name" value="CtsAppEnumerationSharedUidSource.apk" />
         <option name="test-file-name" value="CtsAppEnumerationSharedUidTarget.apk" />
         <option name="test-file-name" value="CtsAppEnumerationQueriesNothing.apk" />
+        <option name="test-file-name" value="CtsAppEnumerationWildcardActionSource.apk" />
         <option name="test-file-name" value="CtsAppEnumerationQueriesActivityViaAction.apk" />
         <option name="test-file-name" value="CtsAppEnumerationQueriesServiceViaAction.apk" />
         <option name="test-file-name" value="CtsAppEnumerationQueriesProviderViaAuthority.apk" />
diff --git a/tests/tests/appenumeration/app/source/Android.bp b/tests/tests/appenumeration/app/source/Android.bp
index 01d26fa..f215e77 100644
--- a/tests/tests/appenumeration/app/source/Android.bp
+++ b/tests/tests/appenumeration/app/source/Android.bp
@@ -149,4 +149,16 @@
         "vts",
         "general-tests",
     ],
+}
+
+android_test_helper_app {
+    name: "CtsAppEnumerationWildcardActionSource",
+    manifest: "AndroidManifest-queriesWildcardAction.xml",
+    defaults: ["CtsAppEnumerationQueriesDefaults"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
 }
\ No newline at end of file
diff --git a/tests/tests/appenumeration/app/source/AndroidManifest-queriesWildcardAction.xml b/tests/tests/appenumeration/app/source/AndroidManifest-queriesWildcardAction.xml
new file mode 100644
index 0000000..ffd8848
--- /dev/null
+++ b/tests/tests/appenumeration/app/source/AndroidManifest-queriesWildcardAction.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2020 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.
+  -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="android.appenumeration.queries.wildcard.action">
+    <queries>
+        <intent>
+            <action android:name="*" />
+        </intent>
+    </queries>
+    <application>
+        <uses-library android:name="android.test.runner" />
+        <activity android:name="android.appenumeration.cts.query.TestActivity"
+                  android:exported="true" />
+    </application>
+</manifest>
diff --git a/tests/tests/appenumeration/lib/src/android/appenumeration/cts/Constants.java b/tests/tests/appenumeration/lib/src/android/appenumeration/cts/Constants.java
index 3a992ac..1afcc65 100644
--- a/tests/tests/appenumeration/lib/src/android/appenumeration/cts/Constants.java
+++ b/tests/tests/appenumeration/lib/src/android/appenumeration/cts/Constants.java
@@ -44,7 +44,9 @@
     public static final String QUERIES_NOTHING = PKG_BASE + "queries.nothing";
     /** A package that queries nothing, but is part of a shared user */
     public static final String QUERIES_NOTHING_SHARED_USER = PKG_BASE + "queries.nothing.shareduid";
-    /** A package that exposes nothing, but is part of a shared user */
+    /** A package that queries via wildcard action. */
+    public static final String QUERIES_WILDCARD_ACTION = PKG_BASE + "queries.wildcard.action";
+    /** A package that queries for {@link #TARGET_NO_API} package */
     public static final String TARGET_SHARED_USER = PKG_BASE + "noapi.shareduid";
     /** A package that exposes itself via various intent filters (activities, services, etc.) */
     public static final String TARGET_FILTERS = PKG_BASE + "filters";
@@ -63,7 +65,8 @@
             QUERIES_UNEXPORTED_SERVICE_ACTION,
             QUERIES_UNEXPORTED_PROVIDER_AUTH,
             QUERIES_PACKAGE,
-            QUERIES_NOTHING_SHARED_USER
+            QUERIES_NOTHING_SHARED_USER,
+            QUERIES_WILDCARD_ACTION
     };
 
     public static final String ACTIVITY_CLASS_TEST = PKG_BASE + "cts.query.TestActivity";
diff --git a/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java b/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
index c172c38..3f624ee 100644
--- a/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
+++ b/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
@@ -43,6 +43,7 @@
 import static android.appenumeration.cts.Constants.QUERIES_UNEXPORTED_ACTIVITY_ACTION;
 import static android.appenumeration.cts.Constants.QUERIES_UNEXPORTED_PROVIDER_AUTH;
 import static android.appenumeration.cts.Constants.QUERIES_UNEXPORTED_SERVICE_ACTION;
+import static android.appenumeration.cts.Constants.QUERIES_WILDCARD_ACTION;
 import static android.appenumeration.cts.Constants.TARGET_FILTERS;
 import static android.appenumeration.cts.Constants.TARGET_FORCEQUERYABLE;
 import static android.appenumeration.cts.Constants.TARGET_NO_API;
@@ -94,7 +95,6 @@
 
 @RunWith(AndroidJUnit4.class)
 public class AppEnumerationTests {
-
     private static Handler sResponseHandler;
     private static HandlerThread sResponseThread;
 
@@ -256,6 +256,11 @@
     }
 
     @Test
+    public void queriesWildcardAction_canSeeTargets() throws Exception {
+        assertVisible(QUERIES_WILDCARD_ACTION, TARGET_FILTERS);
+    }
+
+    @Test
     public void queriesProviderAuthority_canSeeTarget() throws Exception {
         assertVisible(QUERIES_PROVIDER_AUTH, TARGET_FILTERS);
     }
@@ -458,9 +463,7 @@
                 .setComponent(new ComponentName(sourcePackageName, ACTIVITY_CLASS_TEST))
                 // data uri unique to each activity start to ensure actual launch and not just
                 // redisplay
-                .setData(Uri.parse("test://" + name.getMethodName()
-                        + (targetPackageName != null
-                        ? targetPackageName : UUID.randomUUID().toString())))
+                .setData(Uri.parse("test://" + UUID.randomUUID().toString()))
                 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
         if (targetPackageName != null) {
             intent.putExtra(Intent.EXTRA_PACKAGE_NAME, targetPackageName);
diff --git a/tests/tests/appop/AppThatUsesAppOps/src/android/app/appops/cts/appthatusesappops/AppOpsUserService.kt b/tests/tests/appop/AppThatUsesAppOps/src/android/app/appops/cts/appthatusesappops/AppOpsUserService.kt
index 3f55742..fb87058 100644
--- a/tests/tests/appop/AppThatUsesAppOps/src/android/app/appops/cts/appthatusesappops/AppOpsUserService.kt
+++ b/tests/tests/appop/AppThatUsesAppOps/src/android/app/appops/cts/appthatusesappops/AppOpsUserService.kt
@@ -56,8 +56,8 @@
             private val asyncNoted = mutableListOf<AsyncNotedAppOp>()
 
             private fun setNotedAppOpsCollector() {
-                appOpsManager.setNotedAppOpsCollector(
-                        object : AppOpsManager.AppOpsCollector() {
+                appOpsManager.setOnOpNotedCallback(mainExecutor,
+                        object : AppOpsManager.OnOpNotedCallback() {
                             override fun onNoted(op: SyncNotedAppOp) {
                                 noted.add(op to Throwable().stackTrace)
                             }
@@ -73,6 +73,10 @@
             }
 
             init {
+                try {
+                    appOpsManager.setOnOpNotedCallback(null, null)
+                } catch (ignored: IllegalStateException) {
+                }
                 setNotedAppOpsCollector()
             }
 
@@ -94,7 +98,7 @@
                 client: IAppOpsUserClient
             ) {
                 forwardThrowableFrom {
-                    appOpsManager.setNotedAppOpsCollector(null)
+                    appOpsManager.setOnOpNotedCallback(null, null)
 
                     client.noteSyncOp()
 
@@ -114,7 +118,7 @@
                 client: IAppOpsUserClient
             ) {
                 forwardThrowableFrom {
-                    appOpsManager.setNotedAppOpsCollector(null)
+                    appOpsManager.setOnOpNotedCallback(null, null)
 
                     client.noteAsyncOp()
 
diff --git a/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt b/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
index 7b94625..2b92c7f 100644
--- a/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
+++ b/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
@@ -17,7 +17,7 @@
 package android.app.appops.cts
 
 import android.app.AppOpsManager
-import android.app.AppOpsManager.AppOpsCollector
+import android.app.AppOpsManager.OnOpNotedCallback
 import android.app.AppOpsManager.OPSTR_ACCESS_ACCESSIBILITY
 import android.app.AppOpsManager.OPSTR_CAMERA
 import android.app.AppOpsManager.OPSTR_COARSE_LOCATION
@@ -137,8 +137,8 @@
     }
 
     private fun setNotedAppOpsCollector() {
-        appOpsManager.setNotedAppOpsCollector(
-                object : AppOpsCollector() {
+        appOpsManager.setOnOpNotedCallback(Executor { it.run() },
+                object : OnOpNotedCallback() {
                     override fun onNoted(op: SyncNotedAppOp) {
                         noted.add(op to Throwable().stackTrace)
                     }
@@ -150,11 +150,6 @@
                     override fun onAsyncNoted(asyncOp: AsyncNotedAppOp) {
                         asyncNoted.add(asyncOp)
                     }
-
-                    override fun getAsyncNotedExecutor(): Executor {
-                        // Execute callbacks immediately
-                        return Executor { it.run() }
-                    }
                 })
     }
 
@@ -682,7 +677,7 @@
 
     @After
     fun removeNotedAppOpsCollector() {
-        appOpsManager.setNotedAppOpsCollector(null)
+        appOpsManager.setOnOpNotedCallback(null, null)
     }
 
     @After
diff --git a/tests/tests/car/src/android/car/cts/CarApiTestBase.java b/tests/tests/car/src/android/car/cts/CarApiTestBase.java
index 445593b..6d3ffbc 100644
--- a/tests/tests/car/src/android/car/cts/CarApiTestBase.java
+++ b/tests/tests/car/src/android/car/cts/CarApiTestBase.java
@@ -20,6 +20,8 @@
 import static org.junit.Assume.assumeTrue;
 
 import android.car.Car;
+import android.car.FuelType;
+import android.car.PortLocationType;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.ServiceConnection;
@@ -32,6 +34,8 @@
 
 import org.junit.After;
 
+import java.util.Arrays;
+import java.util.List;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 
@@ -40,6 +44,17 @@
 
     private Car mCar;
 
+    // Enums in FuelType
+    final static List<Integer> EXPECTED_FUEL_TYPES =
+            Arrays.asList(FuelType.UNKNOWN, FuelType.UNLEADED, FuelType.LEADED, FuelType.DIESEL_1,
+                    FuelType.DIESEL_2, FuelType.BIODIESEL, FuelType.E85, FuelType.LPG, FuelType.CNG,
+                    FuelType.LNG, FuelType.ELECTRIC, FuelType.HYDROGEN, FuelType.OTHER);
+    // Enums in PortLocationType
+    final static List<Integer> EXPECTED_PORT_LOCATIONS =
+            Arrays.asList(PortLocationType.UNKNOWN, PortLocationType.FRONT_LEFT,
+                    PortLocationType.FRONT_RIGHT, PortLocationType.REAR_RIGHT,
+                    PortLocationType.REAR_LEFT, PortLocationType.FRONT, PortLocationType.REAR);
+
     private final DefaultServiceConnectionListener mConnectionListener =
             new DefaultServiceConnectionListener();
 
diff --git a/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java b/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
index e3ca341..f901a4a 100644
--- a/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
@@ -29,7 +29,6 @@
 import static com.google.common.truth.Truth.assertThat;
 import androidx.test.runner.AndroidJUnit4;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import org.junit.Before;
@@ -85,14 +84,9 @@
     @Test
     public void testGetFuelTypes() throws Exception {
         assertNotNull(mCarInfoManager.getFuelTypes());
-
         int[] actualResults = mCarInfoManager.getFuelTypes();
-        List<Integer> expectedResults =
-            Arrays.asList(FuelType.UNKNOWN, FuelType.UNLEADED, FuelType.LEADED, FuelType.DIESEL_1,
-                FuelType.DIESEL_2, FuelType.BIODIESEL, FuelType.E85, FuelType.LPG, FuelType.CNG,
-                FuelType.LNG, FuelType.ELECTRIC, FuelType.HYDROGEN, FuelType.OTHER);
         for (int result : actualResults) {
-            assertThat(expectedResults).contains(result);
+            assertThat(result).isIn(EXPECTED_FUEL_TYPES);
         }
 
     }
@@ -120,7 +114,7 @@
                 SCAME, GBT_DC);
 
         for (int result : actualResults) {
-            assertThat(expectedResults).contains(result);
+            assertThat(result).isIn(expectedResults);
         }
     }
 
@@ -136,7 +130,7 @@
                 VehicleAreaSeat.SEAT_ROW_2_LEFT, VehicleAreaSeat.SEAT_ROW_2_CENTER,
                 VehicleAreaSeat.SEAT_ROW_2_RIGHT, VehicleAreaSeat.SEAT_ROW_3_LEFT,
                 VehicleAreaSeat.SEAT_ROW_3_CENTER, VehicleAreaSeat.SEAT_ROW_1_RIGHT);
-        assertThat(expectedResult).contains(mCarInfoManager.getDriverSeat());
+        assertThat(mCarInfoManager.getDriverSeat()).isIn(expectedResult);
     }
 
     /**
@@ -145,11 +139,7 @@
      */
     @Test
     public void testGetEvPortLocation() throws Exception {
-        List<Integer> expectedResult =
-            Arrays.asList(PortLocationType.UNKNOWN, PortLocationType.FRONT_LEFT,
-                PortLocationType.FRONT_RIGHT, PortLocationType.REAR_RIGHT,
-                PortLocationType.REAR_LEFT, PortLocationType.FRONT, PortLocationType.REAR);
-        assertThat(expectedResult).contains(mCarInfoManager.getEvPortLocation());
+        assertThat(mCarInfoManager.getEvPortLocation()).isIn(EXPECTED_PORT_LOCATIONS);
     }
 
     /**
@@ -158,10 +148,6 @@
      */
     @Test
     public void testGetFuelDoorLocation() throws Exception {
-        List<Integer> expectedResult =
-            Arrays.asList(PortLocationType.UNKNOWN, PortLocationType.FRONT_LEFT,
-                        PortLocationType.FRONT_RIGHT, PortLocationType.REAR_RIGHT,
-                        PortLocationType.REAR_LEFT, PortLocationType.FRONT, PortLocationType.REAR);
-        assertThat(expectedResult).contains(mCarInfoManager.getFuelDoorLocation());
+        assertThat(mCarInfoManager.getFuelDoorLocation()).isIn(EXPECTED_PORT_LOCATIONS);
     }
 }
diff --git a/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java b/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
index 357f985..865b986 100644
--- a/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
@@ -19,9 +19,10 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import android.app.PendingIntent;
 import android.car.Car;
-import android.car.CarNotConnectedException;
 import android.car.content.pm.CarPackageManager;
+import android.content.Intent;
 import android.os.Build;
 import android.platform.test.annotations.RequiresDevice;
 import android.test.suitebuilder.annotation.SmallTest;
@@ -76,7 +77,7 @@
     }
 
     @Test
-    public void testDistractionOptimizedActivityIsAllowed() throws CarNotConnectedException {
+    public void testDistractionOptimizedActivityIsAllowed() {
         // This test relies on test activity in installed apk, and AndroidManifest declaration.
         if (Build.TYPE.equalsIgnoreCase("user")) {
             // Skip this test on user build, which checks the install source for DO activity list.
@@ -87,7 +88,7 @@
     }
 
     @Test
-    public void testNonDistractionOptimizedActivityNotAllowed() throws CarNotConnectedException {
+    public void testNonDistractionOptimizedActivityNotAllowed() {
         // This test relies on test activity in installed apk, and AndroidManifest declaration.
         if (Build.TYPE.equalsIgnoreCase("user")) {
             // Skip this test on user build, which checks the install source for DO activity list.
@@ -96,4 +97,34 @@
         assertFalse(mCarPm.isActivityDistractionOptimized("android.car.cts",
                 "android.car.cts.drivingstate.NonDistractionOptimizedActivity"));
     }
+
+    private PendingIntent createIntent(String packageName, String relativeClassName) {
+        Intent intent = new Intent();
+        intent.setClassName(packageName, packageName + relativeClassName);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        return PendingIntent.getActivity(sContext, 0, intent, 0);
+    }
+
+    @Test
+    public void testPendingIntentToDistractionOptimizedActivityIsAllowed() {
+        // This test relies on test activity in installed apk, and AndroidManifest declaration.
+        if (Build.TYPE.equalsIgnoreCase("user")) {
+            // Skip this test on user build, which checks the install source for DO activity list.
+            return;
+        }
+        assertTrue(mCarPm.isPendingIntentDistractionOptimized(
+                createIntent("android.car.cts", ".drivingstate.DistractionOptimizedActivity")));
+    }
+
+    @Test
+    public void testPendingIntentToNonDistractionOptimizedActivityNotAllowed() {
+        // This test relies on test activity in installed apk, and AndroidManifest declaration.
+        if (Build.TYPE.equalsIgnoreCase("user")) {
+            // Skip this test on user build, which checks the install source for DO activity list.
+            return;
+        }
+        assertFalse(mCarPm.isPendingIntentDistractionOptimized(
+                createIntent("android.car.cts", ".drivingstate.NonDistractionOptimizedActivity")));
+    }
+
 }
diff --git a/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java b/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java
index ca6d98b..8f2057d 100644
--- a/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java
@@ -16,6 +16,8 @@
 package android.car.cts;
 
 import static org.testng.Assert.assertThrows;
+import static com.google.common.truth.Truth.assertThat;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
@@ -26,6 +28,7 @@
 
 import android.car.Car;
 import android.car.VehicleAreaSeat;
+import android.car.VehicleAreaType;
 import android.car.VehiclePropertyIds;
 import android.car.hardware.CarPropertyConfig;
 import android.car.hardware.CarPropertyValue;
@@ -43,6 +46,7 @@
 import com.android.compatibility.common.util.CddTest;
 
 import org.junit.Assert;
+import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -235,6 +239,47 @@
     }
 
     @Test
+    public void testGetIntArrayProperty() {
+        List<CarPropertyConfig> allConfigs = mCarPropertyManager.getPropertyList();
+        for (CarPropertyConfig cfg : allConfigs) {
+            if (cfg.getAccess() == CarPropertyConfig.VEHICLE_PROPERTY_ACCESS_NONE
+                    || cfg.getAccess() == CarPropertyConfig.VEHICLE_PROPERTY_ACCESS_WRITE
+                    || cfg.getPropertyType() != Integer[].class) {
+                // skip the test if the property is not readable or not an int array type property.
+                continue;
+            }
+            switch (cfg.getPropertyId()) {
+                case VehiclePropertyIds.INFO_FUEL_TYPE:
+                    int[] fuelTypes = mCarPropertyManager.getIntArrayProperty(cfg.getPropertyId(),
+                            VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL);
+                    verifyEnumsRange(EXPECTED_FUEL_TYPES, fuelTypes);
+                    break;
+                case VehiclePropertyIds.INFO_MULTI_EV_PORT_LOCATIONS:
+                    int[] evPortLocations = mCarPropertyManager.getIntArrayProperty(
+                            cfg.getPropertyId(),VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL);
+                    verifyEnumsRange(EXPECTED_PORT_LOCATIONS, evPortLocations);
+                    break;
+                default:
+                    int[] areaIds = getAreaIdsHelper(cfg);
+                    for(int areaId : areaIds) {
+                        mCarPropertyManager.getIntArrayProperty(cfg.getPropertyId(), areaId);
+                    }
+            }
+        }
+    }
+
+    private void verifyEnumsRange(List<Integer> expectedResults, int[] results) {
+        assertThat(results).isNotNull();
+        // If the property is not implemented in cars, getIntArrayProperty returns an empty array.
+        if (results.length == 0) {
+            return;
+        }
+        for (int result : results) {
+            assertThat(result).isIn(expectedResults);
+        }
+    }
+
+    @Test
     public void testIsPropertyAvailable() {
         List<CarPropertyConfig> configs = mCarPropertyManager.getPropertyList(mPropertyIds);
 
@@ -262,7 +307,6 @@
         }
     }
 
-
     @Test
     public void testRegisterCallback() throws Exception {
         //Test on registering a invalid property
@@ -285,7 +329,7 @@
                 CarPropertyManager.SENSOR_RATE_NORMAL);
         mCarPropertyManager.registerCallback(speedListenerUI, vehicleSpeed,
                 CarPropertyManager.SENSOR_RATE_FASTEST);
-
+        // TODO(b/149778976): Use CountDownLatch in listener instead of waitingTime
         Thread.sleep(WAIT_CALLBACK);
         assertNotEquals(0, speedListenerNormal.receivedEvent(vehicleSpeed));
         assertNotEquals(0, speedListenerUI.receivedEvent(vehicleSpeed));
@@ -314,7 +358,7 @@
         CarPropertyEventCounter speedListenerUI = new CarPropertyEventCounter();
 
         mCarPropertyManager.registerCallback(speedListenerNormal, vehicleSpeed,
-            CarPropertyManager.SENSOR_RATE_NORMAL);
+                CarPropertyManager.SENSOR_RATE_NORMAL);
 
         // test on unregistering a callback that was never registered
         try {
@@ -324,7 +368,7 @@
         }
 
         mCarPropertyManager.registerCallback(speedListenerUI, vehicleSpeed,
-            CarPropertyManager.SENSOR_RATE_UI);
+                CarPropertyManager.SENSOR_RATE_UI);
         Thread.sleep(WAIT_CALLBACK);
 
         mCarPropertyManager.unregisterCallback(speedListenerNormal, vehicleSpeed);
@@ -345,6 +389,40 @@
         assertEquals(currentEventUI, speedListenerUI.receivedEvent(vehicleSpeed));
     }
 
+    @Test
+    public void testUnregisterWithPropertyId() throws Exception {
+        // Ignores the test if wheel_tick property does not exist in the car.
+        Assume.assumeTrue("WheelTick is not available, skip unregisterCallback test",
+                mCarPropertyManager.isPropertyAvailable(
+                        VehiclePropertyIds.WHEEL_TICK, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL));
+
+        CarPropertyEventCounter speedAndWheelTicksListener = new CarPropertyEventCounter();
+        mCarPropertyManager.registerCallback(speedAndWheelTicksListener,
+                VehiclePropertyIds.PERF_VEHICLE_SPEED, CarPropertyManager.SENSOR_RATE_FAST);
+        mCarPropertyManager.registerCallback(speedAndWheelTicksListener,
+                VehiclePropertyIds.WHEEL_TICK, CarPropertyManager.SENSOR_RATE_FAST);
+
+        // TODO(b/149778976): Use CountDownLatch in listener instead of waitingTime
+        Thread.sleep(WAIT_CALLBACK);
+        mCarPropertyManager.unregisterCallback(speedAndWheelTicksListener,
+                VehiclePropertyIds.PERF_VEHICLE_SPEED);
+        int currentSpeedEvents = speedAndWheelTicksListener.receivedEvent(
+                VehiclePropertyIds.PERF_VEHICLE_SPEED);
+        int currentWheelTickEvents = speedAndWheelTicksListener.receivedEvent(
+                VehiclePropertyIds.WHEEL_TICK);
+
+        Thread.sleep(WAIT_CALLBACK);
+        int speedEventsAfterUnregister = speedAndWheelTicksListener.receivedEvent(
+                VehiclePropertyIds.PERF_VEHICLE_SPEED);
+        int wheelTicksEventsAfterUnregister = speedAndWheelTicksListener.receivedEvent(
+                VehiclePropertyIds.WHEEL_TICK);
+
+        assertThat(currentSpeedEvents).isEqualTo(speedEventsAfterUnregister);
+        assertThat(wheelTicksEventsAfterUnregister).isGreaterThan(currentWheelTickEvents);
+    }
+
+
+    // Returns {0} if the property is global property, otherwise query areaId for CarPropertyConfig
     private int[] getAreaIdsHelper(CarPropertyConfig config) {
         if (config.isGlobalProperty()) {
             int[] areaIds = {0};
diff --git a/tests/tests/content/src/android/content/cts/ContentResolverTest.java b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
index 821b69a..f56a6ca 100644
--- a/tests/tests/content/src/android/content/cts/ContentResolverTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
@@ -45,6 +45,7 @@
 import com.android.compatibility.common.util.PollingCheck;
 import com.android.internal.util.ArrayUtils;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -1465,6 +1466,16 @@
         assertNull(response);
     }
 
+    public void testEncodeDecode() {
+        final Uri expected = Uri.parse("content://com.example/item/23");
+        final File file = ContentResolver.encodeToFile(expected);
+        assertNotNull(file);
+
+        final Uri actual = ContentResolver.decodeFromFile(file);
+        assertNotNull(actual);
+        assertEquals(expected, actual);
+    }
+
     public static class Change {
         public final boolean selfChange;
         public final Iterable<Uri> uris;
@@ -1515,7 +1526,7 @@
         }
 
         @Override
-        public synchronized void onChange(boolean selfChange, Iterable<Uri> uris, int flags) {
+        public synchronized void onChange(boolean selfChange, Collection<Uri> uris, int flags) {
             final Change change = new Change(selfChange, uris, flags);
             Log.v(TAG, change.toString());
 
diff --git a/tests/tests/content/src/android/content/cts/IntentFilterTest.java b/tests/tests/content/src/android/content/cts/IntentFilterTest.java
index 37d50bc..36e5788 100644
--- a/tests/tests/content/src/android/content/cts/IntentFilterTest.java
+++ b/tests/tests/content/src/android/content/cts/IntentFilterTest.java
@@ -16,7 +16,9 @@
 
 package android.content.cts;
 
+import static android.content.IntentFilter.MATCH_CATEGORY_HOST;
 import static android.content.IntentFilter.MATCH_CATEGORY_SCHEME_SPECIFIC_PART;
+import static android.content.IntentFilter.MATCH_CATEGORY_TYPE;
 import static android.os.PatternMatcher.PATTERN_LITERAL;
 import static android.os.PatternMatcher.PATTERN_PREFIX;
 import static android.os.PatternMatcher.PATTERN_SIMPLE_GLOB;
@@ -483,6 +485,24 @@
                 MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme:a1b"));
     }
 
+    public void testSchemeSpecificPartsWithWildCards() throws Exception {
+        IntentFilter filter = new Match(null, null, null, new String[]{"scheme"},
+                null, null, null, null, new String[]{"ssp1"},
+                new int[]{PATTERN_LITERAL, PATTERN_LITERAL});
+        checkMatches(filter,
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, null, true),
+                MatchCondition.data(MATCH_CATEGORY_SCHEME_SPECIFIC_PART, "scheme:ssp1", true),
+                MatchCondition.data(MATCH_CATEGORY_SCHEME_SPECIFIC_PART, "*:ssp1", true),
+                MatchCondition.data(MATCH_CATEGORY_SCHEME_SPECIFIC_PART, "scheme:*", true),
+                MatchCondition.data(MATCH_CATEGORY_SCHEME_SPECIFIC_PART, "*:*", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme:ssp12", true));
+
+        checkMatches(filter,
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*:ssp1", false),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme:*", false),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*:*", false));
+    }
+
     public void testAuthorities() {
         for (int i = 0; i < 10; i++) {
             mIntentFilter.addDataAuthority(HOST + i, String.valueOf(PORT + i));
@@ -535,6 +555,49 @@
                 MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1://authority1:200/"));
     }
 
+    public void testAuthoritiesWithWildcards() throws Exception {
+        IntentFilter filter = new Match(null, null, null, new String[]{"scheme1"},
+                new String[]{"authority1"}, new String[]{null});
+        checkMatches(filter,
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, null, true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1:*", true),
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_HOST, "scheme1://*/", true),
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_HOST, "scheme1://*:100/", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1://*/", false),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1://*:100/", false));
+
+        filter = new Match(null, null, null, new String[]{"scheme1"},
+                new String[]{"authority1"}, new String[]{"100"});
+        checkMatches(filter,
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, null, true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1:*", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1://*/", true),
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_PORT, "scheme1://*:100/", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1://*:200/", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*:foo", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*://authority1/", true),
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_PORT, "*://authority1:100/", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*://authority1:200/", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*:*", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*://*/", true),
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_PORT, "*://*:100/", true),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*://*:200/", true));
+
+        checkMatches(filter,
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1://*/", false),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "scheme1://*:100/", false),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*://authority1:100/", false),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*://*/", false),
+                MatchCondition.data(IntentFilter.NO_MATCH_DATA, "*://*:100/", false));
+
+        filter = new Match(null, null, null, new String[]{"scheme1"},
+                new String[]{"*"}, null);
+        checkMatches(filter,
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_HOST, "scheme1://", true),
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_HOST, "scheme1://", false),
+                MatchCondition.data(IntentFilter.MATCH_CATEGORY_HOST, "scheme1://*", true));
+    }
+
     public void testDataTypes() throws MalformedMimeTypeException {
         for (int i = 0; i < 10; i++) {
             mIntentFilter.addDataType(DATA_STATIC_TYPE + i);
@@ -682,6 +745,129 @@
                 new MatchCondition(IntentFilter.NO_MATCH_ACTION, "action3", null, null, null));
     }
 
+    public void testActionWildCards() throws Exception {
+        IntentFilter filter = new Match(new String[]{"action1"}, null, null, null, null, null);
+        checkMatches(filter,
+                new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, null, null, null, null, true),
+                new MatchCondition(IntentFilter.MATCH_CATEGORY_EMPTY, "*", null, null, null, true),
+                new MatchCondition(
+                        IntentFilter.NO_MATCH_ACTION, "action3", null, null, null, true));
+
+        checkMatches(filter,
+                new MatchCondition(IntentFilter.NO_MATCH_ACTION, "*", null, null, null, false));
+
+    }
+
+    public void testAppEnumerationContactProviders() throws Exception {
+        // sample contact source
+        IntentFilter filter = new Match(new String[]{Intent.ACTION_VIEW},
+                new String[]{Intent.CATEGORY_DEFAULT},
+                new String[]{"vnd.android.cursor.item/vnd.com.someapp.profile"},
+                new String[]{"content"},
+                new String[]{"com.android.contacts"},
+                null /*ports*/);
+
+        // app that would like to match all contact sources
+        checkMatches(filter,
+                new MatchCondition(MATCH_CATEGORY_TYPE,
+                        Intent.ACTION_VIEW,
+                        null /*categories*/,
+                        "vnd.android.cursor.item/*",
+                        "content://com.android.contacts",
+                        true));
+    }
+
+    public void testAppEnumerationDocumentEditor() throws Exception {
+        // sample document editor
+        IntentFilter filter = new Match(
+                new String[]{
+                        Intent.ACTION_VIEW,
+                        Intent.ACTION_EDIT,
+                        "com.app.android.intent.action.APP_EDIT",
+                        "com.app.android.intent.action.APP_VIEW"},
+                new String[]{Intent.CATEGORY_DEFAULT},
+                new String[]{
+                        "application/msword",
+                        "application/vnd.oasis.opendocument.text",
+                        "application/rtf",
+                        "text/rtf",
+                        "text/plain",
+                        "application/pdf",
+                        "application/x-pdf",
+                        "application/docm"},
+                null /*schemes*/,
+                null /*authorities*/,
+                null /*ports*/);
+
+        // app that would like to match all doc editors
+        checkMatches(filter,
+                new MatchCondition(MATCH_CATEGORY_TYPE,
+                        Intent.ACTION_VIEW,
+                        new String[]{Intent.CATEGORY_DEFAULT},
+                        "*/*",
+                        "content://com.example.fileprovider",
+                        true));
+
+    }
+
+    public void testAppEnumerationDeepLinks() throws Exception {
+        // Sample app that supports deep-links
+        IntentFilter filter = new Match(
+                new String[]{Intent.ACTION_VIEW},
+                new String[]{
+                        Intent.CATEGORY_DEFAULT,
+                        Intent.CATEGORY_BROWSABLE},
+                null /*types*/,
+                new String[]{"http", "https"},
+                new String[]{"arbitrary-site.com"},
+                null /*ports*/);
+
+        // Browser that would like to see all deep-linkable http/s app, but not all apps
+        checkMatches(filter,
+                new MatchCondition(MATCH_CATEGORY_HOST,
+                        Intent.ACTION_VIEW,
+                        new String[]{Intent.CATEGORY_BROWSABLE},
+                        null,
+                        "https://*",
+                        true));
+        checkMatches(filter,
+                new MatchCondition(MATCH_CATEGORY_HOST,
+                        Intent.ACTION_VIEW,
+                        new String[]{Intent.CATEGORY_BROWSABLE},
+                        null,
+                        "http://*",
+                        true));
+    }
+
+    public void testAppEnumerationCustomShareSheet() throws Exception {
+        // Sample share target
+        IntentFilter filter = new Match(
+                new String[]{Intent.ACTION_SEND},
+                new String[]{Intent.CATEGORY_DEFAULT},
+                new String[]{"*/*"},
+                null /*schemes*/,
+                null /*authorities*/,
+                null /*ports*/);
+
+        // App with custom share sheet that would like to see all jpeg targets
+        checkMatches(filter,
+                new MatchCondition(MATCH_CATEGORY_TYPE,
+                        Intent.ACTION_SEND,
+                        null /*categories*/,
+                        "image/jpeg",
+                        "content://com.example.fileprovider",
+                        true));
+        // App with custom share sheet that would like to see all jpeg targets that don't specify
+        // a host
+        checkMatches(filter,
+                new MatchCondition(MATCH_CATEGORY_TYPE,
+                        Intent.ACTION_SEND,
+                        null /*categories*/,
+                        "image/jpeg",
+                        "content:",
+                        true));
+    }
+
     public void testWriteToXml() throws IllegalArgumentException, IllegalStateException,
             IOException, MalformedMimeTypeException, XmlPullParserException {
         XmlSerializer xml;
@@ -1102,18 +1288,27 @@
         public final String mimeType;
         public final Uri data;
         public final String[] categories;
+        public final boolean wildcardSupported;
 
         public static MatchCondition data(int result, String data) {
             return new MatchCondition(result, null, null, null, data);
         }
+        public static MatchCondition data(int result, String data, boolean wildcardSupported) {
+            return new MatchCondition(result, null, null, null, data, wildcardSupported);
+        }
 
         MatchCondition(int result, String action, String[] categories, String mimeType,
                 String data) {
+            this(result, action, categories, mimeType, data, false);
+        }
+        MatchCondition(int result, String action, String[] categories, String mimeType,
+                String data, boolean wildcardSupported) {
             this.result = result;
             this.action = action;
             this.mimeType = mimeType;
             this.data = data != null ? Uri.parse(data) : null;
             this.categories = categories;
+            this.wildcardSupported = wildcardSupported;
         }
     }
 
@@ -1130,7 +1325,7 @@
                 }
             }
             int result = filter.match(mc.action, mc.mimeType, mc.data != null ? mc.data.getScheme()
-                    : null, mc.data, categories, "test");
+                    : null, mc.data, categories, "test", mc.wildcardSupported);
             if ((result & IntentFilter.MATCH_CATEGORY_MASK) !=
                     (mc.result & IntentFilter.MATCH_CATEGORY_MASK)) {
                 StringBuilder msg = new StringBuilder();
@@ -1353,4 +1548,4 @@
             isPrintlnCalled = true;
         }
     }
-}
+}
\ No newline at end of file
diff --git a/tests/tests/database/src/android/database/cts/ContentObserverTest.java b/tests/tests/database/src/android/database/cts/ContentObserverTest.java
index d470a62..c924d9a 100644
--- a/tests/tests/database/src/android/database/cts/ContentObserverTest.java
+++ b/tests/tests/database/src/android/database/cts/ContentObserverTest.java
@@ -24,6 +24,7 @@
 import android.test.InstrumentationTestCase;
 
 import java.util.Arrays;
+import java.util.Collection;
 
 public class ContentObserverTest extends InstrumentationTestCase {
     private static final Uri CONTENT_URI = Uri.parse("content://uri");
@@ -185,7 +186,7 @@
         }
 
         @Override
-        public void onChange(boolean selfChange, Iterable<Uri> uris, int flags) {
+        public void onChange(boolean selfChange, Collection<Uri> uris, int flags) {
             super.onChange(selfChange, uris, flags);
             synchronized (this) {
                 mChangeCount++;
diff --git a/tests/tests/media/Android.bp b/tests/tests/media/Android.bp
index b0930a6..83d6aef 100644
--- a/tests/tests/media/Android.bp
+++ b/tests/tests/media/Android.bp
@@ -77,4 +77,5 @@
         "mts",
     ],
     host_required: ["cts-dynamic-config"],
+    min_sdk_version: "29",
 }
diff --git a/tests/tests/media/AndroidManifest.xml b/tests/tests/media/AndroidManifest.xml
index 1bec10d..7a00734 100644
--- a/tests/tests/media/AndroidManifest.xml
+++ b/tests/tests/media/AndroidManifest.xml
@@ -152,6 +152,8 @@
        <receiver android:name="android.media.cts.MediaButtonReceiver" />
     </application>
 
+    <uses-sdk android:minSdkVersion="29"   android:targetSdkVersion="29" />
+
     <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
                      android:targetPackage="android.media.cts"
                      android:label="CTS tests of android.media">
diff --git a/tests/tests/media/src/android/media/cts/MediaRoute2ProviderServiceTest.java b/tests/tests/media/src/android/media/cts/MediaRoute2ProviderServiceTest.java
index 1ebad5e..e4c3ea1 100644
--- a/tests/tests/media/src/android/media/cts/MediaRoute2ProviderServiceTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRoute2ProviderServiceTest.java
@@ -360,7 +360,7 @@
             }
         });
 
-        CountDownLatch onControllerCreatedLatch = new CountDownLatch(1);
+        CountDownLatch onTransferredLatch = new CountDownLatch(1);
         CountDownLatch onControllerUpdatedForSelectLatch = new CountDownLatch(1);
         CountDownLatch onControllerUpdatedForDeselectLatch = new CountDownLatch(1);
         CountDownLatch onControllerUpdatedForTransferLatch = new CountDownLatch(1);
@@ -370,9 +370,10 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null && SESSION_ID_1.equals(newController.getOriginalId())) {
+                if (SESSION_ID_1.equals(newController.getOriginalId())) {
+                    assertEquals(mRouter2.getSystemController(), oldController);
                     controllers.add(newController);
-                    onControllerCreatedLatch.countDown();
+                    onTransferredLatch.countDown();
                 }
             }
         };
@@ -412,7 +413,7 @@
 
             mRouter2.transferTo(routeToCreateSession);
             assertTrue(onCreateSessionLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
-            assertTrue(onControllerCreatedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+            assertTrue(onTransferredLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
             assertFalse(controllers.isEmpty());
 
             RoutingController controller = controllers.get(0);
@@ -473,25 +474,25 @@
         });
 
 
-        CountDownLatch onControllerCreatedLatch = new CountDownLatch(1);
-        CountDownLatch onControllerReleasedLatch = new CountDownLatch(1);
+        CountDownLatch onTransferredLatch = new CountDownLatch(1);
+        CountDownLatch onStoppedLatch = new CountDownLatch(1);
         List<RoutingController> controllers = new ArrayList<>();
 
         TransferCallback transferCallback = new TransferCallback() {
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    if (SESSION_ID_1.equals(newController.getOriginalId())) {
-                        controllers.add(newController);
-                        onControllerCreatedLatch.countDown();
-                    }
-                } else {
-                    // newController == null means that the oldController is released
-                    if (SESSION_ID_1.equals(oldController.getOriginalId())) {
-                        assertTrue(oldController.isReleased());
-                        onControllerReleasedLatch.countDown();
-                    }
+                if (SESSION_ID_1.equals(newController.getOriginalId())) {
+                    assertEquals(mRouter2.getSystemController(), oldController);
+                    controllers.add(newController);
+                    onTransferredLatch.countDown();
+                }
+            }
+            @Override
+            public void onStopped(RoutingController controller){
+                if (SESSION_ID_1.equals(controller.getOriginalId())) {
+                    assertTrue(controller.isReleased());
+                    onStoppedLatch.countDown();
                 }
             }
         };
@@ -505,11 +506,11 @@
 
             mRouter2.transferTo(routeToCreateSession);
             assertTrue(onCreateSessionLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
-            assertTrue(onControllerCreatedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+            assertTrue(onTransferredLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
             assertFalse(controllers.isEmpty());
 
             mService.notifySessionReleased(SESSION_ID_1);
-            assertTrue(onControllerReleasedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+            assertTrue(onStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
         } finally {
             mRouter2.unregisterRouteCallback(dummyCallback);
             mRouter2.unregisterTransferCallback(transferCallback);
diff --git a/tests/tests/media/src/android/media/cts/MediaRouter2Test.java b/tests/tests/media/src/android/media/cts/MediaRouter2Test.java
index 7fe6b90..71f83de 100644
--- a/tests/tests/media/src/android/media/cts/MediaRouter2Test.java
+++ b/tests/tests/media/src/android/media/cts/MediaRouter2Test.java
@@ -183,12 +183,11 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    assertTrue(createRouteMap(newController.getSelectedRoutes()).containsKey(
-                            ROUTE_ID1));
-                    controllers.add(newController);
-                    successLatch.countDown();
-                }
+                assertEquals(mRouter2.getSystemController(), oldController);
+                assertTrue(createRouteMap(newController.getSelectedRoutes()).containsKey(
+                        ROUTE_ID1));
+                controllers.add(newController);
+                successLatch.countDown();
             }
 
             @Override
@@ -233,10 +232,8 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    controllers.add(newController);
-                    successLatch.countDown();
-                }
+                controllers.add(newController);
+                successLatch.countDown();
             }
 
             @Override
@@ -279,13 +276,11 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    createdControllers.add(newController);
-                    if (successLatch1.getCount() > 0) {
-                        successLatch1.countDown();
-                    } else {
-                        successLatch2.countDown();
-                    }
+                createdControllers.add(newController);
+                if (successLatch1.getCount() > 0) {
+                    successLatch1.countDown();
+                } else {
+                    successLatch2.countDown();
                 }
             }
 
@@ -358,20 +353,18 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    assertTrue(createRouteMap(newController.getSelectedRoutes()).containsKey(
-                            ROUTE_ID1));
+                assertTrue(createRouteMap(newController.getSelectedRoutes())
+                        .containsKey(ROUTE_ID1));
 
-                    // The StubMediaRoute2ProviderService is supposed to set control hints
-                    // with the given controllerHints.
-                    Bundle controlHints = newController.getControlHints();
-                    assertNotNull(controlHints);
-                    assertTrue(controlHints.containsKey(TEST_KEY));
-                    assertEquals(TEST_VALUE, controlHints.getString(TEST_KEY));
+                // The StubMediaRoute2ProviderService is supposed to set control hints
+                // with the given controllerHints.
+                Bundle controlHints = newController.getControlHints();
+                assertNotNull(controlHints);
+                assertTrue(controlHints.containsKey(TEST_KEY));
+                assertEquals(TEST_VALUE, controlHints.getString(TEST_KEY));
 
-                    controllers.add(newController);
-                    successLatch.countDown();
-                }
+                controllers.add(newController);
+                successLatch.countDown();
             }
 
             @Override
@@ -421,10 +414,8 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    controllers.add(newController);
-                    successLatch.countDown();
-                }
+                controllers.add(newController);
+                successLatch.countDown();
             }
         };
 
@@ -493,10 +484,8 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    controllers.add(newController);
-                    successLatch.countDown();
-                }
+                controllers.add(newController);
+                successLatch.countDown();
             }
 
             @Override
@@ -547,12 +536,11 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
-                            ROUTE_ID1));
-                    controllers.add(newController);
-                    onTransferredLatch.countDown();
-                }
+                assertEquals(mRouter2.getSystemController(), oldController);
+                assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
+                        ROUTE_ID1));
+                controllers.add(newController);
+                onTransferredLatch.countDown();
             }
         };
 
@@ -645,12 +633,11 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
-                            ROUTE_ID1));
-                    controllers.add(newController);
-                    onTransferredLatch.countDown();
-                }
+                assertEquals(mRouter2.getSystemController(), oldController);
+                assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
+                        ROUTE_ID1));
+                controllers.add(newController);
+                onTransferredLatch.countDown();
             }
         };
 
@@ -715,12 +702,11 @@
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
-                            ROUTE_ID1));
-                    controllers.add(newController);
-                    onTransferredLatch.countDown();
-                }
+                assertEquals(mRouter2.getSystemController(), oldController);
+                assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
+                        ROUTE_ID1));
+                controllers.add(newController);
+                onTransferredLatch.countDown();
             }
         };
         ControllerCallback controllerCallback = new ControllerCallback() {
@@ -766,7 +752,86 @@
         }
     }
 
-    // TODO: Add tests for onSessionReleased() when provider releases the session.
+    // TODO: Add tests for onStopped() when provider releases the session.
+    @Test
+    public void testStop() throws Exception {
+        final List<String> sampleRouteType = new ArrayList<>();
+        sampleRouteType.add(FEATURE_SAMPLE);
+
+        Map<String, MediaRoute2Info> routes = waitAndGetRoutes(sampleRouteType);
+        MediaRoute2Info routeTransferFrom = routes.get(ROUTE_ID1);
+        assertNotNull(routeTransferFrom);
+
+        final CountDownLatch onTransferredLatch = new CountDownLatch(1);
+        final CountDownLatch onControllerUpdatedLatch = new CountDownLatch(1);
+        final CountDownLatch onStoppedLatch = new CountDownLatch(1);
+        final List<RoutingController> controllers = new ArrayList<>();
+
+        TransferCallback transferCallback = new TransferCallback() {
+            @Override
+            public void onTransferred(RoutingController oldController,
+                    RoutingController newController) {
+                assertEquals(mRouter2.getSystemController(), oldController);
+                assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
+                        ROUTE_ID1));
+                controllers.add(newController);
+                onTransferredLatch.countDown();
+            }
+            @Override
+            public void onStopped(RoutingController controller) {
+                if (onTransferredLatch.getCount() != 0
+                        || !TextUtils.equals(
+                        controllers.get(0).getId(), controller.getId())) {
+                    return;
+                }
+                onStoppedLatch.countDown();
+            }
+        };
+
+        ControllerCallback controllerCallback = new ControllerCallback() {
+            @Override
+            public void onControllerUpdated(RoutingController controller) {
+                if (onTransferredLatch.getCount() != 0
+                        || !TextUtils.equals(controllers.get(0).getId(), controller.getId())) {
+                    return;
+                }
+                onControllerUpdatedLatch.countDown();
+            }
+        };
+
+        // TODO: Remove this once the MediaRouter2 becomes always connected to the service.
+        RouteCallback routeCallback = new RouteCallback() {};
+        mRouter2.registerRouteCallback(mExecutor, routeCallback, EMPTY_DISCOVERY_PREFERENCE);
+
+        try {
+            mRouter2.registerTransferCallback(mExecutor, transferCallback);
+            mRouter2.registerControllerCallback(mExecutor, controllerCallback);
+            mRouter2.transferTo(routeTransferFrom);
+            assertTrue(onTransferredLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+
+            assertEquals(1, controllers.size());
+            RoutingController controller = controllers.get(0);
+
+            mRouter2.stop();
+
+            // Select ROUTE_ID5_TO_TRANSFER_TO
+            MediaRoute2Info routeToSelect = routes.get(ROUTE_ID4_TO_SELECT_AND_DESELECT);
+            assertNotNull(routeToSelect);
+
+            // This call should be ignored.
+            // The onSessionInfoChanged() shouldn't be called.
+            controller.selectRoute(routeToSelect);
+            assertFalse(onControllerUpdatedLatch.await(WAIT_MS, TimeUnit.MILLISECONDS));
+
+            // onStopped should be called.
+            assertTrue(onStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+        } finally {
+            releaseControllers(controllers);
+            mRouter2.unregisterRouteCallback(routeCallback);
+            mRouter2.unregisterControllerCallback(controllerCallback);
+            mRouter2.unregisterTransferCallback(transferCallback);
+        }
+    }
 
     @Test
     public void testRoutingControllerRelease() throws Exception {
@@ -779,26 +844,27 @@
 
         final CountDownLatch onTransferredLatch = new CountDownLatch(1);
         final CountDownLatch onControllerUpdatedLatch = new CountDownLatch(1);
-        final CountDownLatch onControllerReleasedLatch = new CountDownLatch(1);
+        final CountDownLatch onStoppedLatch = new CountDownLatch(1);
         final List<RoutingController> controllers = new ArrayList<>();
 
         TransferCallback transferCallback = new TransferCallback() {
             @Override
             public void onTransferred(RoutingController oldController,
                     RoutingController newController) {
-                if (newController != null) {
-                    assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
-                            ROUTE_ID1));
-                    controllers.add(newController);
-                    onTransferredLatch.countDown();
-                } else {
-                    if (onTransferredLatch.getCount() != 0
-                            || !TextUtils.equals(
-                                    controllers.get(0).getId(), oldController.getId())) {
-                        return;
-                    }
-                    onControllerReleasedLatch.countDown();
+                assertEquals(mRouter2.getSystemController(), oldController);
+                assertTrue(getOriginalRouteIds(newController.getSelectedRoutes()).contains(
+                        ROUTE_ID1));
+                controllers.add(newController);
+                onTransferredLatch.countDown();
+            }
+            @Override
+            public void onStopped(RoutingController controller) {
+                if (onTransferredLatch.getCount() != 0
+                        || !TextUtils.equals(
+                                controllers.get(0).getId(), controller.getId())) {
+                    return;
                 }
+                onStoppedLatch.countDown();
             }
         };
 
@@ -838,8 +904,8 @@
             controller.selectRoute(routeToSelect);
             assertFalse(onControllerUpdatedLatch.await(WAIT_MS, TimeUnit.MILLISECONDS));
 
-            // onControllerReleased should be called.
-            assertTrue(onControllerReleasedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
+            // onStopped should be called.
+            assertTrue(onStoppedLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
         } finally {
             releaseControllers(controllers);
             mRouter2.unregisterRouteCallback(routeCallback);
diff --git a/tests/tests/mediastress/Android.bp b/tests/tests/mediastress/Android.bp
index e0878b6..8a112df 100644
--- a/tests/tests/mediastress/Android.bp
+++ b/tests/tests/mediastress/Android.bp
@@ -39,4 +39,5 @@
     srcs: ["src/**/*.java"],
     host_required: ["cts-dynamic-config"],
     sdk_version: "test_current",
+    min_sdk_version: "29",
 }
diff --git a/tests/tests/mediastress/AndroidManifest.xml b/tests/tests/mediastress/AndroidManifest.xml
index f6c750f..b847ff5 100644
--- a/tests/tests/mediastress/AndroidManifest.xml
+++ b/tests/tests/mediastress/AndroidManifest.xml
@@ -41,6 +41,9 @@
         <activity android:name="android.mediastress.cts.NativeMediaActivity"
                   android:label="NativeMedia" />
     </application>
+
+    <uses-sdk android:minSdkVersion="29"   android:targetSdkVersion="29" />
+
     <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
             android:targetPackage="android.mediastress.cts"
             android:label="Media stress tests InstrumentationRunner" >
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiLockTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiLockTest.java
index 6ac92d4..fee9ef0 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiLockTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiLockTest.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiManager.WifiLock;
+import android.os.WorkSource;
 import android.platform.test.annotations.AppModeFull;
 import android.test.AndroidTestCase;
 
@@ -50,6 +51,7 @@
         WifiLock wl = wm.createWifiLock(lockType, WIFI_TAG);
 
         wl.setReferenceCounted(true);
+        wl.setWorkSource(new WorkSource());
         assertFalse(wl.isHeld());
         wl.acquire();
         assertTrue(wl.isHeld());
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index 5bdd712..f4c20e3 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -32,6 +32,7 @@
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.net.util.MacAddressUtils;
 import android.net.ConnectivityManager;
 import android.net.LinkProperties;
 import android.net.MacAddress;
@@ -42,6 +43,7 @@
 import android.net.wifi.ScanResult;
 import android.net.wifi.SoftApConfiguration;
 import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiManager.WifiLock;
 import android.net.wifi.WifiNetworkConnectionStatistics;
@@ -1392,6 +1394,67 @@
         }
     }
 
+    /**
+     * Tests {@link WifiManager#getFactoryMacAddresses()} returns at least one valid MAC address.
+     */
+    public void testGetFactoryMacAddresses() throws Exception {
+        if (!WifiFeature.isWifiSupported(getContext())) {
+            // skip the test if WiFi is not supported
+            return;
+        }
+        TestActionListener actionListener = new TestActionListener(mLock);
+        UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
+        int newNetworkId = INVALID_NETWORK_ID;
+        try {
+            uiAutomation.adoptShellPermissionIdentity();
+            // Obtain the factory MAC address
+            String[] macAddresses = mWifiManager.getFactoryMacAddresses();
+            assertTrue("At list one MAC address should be returned.", macAddresses.length > 0);
+            try {
+                MacAddress mac = MacAddress.fromString(macAddresses[0]);
+                assertNotEquals(WifiInfo.DEFAULT_MAC_ADDRESS, mac);
+                assertFalse(MacAddressUtils.isMulticastAddress(mac));
+            } catch (IllegalArgumentException e) {
+                fail("Factory MAC address is invalid");
+            }
+        } finally {
+            uiAutomation.dropShellPermissionIdentity();
+        }
+    }
+
+    /**
+     * Tests {@link WifiManager#isApMacRandomizationSupported()} does not crash.
+     */
+    public void testIsApMacRandomizationSupported() throws Exception {
+        if (!WifiFeature.isWifiSupported(getContext())) {
+            // skip the test if WiFi is not supported
+            return;
+        }
+        mWifiManager.isApMacRandomizationSupported();
+    }
+
+    /**
+     * Tests {@link WifiManager#isConnectedMacRandomizationSupported()} does not crash.
+     */
+    public void testIsConnectedMacRandomizationSupported() throws Exception {
+        if (!WifiFeature.isWifiSupported(getContext())) {
+            // skip the test if WiFi is not supported
+            return;
+        }
+        mWifiManager.isConnectedMacRandomizationSupported();
+    }
+
+    /**
+     * Tests {@link WifiManager#isPreferredNetworkOffloadSupported()} does not crash.
+     */
+    public void testIsPreferredNetworkOffloadSupported() throws Exception {
+        if (!WifiFeature.isWifiSupported(getContext())) {
+            // skip the test if WiFi is not supported
+            return;
+        }
+        mWifiManager.isPreferredNetworkOffloadSupported();
+    }
+
     private static class TestTrafficStateCallback implements WifiManager.TrafficStateCallback {
         private final Object mLock;
         public boolean onStateChangedCalled = false;
diff --git a/tests/tests/os/src/android/os/cts/BinderTest.java b/tests/tests/os/src/android/os/cts/BinderTest.java
index 59b81e2..5bc304a 100644
--- a/tests/tests/os/src/android/os/cts/BinderTest.java
+++ b/tests/tests/os/src/android/os/cts/BinderTest.java
@@ -381,6 +381,22 @@
         Binder.restoreCallingIdentity(token);
     }
 
+    public void testClearCallingWorkSource() {
+        final long token = Binder.clearCallingWorkSource();
+        Binder.restoreCallingWorkSource(token);
+    }
+
+    public void testSetCallingWorkSourceUid() {
+        final int otherUid = android.os.Process.myUid() + 1;
+        assertFalse(Binder.getCallingWorkSourceUid() == otherUid);
+
+        final long token = Binder.setCallingWorkSourceUid(otherUid);
+        assertTrue(Binder.getCallingWorkSourceUid() == otherUid);
+        Binder.restoreCallingWorkSource(token);
+
+        assertFalse(Binder.getCallingWorkSourceUid() == otherUid);
+    }
+
     public void testInterfaceRelatedMethods() {
         assertNull(mBinder.getInterfaceDescriptor());
         mBinder.attachInterface(new MockIInterface(), DESCRIPTOR_GOOGLE);
diff --git a/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java b/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
index f0f2d36..69f9a40 100644
--- a/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
@@ -341,6 +341,24 @@
     }
 
     @Test
+    public void testFileWrapped() throws Exception {
+        final Handler handler1 = new Handler(Looper.getMainLooper());
+        final Handler handler2 = new Handler(Looper.getMainLooper());
+        final FutureCloseListener listener1 = new FutureCloseListener();
+        final FutureCloseListener listener2 = new FutureCloseListener();
+        final ParcelFileDescriptor file1 = ParcelFileDescriptor.open(
+                File.createTempFile("pfd", "bbq"), ParcelFileDescriptor.MODE_READ_WRITE, handler1,
+                listener1);
+        final ParcelFileDescriptor file2 = ParcelFileDescriptor.wrap(file1, handler2, listener2);
+
+        write(file2, 7);
+        file2.close();
+
+        // make sure we were notified
+        assertEquals(null, listener2.get());
+    }
+
+    @Test
     public void testSocketErrorAfterClose() throws Exception {
         final ParcelFileDescriptor[] pair = ParcelFileDescriptor.createReliableSocketPair();
         final ParcelFileDescriptor red = pair[0];
diff --git a/tests/tests/permission/src/android/permission/cts/ShellPermissionTest.java b/tests/tests/permission/src/android/permission/cts/ShellPermissionTest.java
index 13c75de..6b73cbd 100644
--- a/tests/tests/permission/src/android/permission/cts/ShellPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/ShellPermissionTest.java
@@ -47,6 +47,7 @@
     /** Permissions that shell is NOT permitted to have. */
     private static final String[] BLACKLISTED_PERMISSIONS = {
             "android.permission.MANAGE_USERS",
+            "android.permission.NETWORK_STACK",
     };
 
     private static final Context sContext = InstrumentationRegistry.getTargetContext();
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index 9bbc177..3e831fd 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -1308,6 +1308,15 @@
         android:description="@string/permdesc_systemCamera"
         android:protectionLevel="system|signature" />
 
+    <!-- Allows receiving the camera service notifications when a camera is opened
+        (by a certain application package) or closed.
+        @hide -->
+    <permission android:name="android.permission.CAMERA_OPEN_CLOSE_LISTENER"
+        android:permissionGroup="android.permission-group.UNDEFINED"
+        android:label="@string/permlab_cameraOpenCloseListener"
+        android:description="@string/permdesc_cameraOpenCloseListener"
+        android:protectionLevel="signature" />
+
     <!-- ====================================================================== -->
     <!-- Permissions for accessing the device sensors                           -->
     <!-- ====================================================================== -->
diff --git a/tests/tests/provider/src/android/provider/cts/DocumentsContractTest.java b/tests/tests/provider/src/android/provider/cts/DocumentsContractTest.java
index 66bb43b..8f435f7 100644
--- a/tests/tests/provider/src/android/provider/cts/DocumentsContractTest.java
+++ b/tests/tests/provider/src/android/provider/cts/DocumentsContractTest.java
@@ -260,6 +260,12 @@
     }
 
     @Test
+    public void testManageMode() {
+        assertFalse(DocumentsContract.isManageMode(URI_RED));
+        assertTrue(DocumentsContract.isManageMode(DocumentsContract.setManageMode(URI_RED)));
+    }
+
+    @Test
     public void testCreateDocument() throws Exception {
         doReturn(DOC_RESULT).when(mProvider).createDocument(DOC_RED, MIME_TYPE, DISPLAY_NAME);
         assertEquals(URI_RESULT, createDocument(mResolver, URI_RED, MIME_TYPE, DISPLAY_NAME));
diff --git a/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java b/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java
index 7b2e562..37ed546 100644
--- a/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java
+++ b/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java
@@ -148,6 +148,15 @@
     }
 
     @Test
+    public void testGetRecentExternalVolumeNames() {
+        Set<String> volumeNames = MediaStore.getRecentExternalVolumeNames(getContext());
+
+        assertFalse(volumeNames.contains(MediaStore.VOLUME_INTERNAL));
+        assertFalse(volumeNames.contains(MediaStore.VOLUME_EXTERNAL));
+        assertTrue(volumeNames.contains(MediaStore.VOLUME_EXTERNAL_PRIMARY));
+    }
+
+    @Test
     public void testGetStorageVolume() throws Exception {
         Assume.assumeFalse(MediaStore.VOLUME_EXTERNAL.equals(mVolumeName));
 
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/CbGeoUtilsTest.java b/tests/tests/telephony/current/src/android/telephony/cts/CbGeoUtilsTest.java
new file mode 100644
index 0000000..cf935f9
--- /dev/null
+++ b/tests/tests/telephony/current/src/android/telephony/cts/CbGeoUtilsTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2020 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.telephony.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.telephony.CbGeoUtils;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+public class CbGeoUtilsTest {
+
+    // latitude is in range -90, 90
+    private static final double LAT1 = 30;
+    // longitude is in range -180, 180
+    private static final double LNG1 = 100;
+
+    private static final double LAT2 = 10;
+    private static final double LNG2 = 120;
+
+    private static final double LAT3 = -10;
+    private static final double LNG3 = -90;
+
+    // distance in meters between (LAT1, LNG1) and (LAT2, LNG2)
+    private static final double DIST = 3040602;
+
+    // max allowed error in calculations
+    private static final double DELTA = 1;
+
+    @Test
+    public void testLatLong() {
+        CbGeoUtils.LatLng p1 = new CbGeoUtils.LatLng(LAT1, LNG1);
+        CbGeoUtils.LatLng p2 = new CbGeoUtils.LatLng(LAT2, LNG2);
+
+        CbGeoUtils.LatLng difference = new CbGeoUtils.LatLng(LAT1 - LAT2, LNG1 - LNG2);
+        assertEquals(difference.lat, p1.subtract(p2).lat, DELTA);
+        assertEquals(difference.lng, p1.subtract(p2).lng, DELTA);
+
+        assertEquals(DIST, p1.distance(p2), DELTA);
+    }
+
+    @Test
+    public void testPolygon() {
+        CbGeoUtils.LatLng p1 = new CbGeoUtils.LatLng(LAT1, LNG1);
+        CbGeoUtils.LatLng p2 = new CbGeoUtils.LatLng(LAT2, LNG2);
+        CbGeoUtils.LatLng p3 = new CbGeoUtils.LatLng(LAT3, LNG3);
+
+        ArrayList<CbGeoUtils.LatLng> vertices = new ArrayList<>();
+        vertices.add(p1);
+        vertices.add(p2);
+        vertices.add(p3);
+
+        CbGeoUtils.Polygon polygon = new CbGeoUtils.Polygon((vertices));
+        assertEquals(vertices, polygon.getVertices());
+
+        assertTrue(polygon.contains(p1));
+        assertTrue(polygon.contains(p2));
+        assertTrue(polygon.contains(p3));
+    }
+
+    @Test
+    public void testCircle() {
+        CbGeoUtils.LatLng p1 = new CbGeoUtils.LatLng(LAT1, LNG1);
+        double radius = 1000;
+        CbGeoUtils.Circle circle = new CbGeoUtils.Circle(p1, radius);
+
+        assertEquals(radius, circle.getRadius(), DELTA);
+        assertEquals(p1, circle.getCenter());
+        // circle should always contain its center
+        assertTrue(circle.contains(p1));
+    }
+}
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SmsCbEtwsInfoTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SmsCbEtwsInfoTest.java
new file mode 100644
index 0000000..05cffda
--- /dev/null
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SmsCbEtwsInfoTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2009 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.telephony.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import android.telephony.SmsCbEtwsInfo;
+
+import com.android.internal.telephony.gsm.SmsCbConstants;
+
+import org.junit.Test;
+
+public class SmsCbEtwsInfoTest {
+
+    private static final int TEST_ETWS_WARNING_TYPE =
+            SmsCbConstants.MESSAGE_ID_ETWS_OTHER_EMERGENCY_TYPE;
+
+    @Test
+    public void testIsPrimary() {
+        SmsCbEtwsInfo info = new SmsCbEtwsInfo(TEST_ETWS_WARNING_TYPE,
+                false, false, false, null);
+        assertFalse(info.isPrimary());
+
+        SmsCbEtwsInfo info2 = new SmsCbEtwsInfo(TEST_ETWS_WARNING_TYPE,
+                false, false, true, null);
+        assertTrue(info2.isPrimary());
+    }
+
+    @Test
+    public void testIsPopupAlert() {
+        SmsCbEtwsInfo info = new SmsCbEtwsInfo(TEST_ETWS_WARNING_TYPE,
+                false, false, false, null);
+        assertFalse(info.isPopupAlert());
+
+        SmsCbEtwsInfo info2 = new SmsCbEtwsInfo(TEST_ETWS_WARNING_TYPE,
+                false, true, false, null);
+        assertTrue(info2.isPopupAlert());
+    }
+
+    @Test
+    public void testIsEmergencyUserAlert() {
+        SmsCbEtwsInfo info = new SmsCbEtwsInfo(TEST_ETWS_WARNING_TYPE,
+                false, false, false, null);
+        assertFalse(info.isEmergencyUserAlert());
+
+        SmsCbEtwsInfo info2 = new SmsCbEtwsInfo(TEST_ETWS_WARNING_TYPE,
+                true, false, false, null);
+        assertTrue(info2.isEmergencyUserAlert());
+    }
+
+    @Test
+    public void testGetWarningType() {
+        SmsCbEtwsInfo info = new SmsCbEtwsInfo(TEST_ETWS_WARNING_TYPE,
+                false, false, false, null);
+        assertEquals(TEST_ETWS_WARNING_TYPE, info.getWarningType());
+    }
+}
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SmsCbLocationTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SmsCbLocationTest.java
index 69c851f..0544fbc 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/SmsCbLocationTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SmsCbLocationTest.java
@@ -16,12 +16,19 @@
 package android.telephony.cts;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import android.telephony.SmsCbLocation;
 
 import org.junit.Test;
 
 public class SmsCbLocationTest {
+    private static final String PLMN = "TEST_PLMN";
+    private static final String PLMN2 = "TEST_PLMN 2";
+    private static final int LAC = -1;
+    private static final int CID = -1;
+
     @Test
     public void testSmsCbLocation() throws Throwable {
         SmsCbLocation cbLocation = new SmsCbLocation("94040", 1234, 5678);
@@ -29,4 +36,15 @@
         assertEquals(1234, cbLocation.getLac());
         assertEquals(5678, cbLocation.getCid());
     }
+
+    @Test
+    public void testIsInLocationArea() {
+        SmsCbLocation cbLocation = new SmsCbLocation(PLMN, LAC, CID);
+
+        SmsCbLocation area = new SmsCbLocation(PLMN, LAC, CID);
+        assertTrue(cbLocation.isInLocationArea(area));
+
+        SmsCbLocation area2 = new SmsCbLocation(PLMN2, LAC, CID);
+        assertFalse(cbLocation.isInLocationArea(area2));
+    }
 }
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SmsCbMessageTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SmsCbMessageTest.java
index c74332c..6b2ddbb 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/SmsCbMessageTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SmsCbMessageTest.java
@@ -18,8 +18,13 @@
 package android.telephony.cts;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 
 import android.content.ContentValues;
+import android.database.Cursor;
 import android.provider.Telephony;
 import android.telephony.CbGeoUtils;
 import android.telephony.SmsCbCmasInfo;
@@ -61,7 +66,7 @@
 
     private static final int TEST_MAX_WAIT_TIME = 0;
     private static final List<CbGeoUtils.Geometry> TEST_GEOS = new ArrayList<>();
-    private static final int TEST_RECEIVED_TIME = 11000;
+    private static final long TEST_RECEIVED_TIME = 11000;
     private static final int TEST_SLOT = 0;
     private static final int TEST_SUB_ID = 1;
 
@@ -229,4 +234,78 @@
         int serial = cv.getAsInteger(Telephony.CellBroadcasts.SERIAL_NUMBER);
         assertEquals(TEST_SERIAL, serial);
     }
+
+    @Test
+    public void testCreateFromCursor() {
+        Cursor cursor = mock(Cursor.class);
+        doReturn(0).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.GEOGRAPHICAL_SCOPE));
+        doReturn(TEST_GEO_SCOPE).when(cursor).getInt(0);
+
+        doReturn(1).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.SERIAL_NUMBER));
+        doReturn(TEST_SERIAL).when(cursor).getInt(1);
+
+        doReturn(2).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.SERVICE_CATEGORY));
+        doReturn(TEST_SERVICE_CATEGORY).when(cursor).getInt(2);
+
+        doReturn(3).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.LANGUAGE_CODE));
+        doReturn(TEST_LANGUAGE).when(cursor).getString(3);
+
+        doReturn(4).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.MESSAGE_BODY));
+        doReturn(TEST_BODY).when(cursor).getString(4);
+
+        doReturn(5).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.MESSAGE_FORMAT));
+        doReturn(TEST_MESSAGE_FORMAT).when(cursor).getInt(5);
+
+        doReturn(6).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.MESSAGE_PRIORITY));
+        doReturn(TEST_PRIORITY).when(cursor).getInt(6);
+
+        doReturn(7).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.SLOT_INDEX));
+        doReturn(TEST_SLOT).when(cursor).getInt(7);
+
+        doReturn(8).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.SUBSCRIPTION_ID));
+        doReturn(TEST_SUB_ID).when(cursor).getInt(8);
+
+        doReturn(-1).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.PLMN));
+
+        doReturn(-1).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.LAC));
+
+        doReturn(-1).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.CID));
+
+        doReturn(-1).when(cursor).getColumnIndex(eq(
+                Telephony.CellBroadcasts.ETWS_WARNING_TYPE));
+
+        doReturn(-1).when(cursor).getColumnIndex(eq(
+                Telephony.CellBroadcasts.CMAS_MESSAGE_CLASS));
+
+        doReturn(9).when(cursor).getColumnIndex(eq(
+                Telephony.CellBroadcasts.GEOMETRIES));
+        // return empty string here to be parsed into empty array list
+        doReturn("").when(cursor).getString(9);
+
+        doReturn(10).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.RECEIVED_TIME));
+        doReturn(TEST_RECEIVED_TIME).when(cursor).getLong(10);
+
+        doReturn(11).when(cursor).getColumnIndexOrThrow(eq(
+                Telephony.CellBroadcasts.MAXIMUM_WAIT_TIME));
+        doReturn(TEST_MAX_WAIT_TIME).when(cursor).getInt(11);
+
+        SmsCbMessage cbMessage = SmsCbMessage.createFromCursor(cursor);
+        assertEquals(TEST_SERIAL, cbMessage.getSerialNumber());
+        assertEquals(TEST_BODY, cbMessage.getMessageBody());
+        assertNull(cbMessage.getEtwsWarningInfo());
+        assertNull(cbMessage.getCmasWarningInfo());
+    }
 }
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java
index b330597..6fb9299 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java
@@ -32,6 +32,7 @@
 
 import android.annotation.Nullable;
 import android.content.pm.PackageManager;
+import android.content.res.Resources;
 import android.net.ConnectivityManager;
 import android.net.ConnectivityManager.NetworkCallback;
 import android.net.Network;
@@ -189,6 +190,17 @@
     }
 
     @Test
+    public void testGetResourcesForSubId() {
+        if (!isSupported()) return;
+        Resources r = ShellIdentityUtils.invokeMethodWithShellPermissions(mSm,
+                (sm) -> sm.getResourcesForSubId(InstrumentationRegistry.getContext(), mSubId));
+        // this is an old method which returns mcc/mnc as ints, so use the old SM.getMcc/Mnc methods
+        // because they also use ints
+        assertEquals(mSm.getActiveSubscriptionInfo(mSubId).getMcc(), r.getConfiguration().mcc);
+        assertEquals(mSm.getActiveSubscriptionInfo(mSubId).getMnc(), r.getConfiguration().mnc);
+    }
+
+    @Test
     public void testIsUsableSubscriptionId() throws Exception {
         if (!isSupported()) return;
         assertTrue(SubscriptionManager.isUsableSubscriptionId(mSubId));
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
index 95fb410..24a5ed5 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
@@ -2520,6 +2520,16 @@
     }
 
     @Test
+    public void testIsDataCapableExists() {
+        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            return;
+        }
+
+        //Simple test to make sure that isDataCapable exists and does not crash.
+        mTelephonyManager.isDataCapable();
+    }
+
+    @Test
     public void testDisAllowedNetworkTypes() {
         if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
             return;
diff --git a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallProfileTest.java b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallProfileTest.java
index 5b16d71..a35dfd7 100644
--- a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallProfileTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallProfileTest.java
@@ -106,6 +106,47 @@
     }
 
     @Test
+    public void testProprietaryExtrasNullCallExtras() {
+        if (!ImsUtils.shouldTestImsService()) {
+            return;
+        }
+        ImsStreamMediaProfile testProfile = new ImsStreamMediaProfile(1, 1, 1, 1, 1);
+        // pass in null for bundle
+        ImsCallProfile data = new ImsCallProfile(ImsCallProfile.SERVICE_TYPE_NORMAL,
+                ImsCallProfile.CALL_TYPE_VOICE_N_VIDEO, null /*bundle*/, testProfile);
+
+        Parcel dataParceled = Parcel.obtain();
+        data.writeToParcel(dataParceled, 0);
+        dataParceled.setDataPosition(0);
+        ImsCallProfile unparceledData =
+                ImsCallProfile.CREATOR.createFromParcel(dataParceled);
+        dataParceled.recycle();
+
+        assertNotNull(unparceledData.getProprietaryCallExtras());
+    }
+
+    @Test
+    public void testProprietaryExtrasEmptyExtras() {
+        if (!ImsUtils.shouldTestImsService()) {
+            return;
+        }
+        // Empty bundle
+        Bundle testBundle = new Bundle();
+        ImsStreamMediaProfile testProfile = new ImsStreamMediaProfile(1, 1, 1, 1, 1);
+        ImsCallProfile data = new ImsCallProfile(ImsCallProfile.SERVICE_TYPE_NORMAL,
+                ImsCallProfile.CALL_TYPE_VOICE_N_VIDEO, testBundle, testProfile);
+
+        Parcel dataParceled = Parcel.obtain();
+        data.writeToParcel(dataParceled, 0);
+        dataParceled.setDataPosition(0);
+        ImsCallProfile unparceledData =
+                ImsCallProfile.CREATOR.createFromParcel(dataParceled);
+        dataParceled.recycle();
+
+        assertNotNull(unparceledData.getProprietaryCallExtras());
+    }
+
+    @Test
     public void testCallExtras() {
         if (!ImsUtils.shouldTestImsService()) {
             return;
diff --git a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
index e471f36..953005e 100644
--- a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
@@ -1362,7 +1362,7 @@
             verifyIntKey(provisioningManager, mIntQueue,
                     ProvisioningManager.KEY_RCS_PUBLISH_TIMER_SEC, 5);
             verifyIntKey(provisioningManager, mIntQueue,
-                    ProvisioningManager.KEY_RCS_PUBLISH_TIMER_EXTENDED_SEC, 5);
+                    ProvisioningManager.KEY_RCS_PUBLISH_OFFLINE_AVAILABILITY_TIMER_SEC, 5);
             verifyIntKey(provisioningManager, mIntQueue,
                     ProvisioningManager.KEY_RCS_CAPABILITY_DISCOVERY_ENABLED, 0);
             verifyIntKey(provisioningManager, mIntQueue,
diff --git a/tests/tests/util/src/android/util/cts/LruCacheTest.java b/tests/tests/util/src/android/util/cts/LruCacheTest.java
new file mode 100644
index 0000000..610443e
--- /dev/null
+++ b/tests/tests/util/src/android/util/cts/LruCacheTest.java
@@ -0,0 +1,526 @@
+/*
+ * Copyright (C) 2020 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.util.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import android.util.LruCache;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/** CTS tests for {@link android.util.LruCache} */
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public final class LruCacheTest {
+    private int expectedCreateCount;
+    private int expectedPutCount;
+    private int expectedHitCount;
+    private int expectedMissCount;
+    private int expectedEvictionCount;
+
+    @Test
+    public void testStatistics() {
+        LruCache<String, String> cache = new LruCache<String, String>(3);
+        assertStatistics(cache);
+
+        assertEquals(null, cache.put("a", "A"));
+        expectedPutCount++;
+        assertStatistics(cache);
+        assertHit(cache, "a", "A");
+        assertSnapshot(cache, "a", "A");
+
+        assertEquals(null, cache.put("b", "B"));
+        expectedPutCount++;
+        assertStatistics(cache);
+        assertHit(cache, "a", "A");
+        assertHit(cache, "b", "B");
+        assertSnapshot(cache, "a", "A", "b", "B");
+
+        assertEquals(null, cache.put("c", "C"));
+        expectedPutCount++;
+        assertStatistics(cache);
+        assertHit(cache, "a", "A");
+        assertHit(cache, "b", "B");
+        assertHit(cache, "c", "C");
+        assertSnapshot(cache, "a", "A", "b", "B", "c", "C");
+
+        assertEquals(null, cache.put("d", "D"));
+        expectedPutCount++;
+        expectedEvictionCount++; // a should have been evicted
+        assertStatistics(cache);
+        assertMiss(cache, "a");
+        assertHit(cache, "b", "B");
+        assertHit(cache, "c", "C");
+        assertHit(cache, "d", "D");
+        assertHit(cache, "b", "B");
+        assertHit(cache, "c", "C");
+        assertSnapshot(cache, "d", "D", "b", "B", "c", "C");
+
+        assertEquals(null, cache.put("e", "E"));
+        expectedPutCount++;
+        expectedEvictionCount++; // d should have been evicted
+        assertStatistics(cache);
+        assertMiss(cache, "d");
+        assertMiss(cache, "a");
+        assertHit(cache, "e", "E");
+        assertHit(cache, "b", "B");
+        assertHit(cache, "c", "C");
+        assertSnapshot(cache, "e", "E", "b", "B", "c", "C");
+    }
+
+    @Test
+    public void testStatisticsWithCreate() {
+        LruCache<String, String> cache = newCreatingCache();
+        assertStatistics(cache);
+
+        assertCreated(cache, "aa", "created-aa");
+        assertHit(cache, "aa", "created-aa");
+        assertSnapshot(cache, "aa", "created-aa");
+
+        assertCreated(cache, "bb", "created-bb");
+        assertMiss(cache, "c");
+        assertSnapshot(cache, "aa", "created-aa", "bb", "created-bb");
+
+        assertCreated(cache, "cc", "created-cc");
+        assertSnapshot(cache, "aa", "created-aa", "bb", "created-bb", "cc", "created-cc");
+
+        expectedEvictionCount++; // aa will be evicted
+        assertCreated(cache, "dd", "created-dd");
+        assertSnapshot(cache, "bb", "created-bb",  "cc", "created-cc", "dd", "created-dd");
+
+        expectedEvictionCount++; // bb will be evicted
+        assertCreated(cache, "aa", "created-aa");
+        assertSnapshot(cache, "cc", "created-cc", "dd", "created-dd", "aa", "created-aa");
+    }
+
+    @Test
+    public void testCreateOnCacheMiss() {
+        LruCache<String, String> cache = newCreatingCache();
+        String created = cache.get("aa");
+        assertEquals("created-aa", created);
+    }
+
+    @Test
+    public void testNoCreateOnCacheHit() {
+        LruCache<String, String> cache = newCreatingCache();
+        cache.put("aa", "put-aa");
+        assertEquals("put-aa", cache.get("aa"));
+    }
+
+    @Test
+    public void testConstructorDoesNotAllowZeroCacheSize() {
+        try {
+            new LruCache<String, String>(0);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    @Test
+    public void testCannotPutNullKey() {
+        LruCache<String, String> cache = new LruCache<String, String>(3);
+        try {
+            cache.put(null, "A");
+            fail();
+        } catch (NullPointerException expected) {
+        }
+    }
+
+    @Test
+    public void testCannotPutNullValue() {
+        LruCache<String, String> cache = new LruCache<String, String>(3);
+        try {
+            cache.put("a", null);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+    }
+
+    @Test
+    public void testEvictionWithSingletonCache() {
+        LruCache<String, String> cache = new LruCache<String, String>(1);
+        cache.put("a", "A");
+        cache.put("b", "B");
+        assertSnapshot(cache, "b", "B");
+    }
+
+    @Test
+    public void testEntryEvictedWhenFull() {
+        List<String> log = new ArrayList<String>();
+        LruCache<String, String> cache = newRemovalLogCache(log);
+
+        cache.put("a", "A");
+        cache.put("b", "B");
+        cache.put("c", "C");
+        assertEquals(Collections.<String>emptyList(), log);
+
+        cache.put("d", "D");
+        assertEquals(Arrays.asList("a=A"), log);
+    }
+
+    /**
+     * Replacing the value for a key doesn't cause an eviction but it does bring
+     * the replaced entry to the front of the queue.
+     */
+    @Test
+    public void testPutCauseEviction() {
+        List<String> log = new ArrayList<String>();
+        LruCache<String, String> cache = newRemovalLogCache(log);
+
+        cache.put("a", "A");
+        cache.put("b", "B");
+        cache.put("c", "C");
+        cache.put("b", "B2");
+        assertEquals(Arrays.asList("b=B>B2"), log);
+        assertSnapshot(cache, "a", "A", "c", "C", "b", "B2");
+    }
+
+    @Test
+    public void testCustomSizesImpactsSize() {
+        LruCache<String, String> cache = new LruCache<String, String>(10) {
+            @Override protected int sizeOf(String key, String value) {
+                return key.length() + value.length();
+            }
+        };
+
+        assertEquals(0, cache.size());
+        cache.put("a", "AA");
+        assertEquals(3, cache.size());
+        cache.put("b", "BBBB");
+        assertEquals(8, cache.size());
+        cache.put("a", "");
+        assertEquals(6, cache.size());
+    }
+
+    @Test
+    public void testEvictionWithCustomSizes() {
+        LruCache<String, String> cache = new LruCache<String, String>(4) {
+            @Override protected int sizeOf(String key, String value) {
+                return value.length();
+            }
+        };
+
+        cache.put("a", "AAAA");
+        assertSnapshot(cache, "a", "AAAA");
+        cache.put("b", "BBBB"); // should evict a
+        assertSnapshot(cache, "b", "BBBB");
+        cache.put("c", "CC"); // should evict b
+        assertSnapshot(cache, "c", "CC");
+        cache.put("d", "DD");
+        assertSnapshot(cache, "c", "CC", "d", "DD");
+        cache.put("e", "E"); // should evict c
+        assertSnapshot(cache, "d", "DD", "e", "E");
+        cache.put("f", "F");
+        assertSnapshot(cache, "d", "DD", "e", "E", "f", "F");
+        cache.put("g", "G"); // should evict d
+        assertSnapshot(cache, "e", "E", "f", "F", "g", "G");
+        cache.put("h", "H");
+        assertSnapshot(cache, "e", "E", "f", "F", "g", "G", "h", "H");
+        cache.put("i", "III"); // should evict e, f, and g
+        assertSnapshot(cache, "h", "H", "i", "III");
+        cache.put("j", "JJJ"); // should evict h and i
+        assertSnapshot(cache, "j", "JJJ");
+    }
+
+    @Test
+    public void testEvictionThrowsWhenSizesAreInconsistent() {
+        LruCache<String, int[]> cache = new LruCache<String, int[]>(4) {
+            @Override protected int sizeOf(String key, int[] value) {
+                return value[0];
+            }
+        };
+
+        int[] a = { 4 };
+        cache.put("a", a);
+
+        // get the cache size out of sync
+        a[0] = 1;
+        assertEquals(4, cache.size());
+
+        // evict something
+        try {
+            cache.put("b", new int[] { 2 });
+            fail();
+        } catch (IllegalStateException expected) {
+        }
+    }
+
+    @Test
+    public void testEvictionThrowsWhenSizesAreNegative() {
+        LruCache<String, String> cache = new LruCache<String, String>(4) {
+            @Override protected int sizeOf(String key, String value) {
+                return -1;
+            }
+        };
+
+        try {
+            cache.put("a", "A");
+            fail();
+        } catch (IllegalStateException expected) {
+        }
+    }
+
+    /**
+     * Naive caches evict at most one element at a time. This is problematic
+     * because evicting a small element may be insufficient to make room for a
+     * large element.
+     */
+    @Test
+    public void testDifferentElementSizes() {
+        LruCache<String, String> cache = new LruCache<String, String>(10) {
+            @Override protected int sizeOf(String key, String value) {
+                return value.length();
+            }
+        };
+
+        cache.put("a", "1");
+        cache.put("b", "12345678");
+        cache.put("c", "1");
+        assertSnapshot(cache, "a", "1", "b", "12345678", "c", "1");
+        cache.put("d", "12345678"); // should evict a and b
+        assertSnapshot(cache, "c", "1", "d", "12345678");
+        cache.put("e", "12345678"); // should evict c and d
+        assertSnapshot(cache, "e", "12345678");
+    }
+
+    @Test
+    public void testEvictAll() {
+        List<String> log = new ArrayList<String>();
+        LruCache<String, String> cache = newRemovalLogCache(log);
+        cache.put("a", "A");
+        cache.put("b", "B");
+        cache.put("c", "C");
+        cache.evictAll();
+        assertEquals(0, cache.size());
+        assertEquals(Arrays.asList("a=A", "b=B", "c=C"), log);
+    }
+
+    @Test
+    public void testEvictAllEvictsSizeZeroElements() {
+        LruCache<String, String> cache = new LruCache<String, String>(10) {
+            @Override protected int sizeOf(String key, String value) {
+                return 0;
+            }
+        };
+
+        cache.put("a", "A");
+        cache.put("b", "B");
+        cache.evictAll();
+        assertSnapshot(cache);
+    }
+
+    @Test
+    public void testRemoveWithCustomSizes() {
+        LruCache<String, String> cache = new LruCache<String, String>(10) {
+            @Override protected int sizeOf(String key, String value) {
+                return value.length();
+            }
+        };
+        cache.put("a", "123456");
+        cache.put("b", "1234");
+        cache.remove("a");
+        assertEquals(4, cache.size());
+    }
+
+    @Test
+    public void testRemoveAbsentElement() {
+        LruCache<String, String> cache = new LruCache<String, String>(10);
+        cache.put("a", "A");
+        cache.put("b", "B");
+        assertEquals(null, cache.remove("c"));
+        assertEquals(2, cache.size());
+    }
+
+    @Test
+    public void testRemoveNullThrows() {
+        LruCache<String, String> cache = new LruCache<String, String>(10);
+        try {
+            cache.remove(null);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+    }
+
+    @Test
+    public void testRemoveCallsEntryRemoved() {
+        List<String> log = new ArrayList<String>();
+        LruCache<String, String> cache = newRemovalLogCache(log);
+        cache.put("a", "A");
+        cache.remove("a");
+        assertEquals(Arrays.asList("a=A>null"), log);
+    }
+
+    @Test
+    public void testPutCallsEntryRemoved() {
+        List<String> log = new ArrayList<String>();
+        LruCache<String, String> cache = newRemovalLogCache(log);
+        cache.put("a", "A");
+        cache.put("a", "A2");
+        assertEquals(Arrays.asList("a=A>A2"), log);
+    }
+
+    @Test
+    public void testEntryRemovedIsCalledWithoutSynchronization() {
+        LruCache<String, String> cache = new LruCache<String, String>(3) {
+            @Override protected void entryRemoved(
+                    boolean evicted, String key, String oldValue, String newValue) {
+                assertFalse(Thread.holdsLock(this));
+            }
+        };
+
+        cache.put("a", "A");
+        cache.put("a", "A2"); // replaced
+        cache.put("b", "B");
+        cache.put("c", "C");
+        cache.put("d", "D");  // single eviction
+        cache.remove("a");    // removed
+        cache.evictAll();     // multiple eviction
+    }
+
+    @Test
+    public void testCreateIsCalledWithoutSynchronization() {
+        LruCache<String, String> cache = new LruCache<String, String>(3) {
+            @Override protected String create(String key) {
+                assertFalse(Thread.holdsLock(this));
+                return null;
+            }
+        };
+
+        cache.get("a");
+    }
+
+    /**
+     * Test what happens when a value is added to the map while create is
+     * working. The map value should be returned by get(), and the created value
+     * should be released with entryRemoved().
+     */
+    @Test
+    public void testCreateWithConcurrentPut() {
+        final List<String> log = new ArrayList<String>();
+        LruCache<String, String> cache = new LruCache<String, String>(3) {
+            @Override protected String create(String key) {
+                put(key, "B");
+                return "A";
+            }
+            @Override protected void entryRemoved(
+                    boolean evicted, String key, String oldValue, String newValue) {
+                log.add(key + "=" + oldValue + ">" + newValue);
+            }
+        };
+
+        assertEquals("B", cache.get("a"));
+        assertEquals(Arrays.asList("a=A>B"), log);
+    }
+
+    /**
+     * Test what happens when two creates happen concurrently. The result from
+     * the first create to return is returned by both gets. The other created
+     * values should be released with entryRemove().
+     */
+    @Test
+    public void testCreateWithConcurrentCreate() {
+        final List<String> log = new ArrayList<String>();
+        LruCache<String, Integer> cache = new LruCache<String, Integer>(3) {
+            int callCount = 0;
+            @Override protected Integer create(String key) {
+                if (callCount++ == 0) {
+                    assertEquals(2, get(key).intValue());
+                    return 1;
+                } else {
+                    return 2;
+                }
+            }
+            @Override protected void entryRemoved(
+                    boolean evicted, String key, Integer oldValue, Integer newValue) {
+                log.add(key + "=" + oldValue + ">" + newValue);
+            }
+        };
+
+        assertEquals(2, cache.get("a").intValue());
+        assertEquals(Arrays.asList("a=1>2"), log);
+    }
+
+    private LruCache<String, String> newCreatingCache() {
+        return new LruCache<String, String>(3) {
+            @Override protected String create(String key) {
+                return (key.length() > 1) ? ("created-" + key) : null;
+            }
+        };
+    }
+
+    private LruCache<String, String> newRemovalLogCache(final List<String> log) {
+        return new LruCache<String, String>(3) {
+            @Override protected void entryRemoved(
+                    boolean evicted, String key, String oldValue, String newValue) {
+                String message = evicted
+                        ? (key + "=" + oldValue)
+                        : (key + "=" + oldValue + ">" + newValue);
+                log.add(message);
+            }
+        };
+    }
+
+    private void assertHit(LruCache<String, String> cache, String key, String value) {
+        assertEquals(value, cache.get(key));
+        expectedHitCount++;
+        assertStatistics(cache);
+    }
+
+    private void assertMiss(LruCache<String, String> cache, String key) {
+        assertEquals(null, cache.get(key));
+        expectedMissCount++;
+        assertStatistics(cache);
+    }
+
+    private void assertCreated(LruCache<String, String> cache, String key, String value) {
+        assertEquals(value, cache.get(key));
+        expectedMissCount++;
+        expectedCreateCount++;
+        assertStatistics(cache);
+    }
+
+    private void assertStatistics(LruCache<?, ?> cache) {
+        assertEquals("create count", expectedCreateCount, cache.createCount());
+        assertEquals("put count", expectedPutCount, cache.putCount());
+        assertEquals("hit count", expectedHitCount, cache.hitCount());
+        assertEquals("miss count", expectedMissCount, cache.missCount());
+        assertEquals("eviction count", expectedEvictionCount, cache.evictionCount());
+    }
+
+    private <T> void assertSnapshot(LruCache<T, T> cache, T... keysAndValues) {
+        List<T> actualKeysAndValues = new ArrayList<T>();
+        for (Map.Entry<T, T> entry : cache.snapshot().entrySet()) {
+            actualKeysAndValues.add(entry.getKey());
+            actualKeysAndValues.add(entry.getValue());
+        }
+
+        // assert using lists because order is important for LRUs
+        assertEquals(Arrays.asList(keysAndValues), actualKeysAndValues);
+    }
+}
diff --git a/tests/tests/widget/src/android/widget/cts/TextClockTest.java b/tests/tests/widget/src/android/widget/cts/TextClockTest.java
index 9438ed1..6c35b33 100644
--- a/tests/tests/widget/src/android/widget/cts/TextClockTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextClockTest.java
@@ -197,11 +197,6 @@
                             countDownAndRemove();
                         }
 
-                        @Override
-                        public void onChange(boolean selfChange, Uri uri, int userId) {
-                            countDownAndRemove();
-                        }
-
                         private void countDownAndRemove() {
                             latch.countDown();
                             resolver.unregisterContentObserver(this);
diff --git a/tools/cts-media-preparer-app/Android.bp b/tools/cts-media-preparer-app/Android.bp
index 400dac7..5991f8b 100644
--- a/tools/cts-media-preparer-app/Android.bp
+++ b/tools/cts-media-preparer-app/Android.bp
@@ -34,4 +34,5 @@
         "mts",
     ],
     sdk_version: "test_current",
+    min_sdk_version: "29",
 }
diff --git a/tools/cts-media-preparer-app/AndroidManifest.xml b/tools/cts-media-preparer-app/AndroidManifest.xml
index 15afba4..789ea99 100644
--- a/tools/cts-media-preparer-app/AndroidManifest.xml
+++ b/tools/cts-media-preparer-app/AndroidManifest.xml
@@ -22,7 +22,7 @@
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
-
+    <uses-sdk android:minSdkVersion="29"   android:targetSdkVersion="29" />
     <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
             android:targetPackage="android.mediastress.cts.preconditions.app"
             android:label="Device-side CTS mediastress preparation" />