Merge "Adding leaked stack check"
diff --git a/apps/CameraITS/tests/scene0/test_unified_timestamps.py b/apps/CameraITS/tests/scene0/test_unified_timestamps.py
index 99dcf3f..e377feb 100644
--- a/apps/CameraITS/tests/scene0/test_unified_timestamps.py
+++ b/apps/CameraITS/tests/scene0/test_unified_timestamps.py
@@ -25,6 +25,7 @@
 
     with its.device.ItsSession() as cam:
         props = cam.get_camera_properties()
+        props = cam.override_with_hidden_physical_camera_props(props)
 
         # Only run test if the appropriate caps are claimed.
         its.caps.skip_unless(its.caps.sensor_fusion(props) and
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index c5c8077..660d95a 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -119,7 +119,8 @@
                 'test_burst_capture',
                 'test_metadata',
                 'test_read_write',
-                'test_sensor_events'
+                'test_sensor_events',
+                'test_unified_timestamps'
         ],
         'scene1_1': [
                 'test_exposure',
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/BitmapUtils.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/BitmapUtils.java
index 88753b1..d1fb166 100644
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/BitmapUtils.java
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/BitmapUtils.java
@@ -16,6 +16,8 @@
 
 package com.android.compatibility.common.util;
 
+import static org.junit.Assert.assertTrue;
+
 import android.app.WallpaperManager;
 import android.content.Context;
 import android.graphics.Bitmap;
@@ -56,6 +58,14 @@
                     + "bmp2=(" + bmp2.getWidth() + "x" + bmp2.getHeight() + ")");
             return Boolean.FALSE;
         }
+
+        if (bmp1.getConfig() != bmp2.getConfig()) {
+            Log.d(TAG, "compareBitmaps() failed because configs don't match "
+                    + "bmp1=(" + bmp1.getConfig() + "), "
+                    + "bmp2=(" + bmp2.getConfig() + ")");
+            return Boolean.FALSE;
+        }
+
         return null;
     }
 
@@ -177,4 +187,78 @@
             e.printStackTrace();
         }
     }
+
+    // Compare expected to actual to see if their diff is less than mseMargin.
+    // lessThanMargin is to indicate whether we expect the diff to be
+    // "less than" or "no less than".
+    public static boolean compareBitmapsMse(Bitmap expected, Bitmap actual,
+            int mseMargin, boolean lessThanMargin, boolean isPremultiplied) {
+        final Boolean basicComparison = compareBasicBitmapsInfo(expected, actual);
+        if (basicComparison != null) return basicComparison.booleanValue();
+
+        double mse = 0;
+        int width = expected.getWidth();
+        int height = expected.getHeight();
+
+        // Bitmap.getPixels() returns colors with non-premultiplied ARGB values.
+        int[] expColors = new int [width * height];
+        expected.getPixels(expColors, 0, width, 0, 0, width, height);
+
+        int[] actualColors = new int [width * height];
+        actual.getPixels(actualColors, 0, width, 0, 0, width, height);
+
+        for (int row = 0; row < height; ++row) {
+            for (int col = 0; col < width; ++col) {
+                int idx = row * width + col;
+                mse += distance(expColors[idx], actualColors[idx], isPremultiplied);
+            }
+        }
+        mse /= width * height;
+
+        Log.i(TAG, "MSE: " + mse);
+        if (lessThanMargin) {
+            if (mse > mseMargin) {
+                Log.d(TAG, "MSE too large for normal case: " + mse);
+                return false;
+            }
+            return true;
+        } else {
+            if (mse <= mseMargin) {
+                Log.d(TAG, "MSE too small for abnormal case: " + mse);
+                return false;
+            }
+            return true;
+        }
+    }
+
+    // Same as above, but asserts compareBitmapsMse's return value.
+    public static void assertBitmapsMse(Bitmap expected, Bitmap actual,
+            int mseMargin, boolean lessThanMargin, boolean isPremultiplied) {
+        assertTrue(compareBitmapsMse(expected, actual, mseMargin, lessThanMargin, isPremultiplied));
+    }
+
+    private static int multiplyAlpha(int color, int alpha) {
+        return (color * alpha + 127) / 255;
+    }
+
+    // For the Bitmap with Alpha, multiply the Alpha values to get the effective
+    // RGB colors and then compute the color-distance.
+    private static double distance(int expect, int actual, boolean isPremultiplied) {
+        if (isPremultiplied) {
+            final int a1 = Color.alpha(actual);
+            final int a2 = Color.alpha(expect);
+            final int r = multiplyAlpha(Color.red(actual), a1) -
+                    multiplyAlpha(Color.red(expect), a2);
+            final int g = multiplyAlpha(Color.green(actual), a1) -
+                    multiplyAlpha(Color.green(expect), a2);
+            final int b = multiplyAlpha(Color.blue(actual), a1) -
+                    multiplyAlpha(Color.blue(expect), a2);
+            return r * r + g * g + b * b;
+        } else {
+            int r = Color.red(actual) - Color.red(expect);
+            int g = Color.green(actual) - Color.green(expect);
+            int b = Color.blue(actual) - Color.blue(expect);
+            return r * r + g * g + b * b;
+        }
+    }
 }
diff --git a/hostsidetests/appbinding/hostside/AndroidTest.xml b/hostsidetests/appbinding/hostside/AndroidTest.xml
index 54dad24..4d96aec 100644
--- a/hostsidetests/appbinding/hostside/AndroidTest.xml
+++ b/hostsidetests/appbinding/hostside/AndroidTest.xml
@@ -20,6 +20,7 @@
     <!-- Instant apps can't be the default SMS app. -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
 
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="am wait-for-broadcast-idle" />
diff --git a/hostsidetests/backup/src/android/cts/backup/BaseMultiUserBackupHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/BaseMultiUserBackupHostSideTest.java
index c1171ac..26c6345 100644
--- a/hostsidetests/backup/src/android/cts/backup/BaseMultiUserBackupHostSideTest.java
+++ b/hostsidetests/backup/src/android/cts/backup/BaseMultiUserBackupHostSideTest.java
@@ -139,7 +139,7 @@
      * {@link String} name of the local transport.
      */
     String switchUserToLocalTransportAndAssertSuccess(int userId)
-            throws IOException, InterruptedException {
+            throws Exception {
         // Make sure the user has the local transport.
         String localTransport = mBackupUtils.getLocalTransportName();
 
@@ -147,7 +147,7 @@
         // initialization. Transports won't be available until they are initialized/registered.
         CommonTestUtils.waitUntil("wait for user to have local transport",
                 TRANSPORT_INITIALIZATION_TIMEOUT_SECS,
-                () -> mBackupUtils.userHasBackupTransport(localTransport, userId));
+                () -> userHasBackupTransport(localTransport, userId));
 
         // Switch to the local transport and assert success.
         mBackupUtils.setBackupTransportForUser(localTransport, userId);
@@ -156,6 +156,18 @@
         return localTransport;
     }
 
+    // TODO(b/139652329): Move to backup utils.
+    private boolean userHasBackupTransport(
+            String transport, int userId) throws DeviceNotAvailableException {
+        String output = mDevice.executeShellCommand("bmgr --user " + userId + " list transports");
+        for (String t : output.split(" ")) {
+            if (transport.equals(t.replace("*", "").trim())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /** Runs "bmgr --user <id> wipe <transport> <package>" to clear the backup data. */
     void clearBackupDataInTransportForUser(String packageName, String transport, int userId)
             throws DeviceNotAvailableException {
diff --git a/hostsidetests/bootstats/AndroidTest.xml b/hostsidetests/bootstats/AndroidTest.xml
index a22479d..e5d78ee 100644
--- a/hostsidetests/bootstats/AndroidTest.xml
+++ b/hostsidetests/bootstats/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="sysui" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
         <option name="jar" value="CtsBootStatsTestCases.jar" />
         <option name="runtime-hint" value="1m" />
diff --git a/hostsidetests/content/AndroidTest.xml b/hostsidetests/content/AndroidTest.xml
index e13a5d9..136550e 100644
--- a/hostsidetests/content/AndroidTest.xml
+++ b/hostsidetests/content/AndroidTest.xml
@@ -19,6 +19,7 @@
     <!-- This is a test for account data sync and READ_SYNC_SETTINGS/WRITE_SYNC_SETTINGS are required, which instant apps don't have -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
         <option name="jar" value="CtsSyncContentHostTestCases.jar" />
         <option name="runtime-hint" value="2m" />
diff --git a/hostsidetests/edi/AndroidTest.xml b/hostsidetests/edi/AndroidTest.xml
index aea1030..acd6b57 100644
--- a/hostsidetests/edi/AndroidTest.xml
+++ b/hostsidetests/edi/AndroidTest.xml
@@ -19,6 +19,7 @@
     <!-- Do no need to run instant mode for collecting information -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
         <option name="jar" value="CtsEdiHostTestCases.jar" />
     </test>
diff --git a/hostsidetests/jvmti/allocation-tracking/AndroidTest.xml b/hostsidetests/jvmti/allocation-tracking/AndroidTest.xml
index 0760f04..3e33f5d 100644
--- a/hostsidetests/jvmti/allocation-tracking/AndroidTest.xml
+++ b/hostsidetests/jvmti/allocation-tracking/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/redefining/AndroidTest.xml b/hostsidetests/jvmti/redefining/AndroidTest.xml
index a7d8d669..cf6a724 100644
--- a/hostsidetests/jvmti/redefining/AndroidTest.xml
+++ b/hostsidetests/jvmti/redefining/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1900/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1900/AndroidTest.xml
index b6f221d..9d804de 100644
--- a/hostsidetests/jvmti/run-tests/test-1900/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1900/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1901/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1901/AndroidTest.xml
index 40e788a..c6b755f 100644
--- a/hostsidetests/jvmti/run-tests/test-1901/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1901/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1902/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1902/AndroidTest.xml
index 00861dc..2194c0f 100644
--- a/hostsidetests/jvmti/run-tests/test-1902/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1902/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1903/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1903/AndroidTest.xml
index 45bfca2..12a4eb3 100644
--- a/hostsidetests/jvmti/run-tests/test-1903/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1903/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1904/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1904/AndroidTest.xml
index de81390..3730edf 100644
--- a/hostsidetests/jvmti/run-tests/test-1904/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1904/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1906/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1906/AndroidTest.xml
index 93d6f5a..73e3c55 100644
--- a/hostsidetests/jvmti/run-tests/test-1906/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1906/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1907/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1907/AndroidTest.xml
index a3ecbe8..958ba54 100644
--- a/hostsidetests/jvmti/run-tests/test-1907/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1907/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1908/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1908/AndroidTest.xml
index c3645b7..767c8c0 100644
--- a/hostsidetests/jvmti/run-tests/test-1908/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1908/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1909/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1909/AndroidTest.xml
index b7f4690..7b7234c 100644
--- a/hostsidetests/jvmti/run-tests/test-1909/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1909/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1910/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1910/AndroidTest.xml
index 323662a..0a2105d 100644
--- a/hostsidetests/jvmti/run-tests/test-1910/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1910/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1911/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1911/AndroidTest.xml
index 98f36dd..7024b6d 100644
--- a/hostsidetests/jvmti/run-tests/test-1911/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1911/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1912/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1912/AndroidTest.xml
index b9202e1..7df6705 100644
--- a/hostsidetests/jvmti/run-tests/test-1912/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1912/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1913/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1913/AndroidTest.xml
index bb270d3..6b24252 100644
--- a/hostsidetests/jvmti/run-tests/test-1913/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1913/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1914/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1914/AndroidTest.xml
index 8657601..a1f09a8 100644
--- a/hostsidetests/jvmti/run-tests/test-1914/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1914/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1915/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1915/AndroidTest.xml
index ca42ad0..ee00dbf 100644
--- a/hostsidetests/jvmti/run-tests/test-1915/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1915/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1916/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1916/AndroidTest.xml
index 55a3bbf..f25aabc 100644
--- a/hostsidetests/jvmti/run-tests/test-1916/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1916/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1917/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1917/AndroidTest.xml
index f049040..9ca810a 100644
--- a/hostsidetests/jvmti/run-tests/test-1917/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1917/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1920/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1920/AndroidTest.xml
index bcc276e..45ed21c 100644
--- a/hostsidetests/jvmti/run-tests/test-1920/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1920/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1921/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1921/AndroidTest.xml
index de35460..5dbb903 100644
--- a/hostsidetests/jvmti/run-tests/test-1921/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1921/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1922/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1922/AndroidTest.xml
index 7fa7d38..df75763 100644
--- a/hostsidetests/jvmti/run-tests/test-1922/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1922/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1923/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1923/AndroidTest.xml
index d12cc61..af1c0d2 100644
--- a/hostsidetests/jvmti/run-tests/test-1923/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1923/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1924/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1924/AndroidTest.xml
index a9a8245..2d50d4e 100644
--- a/hostsidetests/jvmti/run-tests/test-1924/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1924/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1925/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1925/AndroidTest.xml
index 0c003be..1ccdb93 100644
--- a/hostsidetests/jvmti/run-tests/test-1925/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1925/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1926/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1926/AndroidTest.xml
index c12ae92..f4ec859 100644
--- a/hostsidetests/jvmti/run-tests/test-1926/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1926/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1927/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1927/AndroidTest.xml
index 2154147..0faa802 100644
--- a/hostsidetests/jvmti/run-tests/test-1927/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1927/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1928/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1928/AndroidTest.xml
index 3691021..096f5ac 100644
--- a/hostsidetests/jvmti/run-tests/test-1928/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1928/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1930/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1930/AndroidTest.xml
index de9822c..a6c5946 100644
--- a/hostsidetests/jvmti/run-tests/test-1930/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1930/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1931/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1931/AndroidTest.xml
index 1a37af6..8fed4bf 100644
--- a/hostsidetests/jvmti/run-tests/test-1931/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1931/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1932/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1932/AndroidTest.xml
index 6e5f0b1c..2bb94ab 100644
--- a/hostsidetests/jvmti/run-tests/test-1932/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1932/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1933/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1933/AndroidTest.xml
index 90df47b..324aded 100644
--- a/hostsidetests/jvmti/run-tests/test-1933/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1933/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1934/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1934/AndroidTest.xml
index fbb5a20..6023b6c 100644
--- a/hostsidetests/jvmti/run-tests/test-1934/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1934/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1936/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1936/AndroidTest.xml
index 8605d7e..ac194a0 100644
--- a/hostsidetests/jvmti/run-tests/test-1936/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1936/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1937/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1937/AndroidTest.xml
index c2b38b1..0f6daef 100644
--- a/hostsidetests/jvmti/run-tests/test-1937/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1937/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1939/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1939/AndroidTest.xml
index 62a9fe5..e96dcfe 100644
--- a/hostsidetests/jvmti/run-tests/test-1939/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1939/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1941/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1941/AndroidTest.xml
index b958615..3dd86fd 100644
--- a/hostsidetests/jvmti/run-tests/test-1941/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1941/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1942/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1942/AndroidTest.xml
index 82d03a6..7bb68e8 100644
--- a/hostsidetests/jvmti/run-tests/test-1942/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1942/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1943/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1943/AndroidTest.xml
index 997f914..008b29b 100644
--- a/hostsidetests/jvmti/run-tests/test-1943/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1943/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1953/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1953/AndroidTest.xml
index 3e4e876..3f0c776 100644
--- a/hostsidetests/jvmti/run-tests/test-1953/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1953/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-1958/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-1958/AndroidTest.xml
index b30faae..8157bc0 100644
--- a/hostsidetests/jvmti/run-tests/test-1958/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-1958/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
index 25f2011..0048286 100644
--- a/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-902/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
index 0d2d039..367c94a 100644
--- a/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-903/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
index 8a0f43e..08940e0 100644
--- a/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-904/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
index 3aa6007..47a24ce 100644
--- a/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-905/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
index 47d077a..7ced7af 100644
--- a/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-906/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
index b38c4c0..824ee11 100644
--- a/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-907/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
index f4713e3..e4b1118 100644
--- a/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-908/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
index 4ea65ee..9b17239 100644
--- a/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-910/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
index 4990071..28c8a49 100644
--- a/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-911/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml
index fe7c701..f5b2e82 100644
--- a/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-912/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
index 3b44442..6f37953 100644
--- a/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-913/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
index 5652db8..1efafdc 100644
--- a/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-914/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
index eee4d4b..75ae500 100644
--- a/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-915/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
index bb4ba24..1a425de 100644
--- a/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-917/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
index 85dbdda..2421692 100644
--- a/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-918/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
index d90b9e5..c7331d2 100644
--- a/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-919/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
index 38eb72f..c2ee06b 100644
--- a/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-920/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
index 4389b10..04dac54 100644
--- a/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-922/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
index 1ecad38..3dbdbab 100644
--- a/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-923/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
index 50f690b..71226b5 100644
--- a/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-924/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
index f4552db..db33dcf 100644
--- a/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-926/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
index 9f5e79e..003fd7a 100644
--- a/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-927/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
index 9d38cf8..f8a7fac 100644
--- a/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-928/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
index 7c3852f..184c200 100644
--- a/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-930/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
index d11e522..bb07042 100644
--- a/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-931/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
index 5bc2b52..5395e43 100644
--- a/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-932/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
index 98709d4..9dc655c 100644
--- a/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-940/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
index 3404377..3359fdd 100644
--- a/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-942/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
index 1949c01..f0d69c5 100644
--- a/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-944/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
index a40edaa..6a941ee 100644
--- a/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-945/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
index cbb508f..e36b1c9 100644
--- a/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-947/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
index 0d3aa78..7821b7e 100644
--- a/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-951/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
index d946a36..0283963 100644
--- a/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-982/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-983/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-983/AndroidTest.xml
index 33bee46..6299497 100644
--- a/hostsidetests/jvmti/run-tests/test-983/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-983/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art"/>
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true"/>
diff --git a/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
index e97d9ad..523cc8b 100644
--- a/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-984/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
index 8554795..d1bf3bf 100644
--- a/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-985/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
index 016545d..336cd3c 100644
--- a/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-986/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-988/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-988/AndroidTest.xml
index 5db646a..469494c 100644
--- a/hostsidetests/jvmti/run-tests/test-988/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-988/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-989/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-989/AndroidTest.xml
index c590530..316271d 100644
--- a/hostsidetests/jvmti/run-tests/test-989/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-989/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-990/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-990/AndroidTest.xml
index 8f1e64b..2cd94a6 100644
--- a/hostsidetests/jvmti/run-tests/test-990/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-990/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-991/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-991/AndroidTest.xml
index 94b67ae..bfe86f1 100644
--- a/hostsidetests/jvmti/run-tests/test-991/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-991/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-992/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-992/AndroidTest.xml
index 437521e..6a9d4c3 100644
--- a/hostsidetests/jvmti/run-tests/test-992/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-992/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-993/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-993/AndroidTest.xml
index cf92806..aa4faa7 100644
--- a/hostsidetests/jvmti/run-tests/test-993/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-993/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-994/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-994/AndroidTest.xml
index a97b540..bcd4211 100644
--- a/hostsidetests/jvmti/run-tests/test-994/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-994/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-995/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-995/AndroidTest.xml
index cf3fe8a..4c6e4d3 100644
--- a/hostsidetests/jvmti/run-tests/test-995/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-995/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-996/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-996/AndroidTest.xml
index 4b67330..025d6d4 100644
--- a/hostsidetests/jvmti/run-tests/test-996/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-996/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/run-tests/test-997/AndroidTest.xml b/hostsidetests/jvmti/run-tests/test-997/AndroidTest.xml
index 5f36fc3..ffecdca 100644
--- a/hostsidetests/jvmti/run-tests/test-997/AndroidTest.xml
+++ b/hostsidetests/jvmti/run-tests/test-997/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/jvmti/tagging/AndroidTest.xml b/hostsidetests/jvmti/tagging/AndroidTest.xml
index e4dd279..2129bb0 100644
--- a/hostsidetests/jvmti/tagging/AndroidTest.xml
+++ b/hostsidetests/jvmti/tagging/AndroidTest.xml
@@ -18,6 +18,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/hostsidetests/net/AndroidTest.xml b/hostsidetests/net/AndroidTest.xml
index 5479c51..6ba6f42 100644
--- a/hostsidetests/net/AndroidTest.xml
+++ b/hostsidetests/net/AndroidTest.xml
@@ -20,8 +20,6 @@
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
     <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
 
-    <target_preparer class="com.android.cts.net.NetPolicyTestsPreparer" />
-
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="teardown-command" value="cmd power set-mode 0" />
         <option name="teardown-command" value="cmd battery reset" />
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java
index d06ab13..51bdf8e 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractAppIdleTestCase.java
@@ -131,11 +131,11 @@
     @RequiredProperties({BATTERY_SAVER_MODE})
     @Test
     public void testAppIdleNetworkAccess_whenCharging() throws Exception {
-        // Check that app is paroled when charging
+        // Check that idle app doesn't get network when charging
         setAppIdle(true);
         assertBackgroundNetworkAccess(false);
         turnBatteryOff();
-        assertBackgroundNetworkAccess(true);
+        assertBackgroundNetworkAccess(false);
         turnBatteryOn();
         assertBackgroundNetworkAccess(false);
 
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
index 57b7bb4..529b640 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
@@ -164,14 +164,6 @@
         Log.i(TAG, "Apps status:\n"
                 + "\ttest app: uid=" + mMyUid + ", state=" + getProcessStateByUid(mMyUid) + "\n"
                 + "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid));
-
-        // app_idle_constants set in NetPolicyTestsPreparer.setUp() is not always sucessful (suspect
-        // timing issue), here we set it again to make sure.
-        final String appIdleConstants = "parole_duration=0,stable_charging_threshold=0";
-        executeShellCommand("settings put global app_idle_constants " + appIdleConstants);
-        final String currentConstants =
-                executeShellCommand("settings get global app_idle_constants");
-        assertEquals(appIdleConstants, currentConstants);
     }
 
     protected void tearDown() throws Exception {
diff --git a/hostsidetests/net/src/com/android/cts/net/NetPolicyTestsPreparer.java b/hostsidetests/net/src/com/android/cts/net/NetPolicyTestsPreparer.java
deleted file mode 100644
index bc2ee2c..0000000
--- a/hostsidetests/net/src/com/android/cts/net/NetPolicyTestsPreparer.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2017 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 com.android.cts.net;
-
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil;
-import com.android.tradefed.targetprep.ITargetCleaner;
-import com.android.tradefed.targetprep.ITargetPreparer;
-
-public class NetPolicyTestsPreparer implements ITargetPreparer, ITargetCleaner {
-    private final static String KEY_PAROLE_DURATION = "parole_duration";
-    private final static int DESIRED_PAROLE_DURATION = 0;
-    private final static String KEY_STABLE_CHARGING_THRESHOLD = "stable_charging_threshold";
-    private final static int DESIRED_STABLE_CHARGING_THRESHOLD = 0;
-
-    private ITestDevice mDevice;
-    private String mOriginalAppIdleConsts;
-
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo) throws DeviceNotAvailableException {
-        mDevice = device;
-        mOriginalAppIdleConsts = getAppIdleConstants();
-        setAppIdleConstants(KEY_PAROLE_DURATION + "=" + DESIRED_PAROLE_DURATION + ","
-                + KEY_STABLE_CHARGING_THRESHOLD + "=" + DESIRED_STABLE_CHARGING_THRESHOLD);
-        LogUtil.CLog.d("Original app_idle_constants: " + mOriginalAppIdleConsts);
-    }
-
-    @Override
-    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable throwable)
-            throws DeviceNotAvailableException {
-        setAppIdleConstants(mOriginalAppIdleConsts);
-    }
-
-    private void setAppIdleConstants(String appIdleConstants) throws DeviceNotAvailableException {
-        executeCmd("settings put global app_idle_constants \"" + appIdleConstants + "\"");
-    }
-
-    private String getAppIdleConstants() throws DeviceNotAvailableException {
-        return executeCmd("settings get global app_idle_constants");
-    }
-
-    private String executeCmd(String cmd) throws DeviceNotAvailableException {
-        final String output = mDevice.executeShellCommand(cmd).trim();
-        LogUtil.CLog.d("Output for '%s': %s", cmd, output);
-        return output;
-    }
-}
diff --git a/hostsidetests/rollback/src/com/android/cts/rollback/host/RollbackManagerHostTest.java b/hostsidetests/rollback/src/com/android/cts/rollback/host/RollbackManagerHostTest.java
index de58538..d0ce3e0 100644
--- a/hostsidetests/rollback/src/com/android/cts/rollback/host/RollbackManagerHostTest.java
+++ b/hostsidetests/rollback/src/com/android/cts/rollback/host/RollbackManagerHostTest.java
@@ -81,15 +81,15 @@
             // Device doesn't support updating apex. Nothing to uninstall.
             return;
         }
-        final String errorMessage = getDevice().uninstallPackage(SHIM_APEX_PACKAGE_NAME);
-        if (errorMessage == null) {
-            Log.i(TAG, "Uninstalling shim apex");
-            getDevice().reboot();
-        } else {
-            // Most likely we tried to uninstall system version and failed. It should be fine to
-            // continue tests.
-            // TODO(b/140813980): use ApexInfo.sourceDir to decide whenever to issue an uninstall.
-            Log.w(TAG, "Failed to uninstall shim APEX : " + errorMessage);
+
+        if (getShimApex().sourceDir.startsWith("/data")) {
+            final String errorMessage = getDevice().uninstallPackage(SHIM_APEX_PACKAGE_NAME);
+            if (errorMessage == null) {
+                Log.i(TAG, "Uninstalling shim apex");
+                getDevice().reboot();
+            } else {
+                Log.e(TAG, "Failed to uninstall shim APEX : " + errorMessage);
+            }
         }
         assertThat(getShimApex().versionCode).isEqualTo(1L);
     }
@@ -181,7 +181,6 @@
     public void testApexRollbackExpiration() throws Exception {
         assumeTrue("Device does not support updating APEX", isApexUpdateSupported());
 
-        uninstallShimApexIfNecessary();
         run("testApexRollbackExpiration_Phase1");
         getDevice().reboot();
         run("testApexRollbackExpiration_Phase2");
diff --git a/hostsidetests/securitybulletin/Android.bp b/hostsidetests/securitybulletin/Android.bp
new file mode 100644
index 0000000..71839e6
--- /dev/null
+++ b/hostsidetests/securitybulletin/Android.bp
@@ -0,0 +1,56 @@
+// Copyright (C) 2014 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.
+
+java_test_host {
+    name: "CtsSecurityBulletinHostTestCases",
+    defaults: ["cts_defaults"],
+    srcs: ["src/**/*.java"],
+    java_resource_dirs: ["res"],
+    // tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+        "sts",
+    ],
+    // Must match the package name in CtsTestCaseList.mk
+    libs: [
+        "cts-tradefed",
+        "tradefed",
+        "compatibility-host-util",
+    ],
+}
+
+cc_defaults {
+    name: "cts_hostsidetests_securitybulletin_defaults",
+    compile_multilib: "both",
+    multilib: {
+        lib32: {
+            suffix: "32",
+        },
+        lib64: {
+            suffix: "64",
+        },
+    },
+    arch: {
+        arm: {
+            instruction_set: "arm",
+        },
+    },
+    test_suites: [
+        "cts",
+        "vts",
+        "sts",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/Android.mk b/hostsidetests/securitybulletin/Android.mk
index fc814a5..bbf61ce 100644
--- a/hostsidetests/securitybulletin/Android.mk
+++ b/hostsidetests/securitybulletin/Android.mk
@@ -12,28 +12,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_RESOURCE_DIRS := res
-
-LOCAL_MODULE_TAGS := optional
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-
-# Must match the package name in CtsTestCaseList.mk
-LOCAL_MODULE := CtsSecurityBulletinHostTestCases
-
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
-
-LOCAL_CTS_TEST_PACKAGE := android.host.security
-
-include $(BUILD_CTS_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(call all-subdir-makefiles)
diff --git a/hostsidetests/securitybulletin/res/bug_139806216.pac b/hostsidetests/securitybulletin/res/bug_139806216.pac
new file mode 100644
index 0000000..3a1e34d
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/bug_139806216.pac
@@ -0,0 +1,4 @@
+function FindProxyForURL(url, host){
+    var x = new ArrayBuffer(1);
+    return "DIRECT";
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/Android.bp b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/Android.bp
new file mode 100644
index 0000000..03e9154
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/Android.bp
@@ -0,0 +1,33 @@
+// 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.
+
+cc_test {
+    name: "Bug-115739809",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libbase",
+        "libinput",
+        "libutils",
+        "liblog",
+    ],
+    cppflags: [
+        "-Wextra",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/Android.mk b/hostsidetests/securitybulletin/securityPatch/Bug-115739809/Android.mk
deleted file mode 100755
index cd2dbcd..0000000
--- a/hostsidetests/securitybulletin/securityPatch/Bug-115739809/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := Bug-115739809
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := \
-        libbase \
-        libinput \
-        libutils \
-        liblog
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CPPFLAGS += -Wall -Werror -Wextra
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.bp b/hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.bp
new file mode 100644
index 0000000..3d44266
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.bp
@@ -0,0 +1,19 @@
+//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.
+
+cc_test {
+    name: "Bug-38195738",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.mk b/hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.mk
deleted file mode 100644
index a4c1dc5..0000000
--- a/hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := Bug-38195738
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2012-6702/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2012-6702/Android.bp
new file mode 100644
index 0000000..2c0206e
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2012-6702/Android.bp
@@ -0,0 +1,29 @@
+// 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.
+
+cc_test {
+    name: "CVE-2012-6702",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    shared_libs: [
+        "libc",
+        "libexpat",
+        "liblog",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2012-6702/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2012-6702/Android.mk
deleted file mode 100644
index dede1c7..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2012-6702/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2012-6702
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_C_INCLUDES += $(TOP)/external/expat/lib/expat.h
-
-LOCAL_SHARED_LIBRARIES := \
-        libc \
-        libexpat \
-        liblog
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.bp
new file mode 100644
index 0000000..439c139
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.bp
@@ -0,0 +1,19 @@
+// 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.
+
+cc_test {
+    name: "CVE-2014-3145",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.mk
deleted file mode 100644
index 30cae16..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2014-3145
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2014-9803/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2014-9803/Android.bp
new file mode 100644
index 0000000..c8d5dc5
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2014-9803/Android.bp
@@ -0,0 +1,19 @@
+// 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.
+
+cc_test {
+    name: "CVE-2014-9803",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2014-9803/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2014-9803/Android.mk
deleted file mode 100644
index 0bd5a7c..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2014-9803/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2014-9803
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
-
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2015-1805/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2015-1805/Android.bp
new file mode 100644
index 0000000..76485b6
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2015-1805/Android.bp
@@ -0,0 +1,23 @@
+// 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.
+
+cc_test {
+    name: "CVE-2015-1805",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2015-1805/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2015-1805/Android.mk
deleted file mode 100644
index 6dd41bd..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2015-1805/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2015-1805
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.bp
new file mode 100644
index 0000000..3531cdb
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.bp
@@ -0,0 +1,27 @@
+// 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.
+
+cc_test {
+    name: "CVE-2016-0844",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    cflags: [
+        "-fPIE",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.mk
deleted file mode 100644
index c9d313d..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-0844
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_CFLAGS += -Iinclude -fPIE
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.bp
new file mode 100644
index 0000000..4546546
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.bp
@@ -0,0 +1,19 @@
+// 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.
+
+cc_test {
+    name: "CVE-2016-10229",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.mk
deleted file mode 100644
index 179fe15..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-10229
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CPPFLAGS = -Wall -Werror
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.bp
new file mode 100644
index 0000000..c3537f2
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.bp
@@ -0,0 +1,20 @@
+// 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.
+
+cc_test {
+    name: "CVE-2016-2109",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    shared_libs: ["libcrypto"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.mk
deleted file mode 100644
index 02f49d0..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-2109
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-LOCAL_SHARED_LIBRARIES := libcrypto
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2412/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2412/Android.bp
new file mode 100644
index 0000000..09e360d
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2412/Android.bp
@@ -0,0 +1,23 @@
+// 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.
+
+cc_test {
+    name: "CVE-2016-2412",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2412/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2412/Android.mk
deleted file mode 100644
index 77de47e..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2412/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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.

-

-LOCAL_PATH := $(call my-dir)

-

-include $(CLEAR_VARS)

-LOCAL_MODULE := CVE-2016-2412

-LOCAL_SRC_FILES := poc.cpp

-

-LOCAL_MULTILIB := both

-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32

-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64

-

-LOCAL_SHARED_LIBRARIES := libbinder \

-                          libutils

-

-# Tag this module as a cts test artifact

-LOCAL_COMPATIBILITY_SUITE := cts vts sts

-LOCAL_CTS_TEST_PACKAGE := android.security.cts

-

-LOCAL_ARM_MODE := arm

-LOCAL_CFLAGS += -Wall -Werror

-

-include $(BUILD_CTS_EXECUTABLE)

diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.bp
new file mode 100644
index 0000000..c2436bc
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.bp
@@ -0,0 +1,32 @@
+// 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.
+
+cc_test {
+    name: "CVE-2016-2419",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "liblog",
+        "libbinder",
+        "libutils",
+        "libstagefright",
+        "libmedia",
+        "libmediadrm",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.mk
deleted file mode 100644
index 616fd6e..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-2419
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := liblog \
-                          libbinder \
-                          libutils \
-                          libstagefright \
-                          libmedia \
-                          libmediadrm
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.bp
new file mode 100644
index 0000000..af352aa
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.bp
@@ -0,0 +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.
+
+cc_test {
+    name: "CVE-2016-2460",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libcutils",
+        "libc",
+        "libbinder",
+        "libutils",
+        "liblog",
+        "libmedia",
+        "libsoundtrigger",
+        "libgui",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.mk
deleted file mode 100755
index 186a7da..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-2460
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := \
-        libcutils \
-        libc \
-        libbinder \
-        libutils \
-        liblog \
-        libmedia \
-        libsoundtrigger \
-        libgui
-
-LOCAL_C_INCLUDES := \
-    $(TOP)/frameworks/native/include/media/openmax \
-    $(TOP)/frameworks/av/include/media/ \
-    $(TOP)/frameworks/av/media/libstagefright \
-    $(call include-path-for, audio-effects) \
-    $(call include-path-for, audio-utils)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.bp
new file mode 100644
index 0000000..26635d9
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.bp
@@ -0,0 +1,24 @@
+// Copyright (C) 2017 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.
+
+cc_test {
+    name: "CVE-2016-2471",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.mk
deleted file mode 100755
index ff70aa1..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2017 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-2471
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
-
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3746/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3746/Android.bp
new file mode 100644
index 0000000..5d900d8
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3746/Android.bp
@@ -0,0 +1,29 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_test {
+    name: "CVE-2016-3746",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "liblog",
+        "libbinder",
+        "libutils",
+        "libmedia",
+        "libstagefright",
+        "libmedia_omx",
+        "libhidlmemory",
+        "libstagefright_foundation",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3746/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3746/Android.mk
deleted file mode 100644
index 2767528..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3746/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-3746
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_C_INCLUDES += $(TOP)/frameworks/native/include/media/openmax \
-                    $(TOP)/frameworks/av/media/libstagefright
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libbinder \
-    libutils \
-    libmedia \
-    libstagefright \
-    libmedia_omx \
-    libhidlmemory \
-    libstagefright_foundation
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.bp
new file mode 100644
index 0000000..2a488ae
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.bp
@@ -0,0 +1,24 @@
+// 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.
+
+cc_test {
+    name: "CVE-2016-3818",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.mk
deleted file mode 100755
index 0fe16b7..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-3818
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3913/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3913/Android.bp
new file mode 100644
index 0000000..d076d40
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3913/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_test {
+    name: "CVE-2016-3913",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+        "libmedia",
+    ],
+    cppflags: [
+        "-Wno-unused-parameter",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3913/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3913/Android.mk
deleted file mode 100644
index e21a08e..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3913/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-3913
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := \
-    libbinder \
-    libutils \
-    libmedia \
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CPPFLAGS += -Wall -Werror -Wno-unused-parameter
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.bp
new file mode 100644
index 0000000..1cd33a2
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-6730",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-label",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk
deleted file mode 100644
index 8b1fac5..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-6730
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.bp
new file mode 100644
index 0000000..a0dd0d3
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-6731",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-label",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk
deleted file mode 100644
index 2bbe0a6..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-6731
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.bp
new file mode 100644
index 0000000..1340882
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-6732",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-label",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk
deleted file mode 100644
index 1187302..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-6732
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.bp
new file mode 100644
index 0000000..3f873b2
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-6733",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-label",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk
deleted file mode 100644
index 90fae4e..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-6733
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.bp
new file mode 100644
index 0000000..da5a873
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-6734",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-label",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk
deleted file mode 100644
index ad7712d..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-6734
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.bp
new file mode 100644
index 0000000..17937c7
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-6735",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-label",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk
deleted file mode 100644
index 9c007c7..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-6735
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.bp
new file mode 100644
index 0000000..d84178b
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-6736",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-label",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk
deleted file mode 100644
index da7c209..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-6736
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-label
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.bp
new file mode 100644
index 0000000..eccb0d6
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8425",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+        "-Wno-unused-function",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk
deleted file mode 100644
index 45672f1..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8425
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-function
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.bp
new file mode 100644
index 0000000..75bf901
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8426",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+        "-Wno-unused-function",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk
deleted file mode 100644
index aa9d14a..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8426
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-unused-variable -Wno-unused-function
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.bp
new file mode 100644
index 0000000..ae36966
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8427",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-constant-conversion",
+        "-Wno-user-defined-warnings",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk
deleted file mode 100644
index 7e196fe..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8427
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-constant-conversion -Wno-user-defined-warnings
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.bp
new file mode 100644
index 0000000..631e54d
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.bp
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8428",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-incompatible-pointer-types",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-variable",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk
deleted file mode 100644
index 75dae2693..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8428
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-missing-field-initializers
-LOCAL_CFLAGS += -Wno-unused-variable
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.bp
new file mode 100644
index 0000000..8b38c55
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8429",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-incompatible-pointer-types",
+        "-Wno-missing-field-initializers",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk
deleted file mode 100644
index 7c1c305..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8429
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-missing-field-initializers
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.bp
new file mode 100644
index 0000000..1295d71
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8430",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-incompatible-pointer-types",
+        "-Wno-missing-field-initializers",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk
deleted file mode 100644
index d163bd4..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8430
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-missing-field-initializers
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.bp
new file mode 100644
index 0000000..9e19727
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8431",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk
deleted file mode 100644
index 81b0121..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8431
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.bp
new file mode 100644
index 0000000..9fbef08
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.bp
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8432",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk
deleted file mode 100644
index 25e48fc..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8432
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.bp
new file mode 100644
index 0000000..6959175
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.bp
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8434",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk
deleted file mode 100644
index 4daad5d..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8434
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.bp
new file mode 100644
index 0000000..0991572
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.bp
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8460",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-braces",
+        "-Wno-missing-field-initializers",
+        "-Wno-pointer-arith",
+        "-Wno-pointer-sign",
+        "-Wno-unused-variable",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk
deleted file mode 100644
index 07eab6c..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8460
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-braces -Wno-missing-field-initializers -Wno-pointer-arith -Wno-pointer-sign -Wno-unused-variable
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.bp
new file mode 100644
index 0000000..eecb3dc
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.bp
@@ -0,0 +1,48 @@
+// Copyright (C) 2017 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
+
+cc_test {
+    name: "CVE-2016-8479",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    cflags: [
+        "-W",
+        "-g",
+        "-O2",
+        "-Wimplicit",
+        "-D_FORTIFY_SOURCE=2",
+        "-D__linux__",
+        "-Wdeclaration-after-statement",
+        "-Wformat=2",
+        "-Winit-self",
+        "-Wnested-externs",
+        "-Wpacked",
+        "-Wshadow",
+        "-Wswitch-enum",
+        "-Wundef",
+        "-Wwrite-strings",
+        "-Wno-format-nonliteral",
+        "-Wstrict-prototypes",
+        "-Wmissing-prototypes",
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+        "-Wno-macro-redefined",
+        "-fPIE",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk
deleted file mode 100644
index 744144c..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2017 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
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8479
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-macro-redefined
-LOCAL_CFLAGS += -Iinclude -fPIE
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.bp
new file mode 100644
index 0000000..81bae14
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+cc_test {
+    name: "CVE-2016-8482",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "general-tests",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-missing-field-initializers",
+        "-Wno-unused-variable",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk
deleted file mode 100644
index ae05af6..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8482
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-unused-variable
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.bp
new file mode 100644
index 0000000..27e8580
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.bp
@@ -0,0 +1,48 @@
+// Copyright (C) 2017 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
+
+cc_test {
+    name: "CVE-2017-0333",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    cflags: [
+        "-W",
+        "-g",
+        "-O2",
+        "-Wimplicit",
+        "-D_FORTIFY_SOURCE=2",
+        "-D__linux__",
+        "-Wdeclaration-after-statement",
+        "-Wformat=2",
+        "-Winit-self",
+        "-Wnested-externs",
+        "-Wpacked",
+        "-Wshadow",
+        "-Wswitch-enum",
+        "-Wundef",
+        "-Wwrite-strings",
+        "-Wno-format-nonliteral",
+        "-Wstrict-prototypes",
+        "-Wmissing-prototypes",
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+        "-Wno-macro-redefined",
+        "-fPIE",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk
deleted file mode 100644
index ae9fad5..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2017 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
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0333
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-macro-redefined
-LOCAL_CFLAGS += -Iinclude -fPIE
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.bp
new file mode 100644
index 0000000..ffd3169
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.bp
@@ -0,0 +1,19 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-0334",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.mk
deleted file mode 100644
index 166cd62..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0334
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a sts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0386/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0386/Android.bp
new file mode 100644
index 0000000..edbff59
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0386/Android.bp
@@ -0,0 +1,24 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-0386",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    shared_libs: [
+        "libnl",
+        "libc",
+        "liblog",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0386/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0386/Android.mk
deleted file mode 100755
index 258944f..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0386/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0386
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_C_INCLUDES := external/libnl/include
-
-LOCAL_SHARED_LIBRARIES := \
-    libnl \
-    libc \
-    liblog \
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0415/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0415/Android.bp
new file mode 100644
index 0000000..f7ab241
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0415/Android.bp
@@ -0,0 +1,25 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-0415",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libutils",
+        "libui",
+        "libgui",
+        "libmedia",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0415/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0415/Android.mk
deleted file mode 100644
index e3884e6..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0415/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0415
-LOCAL_SRC_FILES := poc.cpp
-
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := libutils \
-                          libui \
-                          libgui \
-                          libmedia
-
-LOCAL_C_INCLUDES:= \
-        $(TOP)/frameworks/native/include/media/openmax
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.bp
new file mode 100644
index 0000000..339cd59
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.bp
@@ -0,0 +1,25 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-0426",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    shared_libs: ["liblog"],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.mk
deleted file mode 100644
index 9dc0ea0..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0426
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_SHARED_LIBRARIES := liblog
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0477/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0477/Android.bp
new file mode 100644
index 0000000..1f4f071
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0477/Android.bp
@@ -0,0 +1,19 @@
+// 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
+
+cc_test {
+    name: "CVE-2017-0477",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0477/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0477/Android.mk
deleted file mode 100644
index 498e85f..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0477/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0477
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
-
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.bp
new file mode 100644
index 0000000..e811dd3
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.bp
@@ -0,0 +1,26 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-0479",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libmedia",
+        "libutils",
+        "libbinder",
+        "libandroid",
+        "libaudioclient",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.mk
deleted file mode 100644
index fc5d5dd..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0479
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := libmedia libutils libbinder libandroid libaudioclient
-LOCAL_C_INCLUDES:= \
-        $(TOP)/frameworks/av/include/media/ \
-        $(TOP)/frameworks/av/services/ \
-        $(TOP)/system/media/audio_utils/include/ \
-        $(TOP)/external/sonic/ \
-        $(TOP)/external/jsoncpp/include/ \
-        $(TOP)/frameworks/av/media/libnblog/include \
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_STS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CPPFLAGS = -Wall -Werror
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.bp
new file mode 100644
index 0000000..9354940
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.bp
@@ -0,0 +1,48 @@
+// Copyright (C) 2017 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
+
+cc_test {
+    name: "CVE-2017-0508",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    cflags: [
+        "-W",
+        "-g",
+        "-O2",
+        "-Wimplicit",
+        "-D_FORTIFY_SOURCE=2",
+        "-D__linux__",
+        "-Wdeclaration-after-statement",
+        "-Wformat=2",
+        "-Winit-self",
+        "-Wnested-externs",
+        "-Wpacked",
+        "-Wshadow",
+        "-Wswitch-enum",
+        "-Wundef",
+        "-Wwrite-strings",
+        "-Wno-format-nonliteral",
+        "-Wstrict-prototypes",
+        "-Wmissing-prototypes",
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+        "-Wno-macro-redefined",
+        "-fPIE",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk
deleted file mode 100644
index e51e98b..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2017 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
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0508
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
-LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
-LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-macro-redefined
-LOCAL_CFLAGS += -Iinclude -fPIE
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.bp
new file mode 100644
index 0000000..1a032a7
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.bp
@@ -0,0 +1,24 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-0553",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    shared_libs: ["libnl"],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.mk
deleted file mode 100644
index feaf0cf..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-0553
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-LOCAL_SHARED_LIBRARIES := libnl
-
-# Tag this module as a sts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror -Wno-unused-parameter -Wno-unused-variable
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.bp
new file mode 100644
index 0000000..a2ac927
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.bp
@@ -0,0 +1,23 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-13232",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libutils",
+        "libbinder",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.mk
deleted file mode 100644
index a01873d..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-13232
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_C_INCLUDES := $(TOP)/system/media/audio/include/
-
-LOCAL_SHARED_LIBRARIES := libutils libbinder
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CPPFLAGS = -Wall -Werror
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.bp
new file mode 100644
index 0000000..aaa2fa5
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.bp
@@ -0,0 +1,30 @@
+// 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
+
+cc_test {
+    name: "CVE-2017-13253",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    header_libs: ["libmediadrm_headers"],
+    shared_libs: [
+        "libmedia",
+        "libutils",
+        "libbinder",
+        "libmediadrm",
+    ],
+    cflags: [
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.mk
deleted file mode 100644
index 811b4c9..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-13253
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_HEADER_LIBRARIES := libmediadrm_headers
-
-LOCAL_SHARED_LIBRARIES := libmedia libutils libbinder libmediadrm
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror -Wno-unused-parameter -Wno-unused-variable
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13273/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13273/Android.bp
new file mode 100644
index 0000000..70dd343
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13273/Android.bp
@@ -0,0 +1,24 @@
+// 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.
+
+cc_test {
+    name: "CVE-2017-13273",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13273/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13273/Android.mk
deleted file mode 100644
index 1cb7357..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13273/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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.
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-13273
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_LDFLAGS += -fPIE -pie
-LOCAL_LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.bp
new file mode 100644
index 0000000..f5adc33
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.bp
@@ -0,0 +1,19 @@
+// 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
+
+cc_test {
+    name: "CVE-2017-6262",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.mk
deleted file mode 100644
index 64ecb5c..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2017-6262
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9344/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9344/Android.bp
new file mode 100644
index 0000000..df215ef
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9344/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+
+cc_test {
+    name: "CVE-2018-9344",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libutils",
+        "libbinder",
+        "libhidlbase",
+        "libhardware",
+        "android.hardware.cas.native@1.0",
+        "android.hardware.cas@1.0",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9344/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9344/Android.mk
deleted file mode 100644
index a806207..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9344/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License
-
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2018-9344
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := \
-    libutils \
-    libbinder \
-    libhidlbase \
-    libhardware \
-    android.hardware.cas.native@1.0 \
-    android.hardware.cas@1.0 \
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS = -Wall -Werror
-include $(BUILD_CTS_EXECUTABLE)
\ No newline at end of file
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9424/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9424/Android.bp
new file mode 100644
index 0000000..7b04ffb
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9424/Android.bp
@@ -0,0 +1,33 @@
+//
+//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.
+
+cc_test {
+    name: "CVE-2018-9424",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+        "libcutils",
+    ],
+    cppflags: [
+        "-fPIE",
+    ],
+    ldflags: [
+        "-fPIE",
+        "-pie",
+        "-rdynamic",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9424/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9424/Android.mk
deleted file mode 100644
index 0615108..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9424/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-#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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2018-9424
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-
-LOCAL_SHARED_LIBRARIES := libbinder \
-                          libutils \
-                          libcutils
-
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CPPFLAGS += -Wall -Werror
-LOCAL_CPPFLAGS += -Iinclude -fPIE
-LOCAL_LDFLAGS += -fPIE -pie
-LDFLAGS += -rdynamic
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9490/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9490/Android.bp
new file mode 100644
index 0000000..faa1a0f
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9490/Android.bp
@@ -0,0 +1,20 @@
+// 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.
+
+cc_test {
+    name: "CVE-2018-9490",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: ["libpac"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9490/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9490/Android.mk
deleted file mode 100644
index a6a520f..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9490/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2018-9490
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := \
-        libpac \
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts sts vts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CPPFLAGS = -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9515/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9515/Android.bp
new file mode 100644
index 0000000..ba0e08f
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9515/Android.bp
@@ -0,0 +1,19 @@
+// 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.
+
+cc_test {
+    name: "CVE-2018-9515",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.c"],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9515/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9515/Android.mk
deleted file mode 100644
index 3c8d79c..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9515/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2018-9515
-LOCAL_SRC_FILES := poc.c
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9539/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9539/Android.bp
new file mode 100644
index 0000000..d0ebfac
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9539/Android.bp
@@ -0,0 +1,28 @@
+// 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.
+
+cc_test {
+    name: "CVE-2018-9539",
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+    srcs: ["poc.cpp"],
+    shared_libs: [
+        "libutils",
+        "liblog",
+        "android.hardware.cas@1.0",
+        "android.hardware.cas.native@1.0",
+        "libhidlbase",
+        "libbinder",
+        "libcutils",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9539/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2018-9539/Android.mk
deleted file mode 100644
index e1f51f1..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2018-9539/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2018-9539
-LOCAL_SRC_FILES := poc.cpp
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-
-LOCAL_SHARED_LIBRARIES := \
-    libutils \
-    liblog \
-    android.hardware.cas@1.0 \
-    android.hardware.cas.native@1.0 \
-    libhidlbase \
-    libbinder \
-    libcutils \
-
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wall -Werror
-
-include $(BUILD_CTS_EXECUTABLE)
-
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java
index 2007914..9f2e9a7 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc19_11.java
@@ -41,4 +41,13 @@
         int code = AdbUtils.runProxyAutoConfig("bug_138442295", getDevice());
         assertTrue(code != 139); // 128 + signal 11
     }
+
+    /**
+     * b/139806216
+     */
+    @SecurityTest(minPatchLevel = "2019-11")
+    public void testPocBug_139806216() throws Exception {
+        int code = AdbUtils.runProxyAutoConfig("bug_139806216", getDevice());
+        assertTrue(code != 139 && code != 135); // 128 + signal 11, 128 + signal 7
+    }
 }
diff --git a/hostsidetests/securitybulletin/test-apps/Android.mk b/hostsidetests/securitybulletin/test-apps/Android.mk
deleted file mode 100644
index f8d63a5..0000000
--- a/hostsidetests/securitybulletin/test-apps/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-
-# Build the test APKs using their own makefiles
-include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/hostsidetests/securitybulletin/test-apps/launchanywhere/Android.bp b/hostsidetests/securitybulletin/test-apps/launchanywhere/Android.bp
new file mode 100644
index 0000000..6b17058
--- /dev/null
+++ b/hostsidetests/securitybulletin/test-apps/launchanywhere/Android.bp
@@ -0,0 +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.
+//
+
+android_test_helper_app {
+    name: "CtsHostLaunchAnyWhereApp",
+    defaults: ["cts_support_defaults"],
+    sdk_version: "current",
+    srcs: ["src/**/*.java"],
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "sts",
+    ],
+    optimize: {
+        enabled: false,
+    },
+    dex_preopt: {
+        enabled: false,
+    },
+}
diff --git a/hostsidetests/securitybulletin/test-apps/launchanywhere/Android.mk b/hostsidetests/securitybulletin/test-apps/launchanywhere/Android.mk
deleted file mode 100644
index 226c360..0000000
--- a/hostsidetests/securitybulletin/test-apps/launchanywhere/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsHostLaunchAnyWhereApp
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts sts
-
-LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_DEX_PREOPT := false
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
\ No newline at end of file
diff --git a/hostsidetests/stagedinstall/app/src/com/android/tests/stagedinstall/StagedInstallTest.java b/hostsidetests/stagedinstall/app/src/com/android/tests/stagedinstall/StagedInstallTest.java
index 748e45e..eb0211d 100644
--- a/hostsidetests/stagedinstall/app/src/com/android/tests/stagedinstall/StagedInstallTest.java
+++ b/hostsidetests/stagedinstall/app/src/com/android/tests/stagedinstall/StagedInstallTest.java
@@ -824,6 +824,18 @@
                 ApplicationInfo.FLAG_INSTALLED);
     }
 
+    @Test
+    public void testInstallApkChangingFingerprint() throws Exception {
+        int sessionId = Install.single(TestApp.A1).setStaged().commit();
+        storeSessionId(sessionId);
+    }
+
+    @Test
+    public void testInstallApkChangingFingerprint_VerifyAborted() throws Exception {
+        int sessionId = retrieveLastSessionId();
+        assertSessionFailed(sessionId);
+    }
+
     private static long getInstalledVersion(String packageName) {
         Context context = InstrumentationRegistry.getInstrumentation().getContext();
         PackageManager pm = context.getPackageManager();
diff --git a/hostsidetests/stagedinstall/src/com/android/tests/stagedinstall/host/StagedInstallTest.java b/hostsidetests/stagedinstall/src/com/android/tests/stagedinstall/host/StagedInstallTest.java
index 2f421c3..5556700 100644
--- a/hostsidetests/stagedinstall/src/com/android/tests/stagedinstall/host/StagedInstallTest.java
+++ b/hostsidetests/stagedinstall/src/com/android/tests/stagedinstall/host/StagedInstallTest.java
@@ -408,6 +408,20 @@
         runPhase("testSamegradeSystemApex_VerifyPostReboot");
     }
 
+    @Test
+    public void testInstallApkChangingFingerprint() throws Exception {
+        assumeThat(getDevice().getBuildFlavor(), not(endsWith("-user")));
+
+        try {
+            getDevice().executeShellCommand("setprop persist.pm.mock-upgrade true");
+            runPhase("testInstallApkChangingFingerprint");
+            getDevice().reboot();
+            runPhase("testInstallApkChangingFingerprint_VerifyAborted");
+        } finally {
+            getDevice().executeShellCommand("setprop persist.pm.mock-upgrade false");
+        }
+    }
+
     private boolean isUpdatingApexSupported() throws Exception {
         final String updatable = getDevice().getProperty("ro.apex.updatable");
         return updatable != null && updatable.equals("true");
diff --git a/hostsidetests/tv/AndroidTest.xml b/hostsidetests/tv/AndroidTest.xml
index 96f39f3..bd883d0 100644
--- a/hostsidetests/tv/AndroidTest.xml
+++ b/hostsidetests/tv/AndroidTest.xml
@@ -19,6 +19,7 @@
     <!-- Instant apps for TV is not supported. -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
         <option name="jar" value="CtsHostsideTvTests.jar" />
         <option name="runtime-hint" value="8m10s" />
diff --git a/hostsidetests/webkit/AndroidTest.xml b/hostsidetests/webkit/AndroidTest.xml
index 54a6c9a..4be85ac 100644
--- a/hostsidetests/webkit/AndroidTest.xml
+++ b/hostsidetests/webkit/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="webview" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsWebViewStartupApp.apk" />
diff --git a/libs/input/src/com/android/cts/input/HidJsonParser.java b/libs/input/src/com/android/cts/input/HidJsonParser.java
index be5f6bf..5e306ad 100644
--- a/libs/input/src/com/android/cts/input/HidJsonParser.java
+++ b/libs/input/src/com/android/cts/input/HidJsonParser.java
@@ -173,15 +173,17 @@
                     testData.reports.add(report);
                 }
 
+                final int source = sourceFromString(testcaseEntry.optString("source", "UNKNOWN"));
+
                 JSONArray events = testcaseEntry.getJSONArray("events");
                 for (int i = 0; i < events.length(); i++) {
                     JSONObject entry = events.getJSONObject(i);
 
-                    InputEvent event = null;
+                    InputEvent event;
                     if (entry.has("keycode")) {
-                        event = parseKeyEvent(entry);
+                        event = parseKeyEvent(source, entry);
                     } else if (entry.has("axes")) {
-                        event = parseMotionEvent(entry);
+                        event = parseMotionEvent(source, entry);
                     } else {
                         throw new RuntimeException(
                                 "Input event is not specified correctly. Received: " + entry);
@@ -196,13 +198,16 @@
         return tests;
     }
 
-    private KeyEvent parseKeyEvent(JSONObject entry) throws JSONException {
+    private KeyEvent parseKeyEvent(int source, JSONObject entry) throws JSONException {
         int action = keyActionFromString(entry.getString("action"));
         int keyCode = KeyEvent.keyCodeFromString(entry.getString("keycode"));
-        return new KeyEvent(action, keyCode);
+        // Only care about key code, action and source here. Times are not checked.
+        return new KeyEvent(/* downTime */ 0, /* eventTime */ 0, action, keyCode,
+                /* repeat */ 0, /* metaState */ 0, /* deviceId */ 0, /* scanCode */ 0,
+                /* flags */ 0, source);
     }
 
-    private MotionEvent parseMotionEvent(JSONObject entry) throws JSONException {
+    private MotionEvent parseMotionEvent(int source, JSONObject entry) throws JSONException {
         MotionEvent.PointerProperties[] properties = new MotionEvent.PointerProperties[1];
         properties[0] = new MotionEvent.PointerProperties();
         properties[0].id = 0;
@@ -219,15 +224,22 @@
             coords[0].setAxisValue(MotionEvent.axisFromString(axis), value);
         }
 
+        int buttonState = 0;
+        JSONArray buttons = entry.optJSONArray("buttonState");
+        if (buttons != null) {
+            for (int i = 0; i < buttons.length(); ++i) {
+                buttonState |= motionButtonFromString(buttons.getString(i));
+            }
+        }
+
         int action = motionActionFromString(entry.getString("action"));
-        // Only care about axes and action here. Times are not checked
-        MotionEvent event = MotionEvent.obtain(/* downTime */ 0, /* eventTime */ 0, action,
-                /* pointercount */ 1, properties, coords, 0, 0, 0f, 0f,
-                0, 0, InputDevice.SOURCE_JOYSTICK, 0);
-        return event;
+        // Only care about axes, action and source here. Times are not checked.
+        return MotionEvent.obtain(/* downTime */ 0, /* eventTime */ 0, action,
+                /* pointercount */ 1, properties, coords, 0, buttonState, 0f, 0f,
+                0, 0, source, 0);
     }
 
-    private int keyActionFromString(String action) {
+    private static int keyActionFromString(String action) {
         switch (action.toUpperCase()) {
             case "DOWN":
                 return KeyEvent.ACTION_DOWN;
@@ -237,7 +249,7 @@
         throw new RuntimeException("Unknown action specified: " + action);
     }
 
-    private int motionActionFromString(String action) {
+    private static int motionActionFromString(String action) {
         switch (action.toUpperCase()) {
             case "DOWN":
                 return MotionEvent.ACTION_DOWN;
@@ -245,7 +257,49 @@
                 return MotionEvent.ACTION_MOVE;
             case "UP":
                 return MotionEvent.ACTION_UP;
+            case "BUTTON_PRESS":
+                return MotionEvent.ACTION_BUTTON_PRESS;
+            case "BUTTON_RELEASE":
+                return MotionEvent.ACTION_BUTTON_RELEASE;
+            case "HOVER_ENTER":
+                return MotionEvent.ACTION_HOVER_ENTER;
+            case "HOVER_MOVE":
+                return MotionEvent.ACTION_HOVER_MOVE;
+            case "HOVER_EXIT":
+                return MotionEvent.ACTION_HOVER_EXIT;
         }
         throw new RuntimeException("Unknown action specified: " + action);
     }
+
+    private static int sourceFromString(String source) {
+        switch (source.toUpperCase()) {
+            case "MOUSE_RELATIVE":
+                return InputDevice.SOURCE_MOUSE_RELATIVE;
+            case "JOYSTICK":
+                return InputDevice.SOURCE_JOYSTICK;
+            case "UNKNOWN":
+                return InputDevice.SOURCE_UNKNOWN;
+        }
+        throw new RuntimeException("Unknown source specified: " + source);
+    }
+
+    private static int motionButtonFromString(String button) {
+        switch (button.toUpperCase()) {
+            case "BACK":
+                return MotionEvent.BUTTON_BACK;
+            case "FORWARD":
+                return MotionEvent.BUTTON_FORWARD;
+            case "PRIMARY":
+                return MotionEvent.BUTTON_PRIMARY;
+            case "SECONDARY":
+                return MotionEvent.BUTTON_SECONDARY;
+            case "STYLUS_PRIMARY":
+                return MotionEvent.BUTTON_STYLUS_PRIMARY;
+            case "STYLUS_SECONDARY":
+                return MotionEvent.BUTTON_STYLUS_SECONDARY;
+            case "TERTIARY":
+                return MotionEvent.BUTTON_TERTIARY;
+        }
+        throw new RuntimeException("Unknown button specified: " + button);
+    }
 }
diff --git a/libs/install/src/com/android/cts/install/lib/InstallUtils.java b/libs/install/src/com/android/cts/install/lib/InstallUtils.java
index 6969398..804de2d 100644
--- a/libs/install/src/com/android/cts/install/lib/InstallUtils.java
+++ b/libs/install/src/com/android/cts/install/lib/InstallUtils.java
@@ -38,6 +38,7 @@
 
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.util.List;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
@@ -45,6 +46,7 @@
  * Utilities to facilitate installation in tests.
  */
 public class InstallUtils {
+
     /**
      * Adopts the given shell permissions.
      */
@@ -264,6 +266,34 @@
     }
 
     /**
+     * Checks whether a given package is installed for only the given user, from a list of users.
+     * @param packageName the package to check
+     * @param userIdToCheck the user id of the user to check
+     * @param userIds a list of user ids to check
+     * @return {@code true} if the package is only installed for the given user,
+     *         {@code false} otherwise.
+     */
+    public static boolean isOnlyInstalledForUser(String packageName, int userIdToCheck,
+            List<Integer> userIds) {
+        Context context = InstrumentationRegistry.getContext();
+        PackageManager pm = context.getPackageManager();
+        for (int userId: userIds) {
+            List<PackageInfo> installedPackages;
+            if (userId != userIdToCheck) {
+                installedPackages = pm.getInstalledPackagesAsUser(PackageManager.MATCH_APEX,
+                        userId);
+                for (PackageInfo pi : installedPackages) {
+                    if (pi.packageName.equals(packageName)) {
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+
+    }
+
+    /**
      * A functional interface representing an operation that takes no arguments,
      * returns no arguments and might throw a {@link Throwable} of any kind.
      */
diff --git a/tests/JobScheduler/AndroidManifest.xml b/tests/JobScheduler/AndroidManifest.xml
index 4bd5208..d470f62 100755
--- a/tests/JobScheduler/AndroidManifest.xml
+++ b/tests/JobScheduler/AndroidManifest.xml
@@ -24,6 +24,7 @@
     <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
 
diff --git a/tests/JobScheduler/src/android/jobscheduler/cts/DeviceStatesTest.java b/tests/JobScheduler/src/android/jobscheduler/cts/DeviceStatesTest.java
index 67d147e..11bb6f1 100644
--- a/tests/JobScheduler/src/android/jobscheduler/cts/DeviceStatesTest.java
+++ b/tests/JobScheduler/src/android/jobscheduler/cts/DeviceStatesTest.java
@@ -18,7 +18,9 @@
 
 import android.annotation.TargetApi;
 import android.app.job.JobInfo;
+import android.content.Context;
 import android.content.pm.PackageManager;
+import android.os.PowerManager;
 import android.os.SystemClock;
 import android.support.test.uiautomator.UiDevice;
 
@@ -31,7 +33,9 @@
 public class DeviceStatesTest extends ConstraintTest {
     /** Unique identifier for the job scheduled by this suite of tests. */
     public static final int STATE_JOB_ID = DeviceStatesTest.class.hashCode();
+    private static final String TAG = "DeviceStatesTest";
 
+    private PowerManager.WakeLock mWakeLock;
     private JobInfo.Builder mBuilder;
     private UiDevice mUiDevice;
 
@@ -40,6 +44,9 @@
         super.setUp();
         mBuilder = new JobInfo.Builder(STATE_JOB_ID, kJobServiceComponent);
         mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
+        mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+        mWakeLock.acquire();
     }
 
     @Override
@@ -47,6 +54,9 @@
         mJobScheduler.cancel(STATE_JOB_ID);
         // Put device back in to normal operation.
         toggleScreenOn(true /* screen on */);
+        if (mWakeLock != null && mWakeLock.isHeld()) {
+            mWakeLock.release();
+        }
     }
 
     void assertJobReady() throws Exception {
diff --git a/tests/acceleration/AndroidTest.xml b/tests/acceleration/AndroidTest.xml
index b066dc1..65fc952 100644
--- a/tests/acceleration/AndroidTest.xml
+++ b/tests/acceleration/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="uitoolkit" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsAccelerationTestCases.apk" />
diff --git a/tests/accessibility/AndroidTest.xml b/tests/accessibility/AndroidTest.xml
index 3057ae8..6fe3f3b 100644
--- a/tests/accessibility/AndroidTest.xml
+++ b/tests/accessibility/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="framework" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="cmd accessibility set-bind-instant-service-allowed true" />
         <option name="teardown-command" value="cmd accessibility set-bind-instant-service-allowed false" />
diff --git a/tests/accessibility/res/xml/speaking_accessibilityservice.xml b/tests/accessibility/res/xml/speaking_accessibilityservice.xml
index 249c381..339245a 100644
--- a/tests/accessibility/res/xml/speaking_accessibilityservice.xml
+++ b/tests/accessibility/res/xml/speaking_accessibilityservice.xml
@@ -16,7 +16,7 @@
 <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
     android:accessibilityEventTypes="typeAllMask"
     android:accessibilityFeedbackType="feedbackSpoken"
-    android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews|flagRequestTouchExplorationMode|flagReportViewIds|flagRequestFilterKeyEvents|flagRequestShortcutWarningDialogSpokenFeedback"
+    android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews|flagRequestTouchExplorationMode|flagReportViewIds|flagRequestFilterKeyEvents|flagRequestShortcutWarningDialogSpokenFeedback|flagHandleShortcut"
     android:canRetrieveWindowContent="true"
     android:canRequestTouchExplorationMode="true"
     android:canRequestFilterKeyEvents="true"
diff --git a/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java b/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
index f4abdf1..b8bea69de 100644
--- a/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
+++ b/tests/accessibility/src/android/view/accessibility/cts/AccessibilityServiceInfoTest.java
@@ -87,7 +87,8 @@
                 | AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE
                 | AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS
                 | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS
-                | AccessibilityServiceInfo.FLAG_REQUEST_SHORTCUT_WARNING_DIALOG_SPOKEN_FEEDBACK,
+                | AccessibilityServiceInfo.FLAG_REQUEST_SHORTCUT_WARNING_DIALOG_SPOKEN_FEEDBACK
+                | AccessibilityServiceInfo.FLAG_HANDLE_SHORTCUT,
                 speakingService.flags);
         assertSame(0l, speakingService.notificationTimeout);
         assertEquals("Some description", speakingService.getDescription());
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityOverlayTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityOverlayTest.java
index 6f88779..d8264dc 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityOverlayTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityOverlayTest.java
@@ -19,12 +19,16 @@
 import static org.junit.Assert.assertTrue;
 
 import android.accessibility.cts.common.AccessibilityDumpOnFailureRule;
-import android.accessibility.cts.common.InstrumentedAccessibilityServiceTestRule;
 import android.accessibility.cts.common.InstrumentedAccessibilityService;
+import android.accessibility.cts.common.InstrumentedAccessibilityServiceTestRule;
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.accessibilityservice.cts.utils.AsyncUtils;
+import android.accessibilityservice.cts.utils.DisplayUtils;
 import android.app.UiAutomation;
+import android.content.Context;
 import android.text.TextUtils;
+import android.util.SparseArray;
+import android.view.Display;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityWindowInfo;
 import android.widget.Button;
@@ -76,30 +80,56 @@
 
     @Test
     public void testA11yServiceShowsOverlay_shouldAppear() throws Exception {
-        final Button button = new Button(mService);
-        button.setText("Button");
         final String overlayTitle = "Overlay title";
 
         sUiAutomation.executeAndWaitForEvent(() -> mService.runOnServiceSync(() -> {
-            final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
-            params.width = WindowManager.LayoutParams.MATCH_PARENT;
-            params.height = WindowManager.LayoutParams.MATCH_PARENT;
-            params.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
-                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
-            params.type = WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
-            params.setTitle(overlayTitle);
-            mService.getSystemService(WindowManager.class).addView(button, params);
-        }), (event) -> findOverlayWindow() != null, AsyncUtils.DEFAULT_TIMEOUT_MS);
+            addOverlayWindow(mService, overlayTitle);
+        }), (event) -> findOverlayWindow(Display.DEFAULT_DISPLAY) != null, AsyncUtils.DEFAULT_TIMEOUT_MS);
 
-        assertTrue(TextUtils.equals(findOverlayWindow().getTitle(), overlayTitle));
+        assertTrue(TextUtils.equals(findOverlayWindow(Display.DEFAULT_DISPLAY).getTitle(), overlayTitle));
     }
 
-    private AccessibilityWindowInfo findOverlayWindow() {
-        List<AccessibilityWindowInfo> windows = sUiAutomation.getWindows();
-        for (int i = 0; i < windows.size(); i++) {
-            AccessibilityWindowInfo window = windows.get(i);
-            if (window.getType() == AccessibilityWindowInfo.TYPE_ACCESSIBILITY_OVERLAY) {
-                return window;
+    @Test
+    public void testA11yServiceShowsOverlayOnVirtualDisplay_shouldAppear() throws Exception {
+        try (DisplayUtils.VirtualDisplaySession displaySession =
+                     new DisplayUtils.VirtualDisplaySession()) {
+            Display newDisplay = displaySession.createDisplayWithDefaultDisplayMetricsAndWait(
+                    mService, false);
+            final int displayId = newDisplay.getDisplayId();
+            final Context newDisplayContext = mService.createDisplayContext(newDisplay);
+            final String overlayTitle = "Overlay title on virtualDisplay";
+
+            sUiAutomation.executeAndWaitForEvent(() -> mService.runOnServiceSync(() -> {
+                addOverlayWindow(newDisplayContext, overlayTitle);
+            }), (event) -> findOverlayWindow(displayId) != null, AsyncUtils.DEFAULT_TIMEOUT_MS);
+
+            assertTrue(TextUtils.equals(findOverlayWindow(displayId).getTitle(), overlayTitle));
+        }
+    }
+
+    private void addOverlayWindow(Context context, String overlayTitle) {
+        final Button button = new Button(context);
+        button.setText("Button");
+        final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
+        params.width = WindowManager.LayoutParams.MATCH_PARENT;
+        params.height = WindowManager.LayoutParams.MATCH_PARENT;
+        params.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
+        params.type = WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
+        params.setTitle(overlayTitle);
+        context.getSystemService(WindowManager.class).addView(button, params);
+    }
+
+    private AccessibilityWindowInfo findOverlayWindow(int displayId) {
+        final SparseArray<List<AccessibilityWindowInfo>> allWindows =
+                sUiAutomation.getWindowsOnAllDisplays();
+        final int index = allWindows.indexOfKey(displayId);
+        final List<AccessibilityWindowInfo> windows = allWindows.valueAt(index);
+        if (windows != null) {
+            for (AccessibilityWindowInfo window : windows) {
+                if (window.getType() == AccessibilityWindowInfo.TYPE_ACCESSIBILITY_OVERLAY) {
+                    return window;
+                }
             }
         }
         return null;
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
index 01d1659..ee38997 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
@@ -128,7 +128,8 @@
                 AccessibilityServiceInfo.FLAG_REQUEST_FINGERPRINT_GESTURES));
         assertEquals("FLAG_REQUEST_SHORTCUT_WARNING_DIALOG_SPOKEN_FEEDBACK", AccessibilityServiceInfo.flagToString(
                 AccessibilityServiceInfo.FLAG_REQUEST_SHORTCUT_WARNING_DIALOG_SPOKEN_FEEDBACK));
-
+        assertEquals("FLAG_HANDLE_SHORTCUT", AccessibilityServiceInfo.flagToString(
+                AccessibilityServiceInfo.FLAG_HANDLE_SHORTCUT));
     }
 
     /**
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java
index 25e6d1f..35ad056 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowReportingTest.java
@@ -19,8 +19,11 @@
 import static android.accessibilityservice.cts.utils.AccessibilityEventFilterUtils.filterWindowsChangeTypesAndWindowTitle;
 import static android.accessibilityservice.cts.utils.AccessibilityEventFilterUtils.filterWindowsChangedWithChangeTypes;
 import static android.accessibilityservice.cts.utils.ActivityLaunchUtils.findWindowByTitle;
+import static android.accessibilityservice.cts.utils.ActivityLaunchUtils.findWindowByTitleAndDisplay;
 import static android.accessibilityservice.cts.utils.ActivityLaunchUtils.getActivityTitle;
 import static android.accessibilityservice.cts.utils.ActivityLaunchUtils.launchActivityAndWaitForItToBeOnscreen;
+import static android.accessibilityservice.cts.utils.ActivityLaunchUtils.launchActivityOnSpecifiedDisplayAndWaitForItToBeOnscreen;
+import static android.accessibilityservice.cts.utils.DisplayUtils.VirtualDisplaySession;
 import static android.accessibilityservice.cts.utils.DisplayUtils.getStatusBarHeight;
 import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
 import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOWS_CHANGED;
@@ -42,9 +45,11 @@
 import android.accessibility.cts.common.AccessibilityDumpOnFailureRule;
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.accessibilityservice.cts.activities.AccessibilityWindowReportingActivity;
+import android.accessibilityservice.cts.utils.DisplayUtils;
 import android.app.Activity;
 import android.app.Instrumentation;
 import android.app.UiAutomation;
+import android.view.Display;
 import android.view.Gravity;
 import android.view.View;
 import android.view.WindowManager;
@@ -232,6 +237,54 @@
     }
 
     @Test
+    public void moveFocusToAnotherDisplay_movesActiveAndFocusWindow() throws Exception {
+        // Makes sure activityWindow on default display is focused
+        AccessibilityWindowInfo activityWindow = findWindowByTitle(sUiAutomation, mActivityTitle);
+        assertTrue(activityWindow.isActive());
+        assertTrue(activityWindow.isFocused());
+
+        // Creates a virtual display.
+        try (VirtualDisplaySession displaySession = new VirtualDisplaySession()) {
+            final int virtualDisplayId =
+                displaySession.createDisplayWithDefaultDisplayMetricsAndWait(
+                    sInstrumentation.getContext(), false).getDisplayId();
+            // Launchs an activity on virtual display.
+            final Activity activityOnVirtualDisplay =
+                    launchActivityOnSpecifiedDisplayAndWaitForItToBeOnscreen(sInstrumentation,
+                            sUiAutomation,
+                            AccessibilityEmbeddedDisplayTest.EmbeddedDisplayActivity.class,
+                            virtualDisplayId);
+            final CharSequence activityTitle = getActivityTitle(sInstrumentation,
+                    activityOnVirtualDisplay);
+            // Make sure activityWindow on virtual display is focused.
+            AccessibilityWindowInfo activityWindowOnVirtualDisplay =
+                findWindowByTitleAndDisplay(sUiAutomation, activityTitle, virtualDisplayId);
+            // Windows may have changed - refresh.
+            activityWindow = findWindowByTitle(sUiAutomation, mActivityTitle);
+            try {
+                assertFalse(activityWindow.isActive());
+                assertFalse(activityWindow.isFocused());
+                assertTrue(activityWindowOnVirtualDisplay.isActive());
+                assertTrue(activityWindowOnVirtualDisplay.isFocused());
+            } finally {
+                sUiAutomation.executeAndWaitForEvent(
+                        () -> {
+                            sInstrumentation.runOnMainSync(
+                                    () -> activityOnVirtualDisplay.finish());
+                        },
+                        filterWindowsChangedWithChangeTypes(WINDOWS_CHANGE_FOCUSED |
+                                WINDOWS_CHANGE_ACTIVE),
+                        TIMEOUT_ASYNC_PROCESSING);
+            }
+        }
+        // The focused window should be returned to activity at default display after
+        // the activity at virtual display is destroyed.
+        activityWindow = findWindowByTitle(sUiAutomation, mActivityTitle);
+        assertTrue(activityWindow.isActive());
+        assertTrue(activityWindow.isFocused());
+    }
+
+    @Test
     public void testChangeAccessibilityFocusWindow_getEvent() throws Exception {
         final AccessibilityServiceInfo info = sUiAutomation.getServiceInfo();
         info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;
diff --git a/tests/app/OWNERS b/tests/app/OWNERS
index 3b15c95..7516b62 100644
--- a/tests/app/OWNERS
+++ b/tests/app/OWNERS
@@ -1,2 +1,4 @@
 # Bug component: 316234
 include platform/frameworks/base:/services/core/java/com/android/server/am/OWNERS
+juliacr@google.com
+beverlyt@google.com
\ No newline at end of file
diff --git a/tests/app/app/AndroidManifest.xml b/tests/app/app/AndroidManifest.xml
index 74e5611..e75cab0 100644
--- a/tests/app/app/AndroidManifest.xml
+++ b/tests/app/app/AndroidManifest.xml
@@ -385,6 +385,18 @@
             </intent-filter>
         </service>
 
+        <service android:name="android.app.stubs.BooleanTestTileService"
+                 android:exported="true"
+                 android:label="BooleanTestTileService"
+                 android:icon="@drawable/robot"
+                 android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
+            <intent-filter>
+                <action android:name="android.service.quicksettings.action.QS_TILE" />
+            </intent-filter>
+            <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+                       android:value="true"/>
+        </service>
+
         <activity android:name="android.app.stubs.AutomaticZenRuleActivity">
             <intent-filter>
                 <action android:name="android.app.action.AUTOMATIC_ZEN_RULE" />
diff --git a/tests/app/app/src/android/app/stubs/BooleanTestTileService.java b/tests/app/app/src/android/app/stubs/BooleanTestTileService.java
new file mode 100644
index 0000000..fe04e00
--- /dev/null
+++ b/tests/app/app/src/android/app/stubs/BooleanTestTileService.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.stubs;
+
+import android.content.ComponentName;
+import android.service.quicksettings.Tile;
+
+public class BooleanTestTileService extends TestTileService {
+    public static final String TAG = "BooleanTestTileService";
+    public static final String PKG = "android.app.stubs";
+    public static final int ICON_ID = R.drawable.robot;
+
+    public static String getId() {
+        return String.format("%s/%s", BooleanTestTileService.class.getPackage().getName(),
+                BooleanTestTileService.class.getName());
+    }
+
+    public static ComponentName getComponentName() {
+        return new ComponentName(BooleanTestTileService.class.getPackage().getName(),
+                BooleanTestTileService.class.getName());
+    }
+
+    public void toggleState() {
+        if (isListening()) {
+            Tile tile = sTestTileService.getQsTile();
+            switch(tile.getState()) {
+                case Tile.STATE_ACTIVE:
+                    tile.setState(Tile.STATE_INACTIVE);
+                    break;
+                case Tile.STATE_INACTIVE:
+                    tile.setState(Tile.STATE_ACTIVE);
+                    break;
+                default:
+                    break;
+            }
+            tile.updateTile();
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/app/app/src/android/app/stubs/TestTileService.java b/tests/app/app/src/android/app/stubs/TestTileService.java
index 51a7a2c..c50ecc5 100644
--- a/tests/app/app/src/android/app/stubs/TestTileService.java
+++ b/tests/app/app/src/android/app/stubs/TestTileService.java
@@ -29,7 +29,7 @@
     public static final String PKG = "android.app.stubs";
     public static final int ICON_ID = R.drawable.robot;
 
-    private static TestTileService sTestTileService = null;
+    protected static TestTileService sTestTileService = null;
     AtomicBoolean isConnected = new AtomicBoolean(false);
     AtomicBoolean isListening = new AtomicBoolean(false);
     AtomicBoolean hasBeenClicked = new AtomicBoolean(false);
diff --git a/tests/app/src/android/app/cts/BaseTileServiceTest.java b/tests/app/src/android/app/cts/BaseTileServiceTest.java
new file mode 100644
index 0000000..940dbf5
--- /dev/null
+++ b/tests/app/src/android/app/cts/BaseTileServiceTest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.cts;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
+import android.app.stubs.BooleanTestTileService;
+import android.app.stubs.TestTileService;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.service.quicksettings.TileService;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.Until;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import androidx.test.InstrumentationRegistry;
+
+import com.android.compatibility.common.util.SystemUtil;
+
+import java.io.IOException;
+
+public abstract class BaseTileServiceTest extends AndroidTestCase {
+
+    protected abstract String getTag();
+    protected abstract String getComponentName();
+    protected abstract TileService getTileServiceInstance();
+    protected abstract void waitForConnected(boolean state) throws InterruptedException;
+    protected abstract void waitForListening(boolean state) throws InterruptedException;
+
+    final static String DUMP_COMMAND =
+            "dumpsys activity service com.android.systemui/.SystemUIService dependency "
+                    + "DumpController qstilehost";
+
+    // Time between checks for state we expect.
+    protected static final long CHECK_DELAY = 250;
+    // Number of times to check before failing. This is set so the maximum wait time is about 4s,
+    // as some tests were observed to take around 3s.
+    protected static final long CHECK_RETRIES = 15;
+    // Timeout to wait for launcher
+    protected static final long TIMEOUT = 8000;
+
+    protected TileService mTileService;
+    private Intent homeIntent;
+    private String mLauncherPackage;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (!TileService.isQuickSettingsSupported()) return;
+        homeIntent = new Intent(Intent.ACTION_MAIN);
+        homeIntent.addCategory(Intent.CATEGORY_HOME);
+
+        mLauncherPackage = mContext.getPackageManager().resolveActivity(homeIntent,
+                PackageManager.MATCH_DEFAULT_ONLY).activityInfo.packageName;
+
+        // Wait for home
+        UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        device.pressHome();
+        device.wait(Until.hasObject(By.pkg(mLauncherPackage).depth(0)), TIMEOUT);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        expandSettings(false);
+        toggleServiceAccess(getComponentName(), false);
+        waitForConnected(false);
+        assertNull(TestTileService.getInstance());
+    }
+
+    protected void startTileService() throws Exception {
+        toggleServiceAccess(getComponentName(), true);
+        waitForConnected(true); // wait for service to be bound
+        mTileService = BooleanTestTileService.getInstance();
+        assertNotNull(mTileService);
+    }
+
+    protected void toggleServiceAccess(String componentName, boolean on) throws Exception {
+        String command = " cmd statusbar " + (on ? "add-tile " : "remove-tile ")
+                + componentName;
+
+        executeShellCommand(command);
+    }
+
+    public String executeShellCommand(String command) throws IOException {
+        Log.i(getTag(), "Shell command: " + command);
+        try {
+            return SystemUtil.runShellCommand(getInstrumentation(), command);
+        } catch (IOException e) {
+            //bubble it up
+            Log.e(getTag(), "Error running shell command: " + command);
+            throw new IOException(e);
+        }
+    }
+
+    protected void expandSettings(boolean expand) throws Exception {
+        executeShellCommand(" cmd statusbar " + (expand ? "expand-settings" : "collapse"));
+        Thread.sleep(200); // wait for animation
+    }
+
+    protected void initializeAndListen() throws Exception {
+        startTileService();
+        expandSettings(true);
+        waitForListening(true);
+    }
+
+    /**
+     * Find a line containing {@code label} in {@code lines}.
+     */
+    protected String findLine(String[] lines, CharSequence label) {
+        for (String line: lines) {
+            if (line.contains(label)) {
+                return line;
+            }
+        }
+        return null;
+    }
+}
diff --git a/tests/app/src/android/app/cts/BooleanTileServiceTest.java b/tests/app/src/android/app/cts/BooleanTileServiceTest.java
new file mode 100644
index 0000000..5b09186
--- /dev/null
+++ b/tests/app/src/android/app/cts/BooleanTileServiceTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.cts;
+
+
+import android.app.stubs.BooleanTestTileService;
+import android.service.quicksettings.Tile;
+import android.service.quicksettings.TileService;
+
+public class BooleanTileServiceTest extends BaseTileServiceTest {
+    private final static String TAG = "BooleanTileServiceTest";
+
+    public void testTileIsBoundAndListening() throws Exception {
+        startTileService();
+        expandSettings(true);
+        waitForListening(true);
+    }
+
+    public void testTileInDumpAndHasBooleanState() throws Exception {
+        initializeAndListen();
+
+        final CharSequence tileLabel = mTileService.getQsTile().getLabel();
+
+        final String[] dumpLines = executeShellCommand(DUMP_COMMAND).split("\n");
+        final String line = findLine(dumpLines, tileLabel);
+        assertNotNull(line);
+        assertTrue(line.trim().startsWith("BooleanState"));
+    }
+
+    public void testTileStartsInactive() throws Exception {
+        initializeAndListen();
+
+        assertEquals(Tile.STATE_INACTIVE, mTileService.getQsTile().getState());
+    }
+
+    public void testValueTracksState() throws Exception {
+        initializeAndListen();
+
+        final CharSequence tileLabel = mTileService.getQsTile().getLabel();
+
+        String[] dumpLines = executeShellCommand(DUMP_COMMAND).split("\n");
+        String line = findLine(dumpLines, tileLabel);
+
+        // Tile starts inactive
+        assertTrue(line.contains("value=false"));
+
+        ((BooleanTestTileService) mTileService).toggleState();
+
+        // Close and open QS to make sure that state is refreshed
+        expandSettings(false);
+        waitForListening(false);
+        expandSettings(true);
+        waitForListening(true);
+
+        assertEquals(Tile.STATE_ACTIVE, mTileService.getQsTile().getState());
+
+        dumpLines = executeShellCommand(DUMP_COMMAND).split("\n");
+        line = findLine(dumpLines, tileLabel);
+
+        assertTrue(line.contains("value=true"));
+    }
+
+    @Override
+    protected String getTag() {
+        return TAG;
+    }
+
+    @Override
+    protected String getComponentName() {
+        return BooleanTestTileService.getComponentName().flattenToString();
+    }
+
+    @Override
+    protected TileService getTileServiceInstance() {
+        return BooleanTestTileService.getInstance();
+    }
+
+    /**
+     * Waits for the TileService to be in the expected listening state. If it times out, it fails
+     * the test
+     * @param state desired listening state
+     * @throws InterruptedException
+     */
+    @Override
+    protected void waitForListening(boolean state) throws InterruptedException {
+        int ct = 0;
+        while (BooleanTestTileService.isListening() != state && (ct++ < CHECK_RETRIES)) {
+            Thread.sleep(CHECK_DELAY);
+        }
+        assertEquals(state, BooleanTestTileService.isListening());
+    }
+
+    /**
+     * Waits for the TileService to be in the expected connected state. If it times out, it fails
+     * the test
+     * @param state desired connected state
+     * @throws InterruptedException
+     */
+    @Override
+    protected void waitForConnected(boolean state) throws InterruptedException {
+        int ct = 0;
+        while (BooleanTestTileService.isConnected() != state && (ct++ < CHECK_RETRIES)) {
+            Thread.sleep(CHECK_DELAY);
+        }
+        assertEquals(state, BooleanTestTileService.isConnected());
+    }
+}
diff --git a/tests/app/src/android/app/cts/TileServiceTest.java b/tests/app/src/android/app/cts/TileServiceTest.java
index 35faf28..9b40fdd 100644
--- a/tests/app/src/android/app/cts/TileServiceTest.java
+++ b/tests/app/src/android/app/cts/TileServiceTest.java
@@ -18,116 +18,48 @@
 
 import android.app.AlertDialog;
 import android.app.Dialog;
-import android.app.UiAutomation;
 import android.app.stubs.TestTileService;
-import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.os.Looper;
-import android.os.ParcelFileDescriptor;
 import android.service.quicksettings.Tile;
 import android.service.quicksettings.TileService;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.Until;
-import android.test.AndroidTestCase;
 
-import androidx.test.filters.FlakyTest;
-import androidx.test.InstrumentationRegistry;
-
-import junit.framework.Assert;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class TileServiceTest extends AndroidTestCase {
-    final String TAG = TileServiceTest.class.getSimpleName();
-
-    // Time between checks for state we expect.
-    private static final long CHECK_DELAY = 250;
-    // Number of times to check before failing. This is set so the maximum wait time is about 4s,
-    // as some tests were observed to take around 3s.
-    private static final long CHECK_RETRIES = 15;
-    // Timeout to wait for launcher
-    private static final long TIMEOUT = 8000;
-
-    private TileService mTileService;
-    private Intent homeIntent;
-    private String mLauncherPackage;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        homeIntent = new Intent(Intent.ACTION_MAIN);
-        homeIntent.addCategory(Intent.CATEGORY_HOME);
-
-        mLauncherPackage = mContext.getPackageManager().resolveActivity(homeIntent,
-                PackageManager.MATCH_DEFAULT_ONLY).activityInfo.packageName;
-
-        // Wait for home
-        UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
-        device.pressHome();
-        device.wait(Until.hasObject(By.pkg(mLauncherPackage).depth(0)), TIMEOUT);
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        expandSettings(false);
-        toggleServiceAccess(TestTileService.getComponentName().flattenToString(), false);
-        waitForConnected(false);
-        assertNull(TestTileService.getInstance());
-    }
+public class TileServiceTest extends BaseTileServiceTest {
+    private final static String TAG = "TileServiceTest";
 
     public void testCreateTileService() {
         final TileService tileService = new TileService();
     }
 
+
     public void testListening() throws Exception {
         if (!TileService.isQuickSettingsSupported()) return;
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
     }
 
     public void testListening_stopped() throws Exception {
-        if (!TileService.isQuickSettingsSupported()) return;
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
         expandSettings(false);
         waitForListening(false);
     }
 
     public void testLocked_deviceNotLocked() throws Exception {
-        if (!TileService.isQuickSettingsSupported()) return;
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
         assertFalse(mTileService.isLocked());
     }
 
     public void testSecure_deviceNotSecure() throws Exception {
-        if (!TileService.isQuickSettingsSupported()) return;
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
         assertFalse(mTileService.isSecure());
     }
     
     public void testTile_hasCorrectIcon() throws Exception {
-        if (!TileService.isQuickSettingsSupported()) return;
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
         Tile tile = mTileService.getQsTile();
         assertEquals(TestTileService.ICON_ID, tile.getIcon().getResId());
     }
 
     public void testTile_hasCorrectSubtitle() throws Exception {
-        if (!TileService.isQuickSettingsSupported()) return;
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
 
         Tile tile = mTileService.getQsTile();
         tile.setSubtitle("test_subtitle");
@@ -136,12 +68,9 @@
     }
 
     public void testShowDialog() throws Exception {
-        if (!TileService.isQuickSettingsSupported()) return;
         Looper.prepare();
         Dialog dialog = new AlertDialog.Builder(mContext).create();
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
         clickTile(TestTileService.getComponentName().flattenToString());
         waitForClick();
 
@@ -152,10 +81,7 @@
     }
 
     public void testUnlockAndRun_phoneIsUnlockedActivityIsRun() throws Exception {
-        if (!TileService.isQuickSettingsSupported()) return;
-        startTileService();
-        expandSettings(true);
-        waitForListening(true);
+        initializeAndListen();
         assertFalse(mTileService.isLocked());
 
         TestRunnable testRunnable = new TestRunnable();
@@ -165,40 +91,19 @@
         waitForRun(testRunnable);
     }
 
-    private void startTileService() throws Exception {
-        toggleServiceAccess(TestTileService.getComponentName().flattenToString(), true);
-        waitForConnected(true); // wait for service to be bound
-        mTileService = TestTileService.getInstance();
-        assertNotNull(mTileService);
-    }
+    public void testTileInDumpAndHasState() throws Exception {
+        initializeAndListen();
 
-    private void toggleServiceAccess(String componentName, boolean on) throws Exception {
+        final CharSequence tileLabel = mTileService.getQsTile().getLabel();
 
-        String command = " cmd statusbar " + (on ? "add-tile " : "remove-tile ")
-                + componentName;
-
-        runCommand(command);
+        final String[] dumpLines = executeShellCommand(DUMP_COMMAND).split("\n");
+        final String line = findLine(dumpLines, tileLabel);
+        assertNotNull(line);
+        assertTrue(line.trim().startsWith("State")); // Not BooleanState
     }
 
     private void clickTile(String componentName) throws Exception {
-        runCommand(" cmd statusbar click-tile " + componentName);
-    }
-
-    private void runCommand(String command) throws IOException {
-        UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
-        // Execute command
-        try (ParcelFileDescriptor fd = uiAutomation.executeShellCommand(command)) {
-            Assert.assertNotNull("Failed to execute shell command: " + command, fd);
-            // Wait for the command to finish by reading until EOF
-            try (InputStream in = new FileInputStream(fd.getFileDescriptor())) {
-                byte[] buffer = new byte[4096];
-                while (in.read(buffer) > 0) {}
-            } catch (IOException e) {
-                throw new IOException("Could not read stdout of command: " + command, e);
-            }
-        } finally {
-            uiAutomation.destroy();
-        }
+        executeShellCommand(" cmd statusbar click-tile " + componentName);
     }
 
     /**
@@ -225,13 +130,8 @@
         assertTrue(t.hasRan);
     }
 
-    /**
-     * Waits for the TileService to be in the expected listening state. If it times out, it fails
-     * the test
-     * @param state desired listening state
-     * @throws InterruptedException
-     */
-    private void waitForListening(boolean state) throws InterruptedException {
+    @Override
+    protected void waitForListening(boolean state) throws InterruptedException {
         int ct = 0;
         while (TestTileService.isListening() != state && (ct++ < CHECK_RETRIES)) {
             Thread.sleep(CHECK_DELAY);
@@ -245,7 +145,8 @@
      * @param state desired connected state
      * @throws InterruptedException
      */
-    private void waitForConnected(boolean state) throws InterruptedException {
+    @Override
+    protected void waitForConnected(boolean state) throws InterruptedException {
         int ct = 0;
         while (TestTileService.isConnected() != state && (ct++ < CHECK_RETRIES)) {
             Thread.sleep(CHECK_DELAY);
@@ -253,9 +154,19 @@
         assertEquals(state, TestTileService.isConnected());
     }
 
-    private void expandSettings(boolean expand) throws Exception {
-        runCommand(" cmd statusbar " + (expand ? "expand-settings" : "collapse"));
-        Thread.sleep(200); // wait for animation
+    @Override
+    protected String getTag() {
+        return TAG;
+    }
+
+    @Override
+    protected String getComponentName() {
+        return TestTileService.getComponentName().flattenToString();
+    }
+
+    @Override
+    protected TileService getTileServiceInstance() {
+        return TestTileService.getInstance();
     }
 
     class TestRunnable implements Runnable {
diff --git a/tests/apppredictionservice/AndroidTest.xml b/tests/apppredictionservice/AndroidTest.xml
index 8166a4c..5a689be 100644
--- a/tests/apppredictionservice/AndroidTest.xml
+++ b/tests/apppredictionservice/AndroidTest.xml
@@ -18,6 +18,7 @@
   <option name="config-descriptor:metadata" key="component" value="framework" />
   <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
   <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+  <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
   <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
     <option name="cleanup-apks" value="true" />
     <option name="test-file-name" value="CtsAppPredictionServiceTestCases.apk" />
diff --git a/tests/autofillservice/AndroidManifest.xml b/tests/autofillservice/AndroidManifest.xml
index fe21919..5afe073 100644
--- a/tests/autofillservice/AndroidManifest.xml
+++ b/tests/autofillservice/AndroidManifest.xml
@@ -123,6 +123,8 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        <activity android:name=".SimpleAfterLoginActivity" />
+        <activity android:name=".SimpleBeforeLoginActivity" />
 
         <receiver android:name=".SelfDestructReceiver"
             android:exported="true"
diff --git a/tests/autofillservice/res/layout/simple_after_login_activity.xml b/tests/autofillservice/res/layout/simple_after_login_activity.xml
new file mode 100644
index 0000000..1752af5
--- /dev/null
+++ b/tests/autofillservice/res/layout/simple_after_login_activity.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="wrap_content"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:id="@+id/after_login"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Finished login activity!" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/autofillservice/res/layout/simple_before_login_activity.xml b/tests/autofillservice/res/layout/simple_before_login_activity.xml
new file mode 100644
index 0000000..79ba1f7
--- /dev/null
+++ b/tests/autofillservice/res/layout/simple_before_login_activity.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="wrap_content"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:id="@+id/before_login"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Launch login activity!" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AutofillSaveDialogTest.java b/tests/autofillservice/src/android/autofillservice/cts/AutofillSaveDialogTest.java
new file mode 100644
index 0000000..2c5dc0c
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/AutofillSaveDialogTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.autofillservice.cts;
+
+import static android.autofillservice.cts.Helper.ID_USERNAME;
+import static android.service.autofill.SaveInfo.SAVE_DATA_TYPE_USERNAME;
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.View;
+
+import org.junit.Test;
+
+/**
+ * Tests whether autofill save dialog is shown as expected.
+ */
+public class AutofillSaveDialogTest extends AutoFillServiceTestCase.ManualActivityLaunch {
+
+    @Test
+    public void testShowSaveUiWhenLaunchActivityWithFlagClearTopAndSingleTop() throws Exception {
+        // Set service.
+        enableService();
+
+        // Start SimpleBeforeLoginActivity before login activity.
+        startActivityWithFlag(mContext, SimpleBeforeLoginActivity.class,
+                Intent.FLAG_ACTIVITY_NEW_TASK);
+        mUiBot.assertShownByRelativeId(SimpleBeforeLoginActivity.ID_BEFORE_LOGIN);
+
+        // Start LoginActivity.
+        startActivityWithFlag(SimpleBeforeLoginActivity.getCurrentActivity(), LoginActivity.class,
+                /* flags= */ 0);
+        mUiBot.assertShownByRelativeId(LoginActivity.ID_USERNAME_CONTAINER);
+
+        sReplier.addResponse(new CannedFillResponse.Builder()
+                .setRequiredSavableIds(SAVE_DATA_TYPE_USERNAME, ID_USERNAME)
+                .build());
+
+        // Trigger autofill on username.
+        LoginActivity loginActivity = LoginActivity.getCurrentActivity();
+        loginActivity.onUsername(View::requestFocus);
+
+        // Wait for fill request to be processed.
+        sReplier.getNextFillRequest();
+
+        // Set data.
+        loginActivity.onUsername((v) -> v.setText("test"));
+
+        // Start SimpleAfterLoginActivity after login activity.
+        startActivityWithFlag(loginActivity, SimpleAfterLoginActivity.class, /* flags= */ 0);
+        mUiBot.assertShownByRelativeId(SimpleAfterLoginActivity.ID_AFTER_LOGIN);
+
+        mUiBot.assertSaveNotShowing(SAVE_DATA_TYPE_USERNAME);
+
+        // Restart SimpleBeforeLoginActivity with CLEAR_TOP and SINGLE_TOP.
+        startActivityWithFlag(SimpleAfterLoginActivity.getCurrentActivity(),
+                SimpleBeforeLoginActivity.class,
+                Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+        mUiBot.assertShownByRelativeId(SimpleBeforeLoginActivity.ID_BEFORE_LOGIN);
+
+        // Verify save ui dialog.
+        mUiBot.assertSaveShowing(SAVE_DATA_TYPE_USERNAME);
+    }
+
+    @Test
+    public void testShowSaveUiWhenLaunchActivityWithFlagClearTaskAndNewTask() throws Exception {
+        // Set service.
+        enableService();
+
+        // Start SimpleBeforeLoginActivity before login activity.
+        startActivityWithFlag(mContext, SimpleBeforeLoginActivity.class,
+                Intent.FLAG_ACTIVITY_NEW_TASK);
+        mUiBot.assertShownByRelativeId(SimpleBeforeLoginActivity.ID_BEFORE_LOGIN);
+
+        // Start LoginActivity.
+        startActivityWithFlag(SimpleBeforeLoginActivity.getCurrentActivity(), LoginActivity.class,
+                /* flags= */ 0);
+        mUiBot.assertShownByRelativeId(LoginActivity.ID_USERNAME_CONTAINER);
+
+        sReplier.addResponse(new CannedFillResponse.Builder()
+                .setRequiredSavableIds(SAVE_DATA_TYPE_USERNAME, ID_USERNAME)
+                .build());
+
+        // Trigger autofill on username.
+        LoginActivity loginActivity = LoginActivity.getCurrentActivity();
+        loginActivity.onUsername(View::requestFocus);
+
+        // Wait for fill request to be processed.
+        sReplier.getNextFillRequest();
+
+        // Set data.
+        loginActivity.onUsername((v) -> v.setText("test"));
+
+        // Start SimpleAfterLoginActivity with CLEAR_TASK and NEW_TASK after login activity.
+        startActivityWithFlag(loginActivity, SimpleAfterLoginActivity.class,
+                Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
+        mUiBot.assertShownByRelativeId(SimpleAfterLoginActivity.ID_AFTER_LOGIN);
+
+        // Verify save ui dialog.
+        mUiBot.assertSaveShowing(SAVE_DATA_TYPE_USERNAME);
+    }
+
+    private void startActivityWithFlag(Context context, Class<?> clazz, int flags) {
+        final Intent intent = new Intent(context, clazz);
+        intent.setFlags(flags);
+        context.startActivity(intent);
+    }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SimpleAfterLoginActivity.java b/tests/autofillservice/src/android/autofillservice/cts/SimpleAfterLoginActivity.java
new file mode 100644
index 0000000..8142f3a
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleAfterLoginActivity.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.autofillservice.cts;
+
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * Activity that displays a "Finished login activity!" message after login.
+ */
+public class SimpleAfterLoginActivity extends AbstractAutoFillActivity {
+
+    private static final String TAG = "SimpleAfterLoginActivity";
+
+    static final String ID_AFTER_LOGIN = "after_login";
+
+    private static SimpleAfterLoginActivity sCurrentActivity;
+
+    public static SimpleAfterLoginActivity getCurrentActivity() {
+        return sCurrentActivity;
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.simple_after_login_activity);
+
+        Log.v(TAG, "Set sCurrentActivity to this onCreate()");
+        sCurrentActivity = this;
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+
+        Log.v(TAG, "Set sCurrentActivity to null onDestroy()");
+        sCurrentActivity = null;
+    }
+}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SimpleBeforeLoginActivity.java b/tests/autofillservice/src/android/autofillservice/cts/SimpleBeforeLoginActivity.java
new file mode 100644
index 0000000..e14a6a4
--- /dev/null
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleBeforeLoginActivity.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.autofillservice.cts;
+
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * Activity that displays a "Launch login activity!" message before login.
+ */
+public class SimpleBeforeLoginActivity extends AbstractAutoFillActivity {
+
+    private static final String TAG = "SimpleBeforeLoginActivity";
+
+    static final String ID_BEFORE_LOGIN = "before_login";
+
+    private static SimpleBeforeLoginActivity sCurrentActivity;
+
+    public static SimpleBeforeLoginActivity getCurrentActivity() {
+        return sCurrentActivity;
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.simple_before_login_activity);
+
+        Log.v(TAG, "Set sCurrentActivity to this onCreate()");
+        sCurrentActivity = this;
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+
+        Log.v(TAG, "Set sCurrentActivity to null onDestroy()");
+        sCurrentActivity = null;
+    }
+}
diff --git a/tests/camera/api25test/AndroidTest.xml b/tests/camera/api25test/AndroidTest.xml
index 2a4bed1..b431952 100644
--- a/tests/camera/api25test/AndroidTest.xml
+++ b/tests/camera/api25test/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="camera" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="not-shardable" value="true" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/contentcaptureservice/AndroidTest.xml b/tests/contentcaptureservice/AndroidTest.xml
index f8afb9a..ed7cbe7 100644
--- a/tests/contentcaptureservice/AndroidTest.xml
+++ b/tests/contentcaptureservice/AndroidTest.xml
@@ -22,6 +22,7 @@
   <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
     <option name="cleanup-apks" value="true" />
     <option name="test-file-name" value="CtsContentCaptureServiceTestCases.apk" />
+    <option name="test-file-name" value="CtsOutsideOfPackageActivity.apk" />
   </target_preparer>
 
   <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
diff --git a/tests/contentcaptureservice/OutsideOfPackageActivity/Android.bp b/tests/contentcaptureservice/OutsideOfPackageActivity/Android.bp
new file mode 100644
index 0000000..1f35d9b
--- /dev/null
+++ b/tests/contentcaptureservice/OutsideOfPackageActivity/Android.bp
@@ -0,0 +1,28 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsOutsideOfPackageActivity",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    srcs: ["src/**/*.java"],
+}
diff --git a/tests/contentcaptureservice/OutsideOfPackageActivity/AndroidManifest.xml b/tests/contentcaptureservice/OutsideOfPackageActivity/AndroidManifest.xml
new file mode 100644
index 0000000..ea2fa41
--- /dev/null
+++ b/tests/contentcaptureservice/OutsideOfPackageActivity/AndroidManifest.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.contentcaptureservice.cts2"
+          android:targetSandboxVersion="2">
+
+    <application>
+
+        <uses-library android:name="android.test.runner" />
+
+        <activity android:name=".OutsideOfPackageActivity"
+                  android:label="OutsideOfPackage"
+                  android:taskAffinity=".OutsideOfPackageActivity"
+                  android:theme="@android:style/Theme.NoTitleBar">
+            <intent-filter>
+                <!-- This intent filter is not really needed by CTS, but it makes easier to launch
+                     this app during CTS development... -->
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+    <instrumentation
+        android:name="androidx.test.runner.AndroidJUnitRunner"
+        android:label="CTS tests for the AutoFill Framework APIs."
+        android:targetPackage="android.contentcaptureservice.cts2" >
+    </instrumentation>
+
+</manifest>
diff --git a/tests/contentcaptureservice/OutsideOfPackageActivity/src/android/contentcaptureservice/cts2/OutsideOfPackageActivity.java b/tests/contentcaptureservice/OutsideOfPackageActivity/src/android/contentcaptureservice/cts2/OutsideOfPackageActivity.java
new file mode 100644
index 0000000..a5e6e24
--- /dev/null
+++ b/tests/contentcaptureservice/OutsideOfPackageActivity/src/android/contentcaptureservice/cts2/OutsideOfPackageActivity.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.contentcaptureservice.cts2;
+
+import android.app.Activity;
+import android.util.Log;
+import android.widget.EditText;
+import android.widget.TextView;
+
+public class OutsideOfPackageActivity extends Activity {
+
+    private static final String TAG = OutsideOfPackageActivity.class.getSimpleName();
+
+    TextView mUsernameLabel;
+    EditText mUsername;
+    TextView mPasswordLabel;
+    EditText mPassword;
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        Log.d(TAG, "AutofillIds: " + "usernameLabel=" + mUsernameLabel.getAutofillId()
+                + ", username=" + mUsername.getAutofillId()
+                + ", passwordLabel=" + mPasswordLabel.getAutofillId()
+                + ", password=" + mPassword.getAutofillId());
+    }
+}
diff --git a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/AbstractContentCaptureActivity.java b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/AbstractContentCaptureActivity.java
index 072c770..3cf1acc 100644
--- a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/AbstractContentCaptureActivity.java
+++ b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/AbstractContentCaptureActivity.java
@@ -35,7 +35,7 @@
 /**
  * Base class for all activities.
  */
-abstract class AbstractContentCaptureActivity extends Activity {
+public abstract class AbstractContentCaptureActivity extends Activity {
 
     private final String mTag = getClass().getSimpleName();
 
diff --git a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/BlankActivityTest.java b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/BlankActivityTest.java
index 6775d56..4424fef 100644
--- a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/BlankActivityTest.java
+++ b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/BlankActivityTest.java
@@ -15,8 +15,10 @@
  */
 package android.contentcaptureservice.cts;
 
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
 import static android.contentcaptureservice.cts.CtsContentCaptureService.CONTENT_CAPTURE_SERVICE_COMPONENT_NAME;
 import static android.contentcaptureservice.cts.Helper.resetService;
+import static android.contentcaptureservice.cts.Helper.sContext;
 
 import static com.android.compatibility.common.util.ActivitiesWatcher.ActivityLifecycle.DESTROYED;
 import static com.android.compatibility.common.util.ActivitiesWatcher.ActivityLifecycle.RESUMED;
@@ -24,6 +26,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.ComponentName;
+import android.content.Intent;
 import android.contentcaptureservice.cts.CtsContentCaptureService.Session;
 import android.platform.test.annotations.AppModeFull;
 import android.util.Log;
@@ -161,4 +164,19 @@
         resetService();
         service.waitUntilDisconnected();
     }
+
+    @Test
+    public void testOutsideOfPackageActivity_noSessionCreated() throws Exception {
+        final CtsContentCaptureService service = enableService();
+        final ActivityWatcher watcher = startWatcher();
+
+        Intent outsideActivity = new Intent();
+        outsideActivity.setComponent(new ComponentName("android.contentcaptureservice.cts2",
+                "android.contentcaptureservice.cts2.OutsideOfPackageActivity"));
+        outsideActivity.setFlags(FLAG_ACTIVITY_NEW_TASK);
+
+        sContext.startActivity(outsideActivity);
+
+        assertThat(service.getAllSessionIds()).isEmpty();
+    }
 }
diff --git a/tests/filesystem/AndroidTest.xml b/tests/filesystem/AndroidTest.xml
index 3ab61fe..2612765 100644
--- a/tests/filesystem/AndroidTest.xml
+++ b/tests/filesystem/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="framework" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsFileSystemTestCases.apk" />
diff --git a/tests/fragment/AndroidTest.xml b/tests/fragment/AndroidTest.xml
index 902b754..d8264bd 100644
--- a/tests/fragment/AndroidTest.xml
+++ b/tests/fragment/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="uitoolkit" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsFragmentTestCases.apk" />
diff --git a/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java b/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java
index 879fbb7..cfb8da5 100644
--- a/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java
+++ b/tests/framework/base/windowmanager/app/src/android/server/wm/app/Components.java
@@ -395,6 +395,8 @@
     public static class TopActivity {
         public static final String EXTRA_FINISH_DELAY = "FINISH_DELAY";
         public static final String EXTRA_TOP_WALLPAPER = "USE_WALLPAPER";
+        public static final String ACTION_CONVERT_TO_TRANSLUCENT = "convert_to_translucent";
+        public static final String ACTION_CONVERT_FROM_TRANSLUCENT = "convert_from_translucent";
     }
 
     /**
diff --git a/tests/framework/base/windowmanager/app/src/android/server/wm/app/TopActivity.java b/tests/framework/base/windowmanager/app/src/android/server/wm/app/TopActivity.java
index 295b7f8..18a1e51 100644
--- a/tests/framework/base/windowmanager/app/src/android/server/wm/app/TopActivity.java
+++ b/tests/framework/base/windowmanager/app/src/android/server/wm/app/TopActivity.java
@@ -16,6 +16,8 @@
 
 package android.server.wm.app;
 
+import static android.server.wm.app.Components.TopActivity.ACTION_CONVERT_FROM_TRANSLUCENT;
+import static android.server.wm.app.Components.TopActivity.ACTION_CONVERT_TO_TRANSLUCENT;
 import static android.server.wm.app.Components.TopActivity.EXTRA_FINISH_DELAY;
 import static android.server.wm.app.Components.TopActivity.EXTRA_TOP_WALLPAPER;
 
@@ -47,4 +49,18 @@
             }, finishDelay);
         }
     }
+
+    @Override
+    public void handleCommand(String command, Bundle data) {
+        switch(command) {
+            case ACTION_CONVERT_TO_TRANSLUCENT:
+                TopActivity.this.setTranslucent(true);
+                break;
+            case ACTION_CONVERT_FROM_TRANSLUCENT:
+                TopActivity.this.setTranslucent(false);
+                break;
+            default:
+                super.handleCommand(command, data);
+        }
+    }
 }
diff --git a/tests/framework/base/windowmanager/intent_tests/resetTaskIfNeeded/reset-task.json b/tests/framework/base/windowmanager/intent_tests/resetTaskIfNeeded/reset-task.json
new file mode 100644
index 0000000..5d5aae5
--- /dev/null
+++ b/tests/framework/base/windowmanager/intent_tests/resetTaskIfNeeded/reset-task.json
@@ -0,0 +1,58 @@
+{
+    "setup": {
+        "initialIntents": [
+            {
+                "flags": "FLAG_ACTIVITY_NEW_TASK",
+                "class": "android.server.wm.intent.Activities$RegularActivity",
+                "package": "android.server.wm.cts",
+                "startForResult": false
+            }
+        ],
+        "act": [
+            {
+                "flags": "FLAG_ACTIVITY_RESET_TASK_IF_NEEDED",
+                "class": "android.server.wm.intent.Activities$NoHistoryActivity",
+                "package": "android.server.wm.cts",
+                "startForResult": false
+            }
+        ]
+    },
+    "initialState": {
+        "stacks": [
+            {
+                "tasks": [
+                    {
+                        "activities": [
+                            {
+                                "name": "android.server.wm.cts\/android.server.wm.intent.Activities$RegularActivity",
+                                "state": "RESUMED"
+                            }
+                        ]
+                    }
+                ],
+                "resumedActivity": "android.server.wm.cts\/android.server.wm.intent.Activities$RegularActivity"
+            }
+        ]
+    },
+    "endState": {
+        "stacks": [
+            {
+                "tasks": [
+                    {
+                        "activities": [
+                            {
+                                "name": "android.server.wm.cts\/android.server.wm.intent.Activities$NoHistoryActivity",
+                                "state": "RESUMED"
+                            },
+                            {
+                                "name": "android.server.wm.cts\/android.server.wm.intent.Activities$RegularActivity",
+                                "state": "STOPPED"
+                            }
+                        ]
+                    }
+                ],
+                "resumedActivity": "android.server.wm.cts\/android.server.wm.intent.Activities$NoHistoryActivity"
+            }
+        ]
+    }
+}
diff --git a/tests/framework/base/windowmanager/intent_tests/resetTaskIfNeeded/reset-task_with_new-task.json b/tests/framework/base/windowmanager/intent_tests/resetTaskIfNeeded/reset-task_with_new-task.json
new file mode 100644
index 0000000..c059027
--- /dev/null
+++ b/tests/framework/base/windowmanager/intent_tests/resetTaskIfNeeded/reset-task_with_new-task.json
@@ -0,0 +1,54 @@
+{
+    "setup": {
+        "initialIntents": [
+            {
+                "flags": "FLAG_ACTIVITY_NEW_TASK",
+                "class": "android.server.wm.intent.Activities$RegularActivity",
+                "package": "android.server.wm.cts",
+                "startForResult": false
+            }
+        ],
+        "act": [
+            {
+                "flags": "FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED",
+                "class": "android.server.wm.intent.Activities$NoHistoryActivity",
+                "package": "android.server.wm.cts",
+                "startForResult": false
+            }
+        ]
+    },
+    "initialState": {
+        "stacks": [
+            {
+                "tasks": [
+                    {
+                        "activities": [
+                            {
+                                "name": "android.server.wm.cts\/android.server.wm.intent.Activities$RegularActivity",
+                                "state": "RESUMED"
+                            }
+                        ]
+                    }
+                ],
+                "resumedActivity": "android.server.wm.cts\/android.server.wm.intent.Activities$RegularActivity"
+            }
+        ]
+    },
+    "endState": {
+        "stacks": [
+            {
+                "tasks": [
+                    {
+                        "activities": [
+                            {
+                                "name": "android.server.wm.cts\/android.server.wm.intent.Activities$RegularActivity",
+                                "state": "RESUMED"
+                            }
+                        ]
+                    }
+                ],
+                "resumedActivity": "android.server.wm.cts\/android.server.wm.intent.Activities$RegularActivity"
+            }
+        ]
+    }
+}
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java b/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java
index 63947ba..fa46aa0 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java
@@ -42,15 +42,20 @@
 import static android.server.wm.app.Components.MoveTaskToBackActivity.FINISH_POINT_ON_PAUSE;
 import static android.server.wm.app.Components.MoveTaskToBackActivity.FINISH_POINT_ON_STOP;
 import static android.server.wm.app.Components.NO_HISTORY_ACTIVITY;
+import static android.server.wm.app.Components.SHOW_WHEN_LOCKED_DIALOG_ACTIVITY;
 import static android.server.wm.app.Components.SWIPE_REFRESH_ACTIVITY;
 import static android.server.wm.app.Components.TEST_ACTIVITY;
+import static android.server.wm.app.Components.TOP_ACTIVITY;
 import static android.server.wm.app.Components.TRANSLUCENT_ACTIVITY;
+import static android.server.wm.app.Components.TRANSLUCENT_TOP_ACTIVITY;
 import static android.server.wm.app.Components.TURN_SCREEN_ON_ACTIVITY;
 import static android.server.wm.app.Components.TURN_SCREEN_ON_ATTR_ACTIVITY;
 import static android.server.wm.app.Components.TURN_SCREEN_ON_ATTR_REMOVE_ATTR_ACTIVITY;
 import static android.server.wm.app.Components.TURN_SCREEN_ON_SHOW_ON_LOCK_ACTIVITY;
 import static android.server.wm.app.Components.TURN_SCREEN_ON_SINGLE_TASK_ACTIVITY;
 import static android.server.wm.app.Components.TURN_SCREEN_ON_WITH_RELAYOUT_ACTIVITY;
+import static android.server.wm.app.Components.TopActivity.ACTION_CONVERT_FROM_TRANSLUCENT;
+import static android.server.wm.app.Components.TopActivity.ACTION_CONVERT_TO_TRANSLUCENT;
 import static android.view.Display.DEFAULT_DISPLAY;
 
 import static org.junit.Assert.assertFalse;
@@ -58,6 +63,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeTrue;
 
+import android.content.ComponentName;
 import android.platform.test.annotations.Presubmit;
 import android.server.wm.CommandSession.ActivitySession;
 import android.server.wm.CommandSession.ActivitySessionClient;
@@ -556,4 +562,86 @@
                 "Activity should become STOPPED");
         mAmWmState.assertVisibility(TEST_ACTIVITY, false);
     }
+
+    @Test
+    public void testConvertTranslucentOnTranslucentActivity() {
+        try (final ActivitySessionClient activityClient = new ActivitySessionClient(mContext)) {
+            // Start CONVERT_TRANSLUCENT_DIALOG_ACTIVITY on top of LAUNCHING_ACTIVITY
+            final ActivitySession activity = activityClient.startActivity(
+                    getLaunchActivityBuilder().setTargetActivity(TRANSLUCENT_TOP_ACTIVITY));
+            verifyActivityVisibilities(TRANSLUCENT_TOP_ACTIVITY, false);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, false);
+
+            activity.sendCommand(ACTION_CONVERT_FROM_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, true);
+
+            activity.sendCommand(ACTION_CONVERT_TO_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, false);
+        }
+    }
+
+    @Test
+    public void testConvertTranslucentOnNonTopTranslucentActivity() {
+        try (final ActivitySessionClient activityClient = new ActivitySessionClient(mContext)) {
+            final ActivitySession activity = activityClient.startActivity(
+                    getLaunchActivityBuilder().setTargetActivity(TRANSLUCENT_TOP_ACTIVITY));
+            getLaunchActivityBuilder().setTargetActivity(SHOW_WHEN_LOCKED_DIALOG_ACTIVITY)
+                    .setUseInstrumentation().execute();
+            verifyActivityVisibilities(SHOW_WHEN_LOCKED_DIALOG_ACTIVITY, false);
+            verifyActivityVisibilities(TRANSLUCENT_TOP_ACTIVITY, false);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, false);
+
+            activity.sendCommand(ACTION_CONVERT_FROM_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, true);
+
+            activity.sendCommand(ACTION_CONVERT_TO_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, false);
+        }
+    }
+
+    @Test
+    public void testConvertTranslucentOnOpaqueActivity() {
+        try (final ActivitySessionClient activityClient = new ActivitySessionClient(mContext)) {
+            final ActivitySession activity = activityClient.startActivity(
+                    getLaunchActivityBuilder().setTargetActivity(TOP_ACTIVITY));
+            verifyActivityVisibilities(TOP_ACTIVITY, false);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, true);
+
+            activity.sendCommand(ACTION_CONVERT_TO_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, false);
+
+            activity.sendCommand(ACTION_CONVERT_FROM_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, true);
+        }
+    }
+
+    @Test
+    public void testConvertTranslucentOnNonTopOpaqueActivity() {
+        try (final ActivitySessionClient activityClient = new ActivitySessionClient(mContext)) {
+            final ActivitySession activity = activityClient.startActivity(
+                    getLaunchActivityBuilder().setTargetActivity(TOP_ACTIVITY));
+            getLaunchActivityBuilder().setTargetActivity(SHOW_WHEN_LOCKED_DIALOG_ACTIVITY)
+                    .setUseInstrumentation().execute();
+            verifyActivityVisibilities(SHOW_WHEN_LOCKED_DIALOG_ACTIVITY, false);
+            verifyActivityVisibilities(TOP_ACTIVITY, false);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, true);
+
+            activity.sendCommand(ACTION_CONVERT_TO_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, false);
+
+            activity.sendCommand(ACTION_CONVERT_FROM_TRANSLUCENT);
+            verifyActivityVisibilities(LAUNCHING_ACTIVITY, true);
+        }
+    }
+
+    private void verifyActivityVisibilities(ComponentName activityBehind,
+            boolean behindFullScreen) {
+        if (behindFullScreen) {
+            mAmWmState.waitForActivityState(activityBehind, STATE_STOPPED);
+            mAmWmState.assertVisibility(activityBehind, false);
+        } else {
+            mAmWmState.waitForValidState(activityBehind);
+            mAmWmState.assertVisibility(activityBehind, true);
+        }
+    }
 }
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/AppConfigurationTests.java b/tests/framework/base/windowmanager/src/android/server/wm/AppConfigurationTests.java
index 9fffd6b..ce2a776 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/AppConfigurationTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/AppConfigurationTests.java
@@ -248,16 +248,14 @@
         // Make sure docked stack is focused. This way when we dismiss it later fullscreen stack
         // will come up.
         launchActivity(activityName, WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
-        mAmWmState.computeState(false /* compareTaskAndStackBounds */,
-                new WaitForValidActivityState.Builder(activityName).build());
-        final ActivityManagerState.ActivityStack stack = mAmWmState.getAmState()
-                .getStandardStackByWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
 
         // Resize docked stack to fullscreen size. This will trigger activity relaunch with
         // non-empty override configuration corresponding to fullscreen size.
         separateTestJournal();
-        resizeDockedStack(displayRect.left, displayRect.top, displayRect.width(),
-                displayRect.height());
+        final int width = displayRect.width();
+        final int height = displayRect.height();
+        resizeDockedStack(width /* stackWidth */, height /* stackHeight */,
+                width /* taskWidth */, height /* taskHeight */);
 
         // Move activity back to fullscreen stack.
         setActivityTaskWindowingMode(activityName,
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/SplitScreenTests.java b/tests/framework/base/windowmanager/src/android/server/wm/SplitScreenTests.java
index a4857ba..e764514 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/SplitScreenTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/SplitScreenTests.java
@@ -399,7 +399,8 @@
              final LockScreenSession lockScreenSession = new LockScreenSession()) {
             for (int i = 0; i < 4; i++) {
                 lockScreenSession.sleepDevice();
-                rotationSession.set(i);
+                // The display may not be rotated while device is locked.
+                rotationSession.set(i, false /* waitDeviceRotation */);
                 lockScreenSession.wakeUpDevice()
                         .unlockDevice();
                 mAmWmState.computeState(LAUNCHING_ACTIVITY, TEST_ACTIVITY);
@@ -458,8 +459,10 @@
         // going home has the correct app transition
         try (final RotationSession rotationSession = new RotationSession()) {
             for (int rotation = ROTATION_0; rotation <= ROTATION_270; rotation++) {
-                rotationSession.set(rotation);
                 launchActivityInDockStackAndMinimize(DOCKED_ACTIVITY);
+                // Set rotation after docked stack exists so the display can be rotated (home may
+                // be fixed-orientation if it is fullscreen).
+                rotationSession.set(rotation);
 
                 if (mIsHomeRecentsComponent) {
                     launchActivity(TEST_ACTIVITY,
@@ -665,25 +668,24 @@
                 expectedHomeStackIndex, homeStackIndex);
     }
 
-    private void launchActivityInDockStackAndMinimize(ComponentName activityName) throws Exception {
+    private void launchActivityInDockStackAndMinimize(ComponentName activityName) {
         launchActivityInDockStackAndMinimize(activityName, SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT);
     }
 
-    private void launchActivityInDockStackAndMinimize(ComponentName activityName, int createMode)
-            throws Exception {
+    private void launchActivityInDockStackAndMinimize(ComponentName activityName, int createMode) {
         launchActivityInSplitScreenWithRecents(activityName, createMode);
         launchHomeActivityNoWait();
-        waitForAndAssertDockMinimized();
+        waitForAndAssertDockMinimized(activityName);
     }
 
     private void assertDockMinimized() {
         assertTrue(mAmWmState.getWmState().isDockedStackMinimized());
     }
 
-    private void waitForAndAssertDockMinimized() throws Exception {
+    private void waitForAndAssertDockMinimized(ComponentName activityName)  {
         waitForDockMinimized();
         assertDockMinimized();
-        mAmWmState.computeState(TEST_ACTIVITY);
+        mAmWmState.computeState(activityName);
         mAmWmState.assertContainsStack("Must contain docked stack.",
                 WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_STANDARD);
         mAmWmState.assertFocusedStack("Home activity should be focused in minimized mode",
@@ -694,12 +696,12 @@
         assertFalse(mAmWmState.getWmState().isDockedStackMinimized());
     }
 
-    private void waitForDockMinimized() throws Exception {
+    private void waitForDockMinimized() {
         mAmWmState.waitForWithWmState(state -> state.isDockedStackMinimized(),
                 "Dock stack to be minimized");
     }
 
-    private void waitForDockNotMinimized() throws Exception {
+    private void waitForDockNotMinimized() {
         mAmWmState.waitForWithWmState(state -> !state.isDockedStackMinimized(),
                 "Dock stack to not be minimized");
     }
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityAndWindowManagersState.java b/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityAndWindowManagersState.java
index 57e20c5..fe7a7ef 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityAndWindowManagersState.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityAndWindowManagersState.java
@@ -421,8 +421,7 @@
                     if (stackId != INVALID_STACK_ID && ws.getStackId() != stackId) {
                         continue;
                     }
-                    if (windowingMode != WINDOWING_MODE_UNDEFINED
-                            && ws.getWindowingMode() != windowingMode) {
+                    if (!ws.isWindowingModeCompatible(windowingMode)) {
                         continue;
                     }
                     if (activityType != ACTIVITY_TYPE_UNDEFINED
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java b/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java
index 05392a2..7cf31de 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java
@@ -59,6 +59,7 @@
 import static android.server.wm.ActivityLauncher.KEY_USE_APPLICATION_CONTEXT;
 import static android.server.wm.ActivityLauncher.launchActivityFromExtras;
 import static android.server.wm.ActivityManagerState.STATE_RESUMED;
+import static android.server.wm.CommandSession.KEY_FORWARD;
 import static android.server.wm.ComponentNameUtils.getActivityName;
 import static android.server.wm.ComponentNameUtils.getLogTag;
 import static android.server.wm.StateLogger.log;
@@ -1227,12 +1228,26 @@
 
         @Override
         public void set(@NonNull Integer value) {
+            set(value, true /* waitDeviceRotation */);
+        }
+
+        /**
+         * Sets the rotation preference.
+         *
+         * @param value The rotation between {@link android.view.Surface#ROTATION_0} ~
+         *              {@link android.view.Surface#ROTATION_270}
+         * @param waitDeviceRotation If {@code true}, it will wait until the display has applied the
+         *                           rotation. Otherwise it only waits for the settings value has
+         *                           been changed.
+         */
+        public void set(@NonNull Integer value, boolean waitDeviceRotation) {
             // When the rotation is locked and the SystemUI receives the rotation becoming 0deg, it
             // will call freezeRotation to WMS, which will cause USER_ROTATION be set to zero again.
             // In order to prevent our test target from being overwritten by SystemUI during
             // rotation test, wait for the USER_ROTATION changed then continue testing.
             final boolean waitSystemUI = value == ROTATION_0 && mPreviousDegree != ROTATION_0;
-            if (waitSystemUI) {
+            final boolean observeRotationSettings = waitSystemUI || !waitDeviceRotation;
+            if (observeRotationSettings) {
                 mRotationObserver.observe();
             }
             mUserRotation.set(value);
@@ -1244,10 +1259,17 @@
                         // rotates to 0deg, RotationContextButton will also set ROTATION_0 again.
                         () -> mRotationObserver.count == 2).setRetryIntervalMs(500));
             }
-            // Wait for settling rotation.
-            mAmWmState.waitForRotation(value);
 
-            if (waitSystemUI) {
+            if (waitDeviceRotation) {
+                // Wait for the display to apply the rotation.
+                mAmWmState.waitForRotation(value);
+            } else {
+                // Wait for the settings have been changed.
+                Condition.waitFor(new Condition<>("rotation setting changed",
+                        () -> mRotationObserver.count > 0).setRetryIntervalMs(100));
+            }
+
+            if (observeRotationSettings) {
                 mRotationObserver.stopObserver();
             }
         }
@@ -2006,6 +2028,7 @@
             }
 
             if (mLaunchInjector != null) {
+                commandBuilder.append(" --ez " + KEY_FORWARD + " true");
                 mLaunchInjector.setupShellCommand(commandBuilder);
             }
             executeShellCommand(commandBuilder.toString());
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/CommandSession.java b/tests/framework/base/windowmanager/util/src/android/server/wm/CommandSession.java
index 6675c68..173c08c 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/CommandSession.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/CommandSession.java
@@ -76,12 +76,12 @@
 
     private static final String EXTRA_PREFIX = "s_";
 
+    static final String KEY_FORWARD = EXTRA_PREFIX + "key_forward";
+
     private static final String KEY_CALLBACK_HISTORY = EXTRA_PREFIX + "key_callback_history";
     private static final String KEY_CLIENT_ID = EXTRA_PREFIX + "key_client_id";
     private static final String KEY_COMMAND = EXTRA_PREFIX + "key_command";
     private static final String KEY_CONFIG_INFO = EXTRA_PREFIX + "key_config_info";
-    // TODO(b/112837428): Used for LaunchActivityBuilder#launchUsingShellCommand
-    private static final String KEY_FORWARD = EXTRA_PREFIX + "key_forward";
     private static final String KEY_HOST_ID = EXTRA_PREFIX + "key_host_id";
     private static final String KEY_ORIENTATION = EXTRA_PREFIX + "key_orientation";
     private static final String KEY_REQUEST_TOKEN = EXTRA_PREFIX + "key_request_id";
@@ -122,7 +122,7 @@
         final Bundle sessionInfo = new Bundle(data);
         sessionInfo.remove(KEY_FORWARD);
         for (String key : sessionInfo.keySet()) {
-            if (!key.startsWith(EXTRA_PREFIX)) {
+            if (key != null && !key.startsWith(EXTRA_PREFIX)) {
                 sessionInfo.remove(key);
             }
         }
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 f80ffee..bfaeb7a 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
@@ -18,6 +18,9 @@
 
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
 import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
 import static android.server.wm.ProtoExtractors.extract;
 import static android.server.wm.StateLogger.log;
@@ -685,6 +688,18 @@
             mMergedOverrideConfiguration.setTo(extract(proto.mergedOverrideConfiguration));
         }
 
+        boolean isWindowingModeCompatible(int requestedWindowingMode) {
+            if (requestedWindowingMode == WINDOWING_MODE_UNDEFINED) {
+                return true;
+            }
+            final int windowingMode = getWindowingMode();
+            if (requestedWindowingMode == WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY) {
+                return windowingMode == WINDOWING_MODE_FULLSCREEN
+                        || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
+            }
+            return windowingMode == requestedWindowingMode;
+        }
+
         int getWindowingMode() {
             if (mFullConfiguration == null) {
                 return WINDOWING_MODE_UNDEFINED;
diff --git a/tests/libcore/jsr166/AndroidTest.xml b/tests/libcore/jsr166/AndroidTest.xml
index ed88b00a..f2aaee5 100644
--- a/tests/libcore/jsr166/AndroidTest.xml
+++ b/tests/libcore/jsr166/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/java.io.tmpdir" />
diff --git a/tests/libcore/luni/AndroidTest.xml b/tests/libcore/luni/AndroidTest.xml
index 7fef84d..b30e290 100644
--- a/tests/libcore/luni/AndroidTest.xml
+++ b/tests/libcore/luni/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/java.io.tmpdir" />
diff --git a/tests/libcore/ojluni/AndroidTest.xml b/tests/libcore/ojluni/AndroidTest.xml
index 7a1b306..f4d043a 100644
--- a/tests/libcore/ojluni/AndroidTest.xml
+++ b/tests/libcore/ojluni/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/java.io.tmpdir" />
diff --git a/tests/libcore/okhttp/AndroidTest.xml b/tests/libcore/okhttp/AndroidTest.xml
index 45a63b5..771293e 100644
--- a/tests/libcore/okhttp/AndroidTest.xml
+++ b/tests/libcore/okhttp/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="mkdir -p /data/local/tmp/ctslibcore/java.io.tmpdir" />
diff --git a/tests/libcore/wycheproof-bc/AndroidTest.xml b/tests/libcore/wycheproof-bc/AndroidTest.xml
index 4b6aaf6..c962faa 100644
--- a/tests/libcore/wycheproof-bc/AndroidTest.xml
+++ b/tests/libcore/wycheproof-bc/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/libcore/wycheproof/AndroidTest.xml b/tests/libcore/wycheproof/AndroidTest.xml
index f3c2908..27f1f4c 100644
--- a/tests/libcore/wycheproof/AndroidTest.xml
+++ b/tests/libcore/wycheproof/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/location/location_none/Android.bp b/tests/location/location_none/Android.bp
new file mode 100644
index 0000000..a57d31d
--- /dev/null
+++ b/tests/location/location_none/Android.bp
@@ -0,0 +1,38 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+    name: "CtsLocationNoneTestCases",
+    defaults: ["cts_defaults"],
+    static_libs: [
+        "LocationCtsCommon",
+        "androidx.test.ext.junit",
+        "androidx.test.ext.truth",
+        "androidx.test.rules",
+        "compatibility-device-util-axt",
+        "ctstestrunner-axt",
+        "truth-prebuilt",
+    ],
+    libs: [
+        "android.test.runner.stubs",
+        "android.test.base.stubs",
+    ],
+    srcs: ["src/**/*.java"],
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    sdk_version: "test_current",
+}
diff --git a/tests/location/location_none/AndroidManifest.xml b/tests/location/location_none/AndroidManifest.xml
new file mode 100644
index 0000000..db2aaa4
--- /dev/null
+++ b/tests/location/location_none/AndroidManifest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.location.cts.none">
+
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+                     android:label="CTS tests for android.location"
+                     android:targetPackage="android.location.cts" >
+        <meta-data android:name="listener"
+                   android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+</manifest>
+
diff --git a/tests/location/location_none/AndroidTest.xml b/tests/location/location_none/AndroidTest.xml
new file mode 100644
index 0000000..1bd875d
--- /dev/null
+++ b/tests/location/location_none/AndroidTest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Config for CTS Location test cases">
+    <option name="test-suite-tag" value="cts" />
+    <option name="config-descriptor:metadata" key="component" value="location" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.LocationCheck" />
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsLocationNoneTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.location.cts.none" />
+        <option name="runtime-hint" value="10m30s" />
+    </test>
+
+</configuration>
diff --git a/tests/location/location_none/src/android/location/cts/none/NoLocationPermissionTest.java b/tests/location/location_none/src/android/location/cts/none/NoLocationPermissionTest.java
new file mode 100644
index 0000000..b72f3d4
--- /dev/null
+++ b/tests/location/location_none/src/android/location/cts/none/NoLocationPermissionTest.java
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.location.cts.none;
+
+import static android.content.pm.PackageManager.FEATURE_TELEPHONY;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.location.Criteria;
+import android.location.LocationManager;
+import android.location.cts.common.LocationListenerCapture;
+import android.location.cts.common.LocationPendingIntentCapture;
+import android.os.Looper;
+import android.telephony.CellInfo;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+
+@RunWith(AndroidJUnit4.class)
+public class NoLocationPermissionTest {
+
+    private Context mContext;
+    private LocationManager mLocationManager;
+
+    @Before
+    protected void setUp() throws Exception {
+        mContext = ApplicationProvider.getApplicationContext();
+        mLocationManager = mContext.getSystemService(LocationManager.class);
+
+        assertNotNull(mLocationManager);
+    }
+
+    @SuppressWarnings("deprecation")
+    @Test
+    public void testGetCellLocation() {
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_TELEPHONY)) {
+            return;
+        }
+
+        TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+        assertNotNull(telephonyManager);
+
+        try {
+            telephonyManager.getCellLocation();
+            fail("Should throw SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testGetAllCellInfo() {
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_TELEPHONY)) {
+            return;
+        }
+
+        TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+        assertNotNull(telephonyManager);
+
+        try {
+            telephonyManager.getAllCellInfo();
+            fail("Should throw SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testListenCellLocation() {
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_TELEPHONY)) {
+            return;
+        }
+
+        TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+        assertNotNull(telephonyManager);
+
+        try {
+            telephonyManager.listen(new PhoneStateListener(),
+                    PhoneStateListener.LISTEN_CELL_LOCATION);
+            fail("Should throw SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testRequestCellInfoUpdate() {
+        if (!mContext.getPackageManager().hasSystemFeature(FEATURE_TELEPHONY)) {
+            return;
+        }
+
+        TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+        assertNotNull(telephonyManager);
+
+        try {
+            telephonyManager.requestCellInfoUpdate(Runnable::run,
+                    new TelephonyManager.CellInfoCallback() {
+                        @Override
+                        public void onCellInfo(List<CellInfo> cellInfos) {
+                        }
+                    });
+            fail("Should throw SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testRequestLocationUpdates() {
+        for (String provider : mLocationManager.getAllProviders()) {
+            try (LocationListenerCapture capture = new LocationListenerCapture(mContext)) {
+                mLocationManager.requestLocationUpdates(provider, 0, 0, capture,
+                        Looper.getMainLooper());
+                fail("Should throw SecurityException for provider " + provider);
+            } catch (SecurityException e) {
+                // expected
+            }
+
+            try (LocationListenerCapture capture = new LocationListenerCapture(mContext)) {
+                mLocationManager.requestLocationUpdates(provider, 0, 0, Runnable::run, capture);
+                fail("Should throw SecurityException for provider " + provider);
+            } catch (SecurityException e) {
+                // expected
+            }
+
+            try (LocationPendingIntentCapture capture = new LocationPendingIntentCapture(
+                    mContext)) {
+                mLocationManager.requestLocationUpdates(provider, 0, 0, capture.getPendingIntent());
+                fail("Should throw SecurityException for provider " + provider);
+            } catch (SecurityException e) {
+                // expected
+            }
+        }
+    }
+
+    @Test
+    public void testAddProximityAlert() {
+        PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
+                0, new Intent("action"), PendingIntent.FLAG_ONE_SHOT);
+        try {
+            mLocationManager.addProximityAlert(0, 0, 100, -1, pendingIntent);
+            fail("Should throw SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        } finally {
+            pendingIntent.cancel();
+        }
+    }
+
+    @Test
+    public void testGetLastKnownLocation() {
+        for (String provider : mLocationManager.getAllProviders()) {
+            try {
+                mLocationManager.getLastKnownLocation(provider);
+                fail("Should throw SecurityException for provider " + provider);
+            } catch (SecurityException e) {
+                // expected
+            }
+        }
+    }
+
+    @Test
+    public void testGetProvider() {
+        for (String provider : mLocationManager.getAllProviders()) {
+            mLocationManager.getProvider(provider);
+        }
+    }
+
+    @Test
+    public void testIsProviderEnabled() {
+        for (String provider : mLocationManager.getAllProviders()) {
+            mLocationManager.isProviderEnabled(provider);
+        }
+    }
+
+    @Test
+    public void testAddTestProvider() {
+        for (String provider : mLocationManager.getAllProviders()) {
+            try {
+                mLocationManager.addTestProvider(
+                        provider,
+                        true,
+                        true,
+                        true,
+                        true,
+                        true,
+                        true,
+                        true,
+                        Criteria.POWER_LOW,
+                        Criteria.ACCURACY_FINE);
+                fail("Should throw SecurityException for provider " + provider);
+            } catch (SecurityException e) {
+                // expected
+            }
+        }
+    }
+
+    @Test
+    public void testRemoveTestProvider() {
+        for (String provider : mLocationManager.getAllProviders()) {
+            try {
+                mLocationManager.removeTestProvider(provider);
+                fail("Should throw SecurityException for provider " + provider);
+            } catch (SecurityException e) {
+                // expected
+            }
+        }
+    }
+}
diff --git a/tests/mocking/extended/AndroidTest.xml b/tests/mocking/extended/AndroidTest.xml
index dad860d..aa44391 100644
--- a/tests/mocking/extended/AndroidTest.xml
+++ b/tests/mocking/extended/AndroidTest.xml
@@ -19,6 +19,7 @@
     <option name="config-descriptor:metadata" key="component" value="mocking" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
 
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidTest.xml b/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidTest.xml
index 68c3e5c..c0fadbd 100644
--- a/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="systems" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsHiddenApiKillswitchDebugClassTestCases.apk" />
diff --git a/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidTest.xml b/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidTest.xml
index e25bb65..9579126 100644
--- a/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="systems" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <!-- Whitelist all APIs before running the test, then reset this afterwards. The test
              is intended to verify the behaviour when all APIs are whitelisted. -->
diff --git a/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidTest.xml b/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidTest.xml
index 0363684..27b874c 100644
--- a/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="systems" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <!-- Enable the killswitch before running the test, then disable it afterwards. The test
              is intended to verify the behaviour when the killswitch is enabled. -->
diff --git a/tests/tests/accounts/AndroidTest.xml b/tests/tests/accounts/AndroidTest.xml
index e473a1a..0f118d8 100644
--- a/tests/tests/accounts/AndroidTest.xml
+++ b/tests/tests/accounts/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="framework" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="cmd account set-bind-instant-service-allowed true" />
         <option name="teardown-command" value="cmd account set-bind-instant-service-allowed false" />
diff --git a/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java b/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
index 77c1c5c..7e22b6a 100644
--- a/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
+++ b/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
@@ -118,7 +118,7 @@
                                 + "package_query_filtering_enabled")
                         .trim();
         if ("null".equalsIgnoreCase(deviceConfigResponse) || deviceConfigResponse.isEmpty()) {
-            sGlobalFeatureEnabled = true;
+            sGlobalFeatureEnabled = false;
         } else {
             sGlobalFeatureEnabled = Boolean.parseBoolean(deviceConfigResponse);
         }
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 de2729c..ff002dc 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
@@ -25,6 +25,7 @@
 import android.app.SyncNotedAppOp
 import android.app.appops.cts.IAppOpsUserClient
 import android.app.appops.cts.IAppOpsUserService
+import android.app.appops.cts.TEST_FEATURE_ID
 import android.app.appops.cts.eventually
 import android.content.Intent
 import android.os.IBinder
@@ -129,7 +130,8 @@
                 forwardThrowableFrom {
                     client.noteSyncOp()
 
-                    assertThat(noted.map { it.first.op }).containsExactly(OPSTR_COARSE_LOCATION)
+                    assertThat(noted.map { it.first.featureId to it.first.op })
+                        .containsExactly(null to OPSTR_COARSE_LOCATION)
                     assertThat(noted[0].second.map { it.methodName })
                         .contains("callApiThatNotesSyncOpAndCheckLog")
                     assertThat(selfNoted).isEmpty()
@@ -151,6 +153,14 @@
                 }
             }
 
+            override fun callApiThatNotesSyncOpWithFeatureAndCheckLog(client: IAppOpsUserClient) {
+                forwardThrowableFrom {
+                    client.noteSyncOpWithFeature(TEST_FEATURE_ID)
+
+                    assertThat(noted.map { it.first.featureId }).containsExactly(TEST_FEATURE_ID)
+                }
+            }
+
             override fun callApiThatCallsBackIntoServiceAndCheckLog(client: IAppOpsUserClient) {
                 forwardThrowableFrom {
                     // This calls back into the service via callApiThatNotesSyncOpAndClearLog
@@ -326,13 +336,27 @@
                     client.noteAsyncOp()
 
                     eventually {
-                        assertThat(asyncNoted.map { it.op }).containsExactly(OPSTR_COARSE_LOCATION)
+                        assertThat(asyncNoted.map { it.featureId to it.op })
+                            .containsExactly(null to OPSTR_COARSE_LOCATION)
                     }
                     assertThat(noted).isEmpty()
                     assertThat(selfNoted).isEmpty()
                 }
             }
 
+            override fun callApiThatNotesAsyncOpWithFeatureAndCheckLog(
+                client: IAppOpsUserClient
+            ) {
+                forwardThrowableFrom {
+                    client.noteAsyncOpWithFeature(TEST_FEATURE_ID)
+
+                    eventually {
+                        assertThat(asyncNoted.map { it.featureId })
+                            .containsExactly(TEST_FEATURE_ID)
+                    }
+                }
+            }
+
             override fun callApiThatNotesAsyncOpAndCheckDefaultMessage(client: IAppOpsUserClient) {
                 forwardThrowableFrom {
                     client.noteAsyncOp()
@@ -387,4 +411,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserClient.aidl b/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserClient.aidl
index 76641ea..f3af855 100644
--- a/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserClient.aidl
+++ b/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserClient.aidl
@@ -18,6 +18,7 @@
 
 interface IAppOpsUserClient {
     void noteSyncOp();
+    void noteSyncOpWithFeature(String featureId);
     void callBackIntoService();
     void noteNonPermissionSyncOp();
     void noteSyncOpTwice();
@@ -29,6 +30,7 @@
     void noteSyncOpOtherUid();
     void noteSyncOpOtherUidNative();
     void noteAsyncOp();
+    void noteAsyncOpWithFeature(String featureId);
     void noteAsyncOpWithCustomMessage();
     void noteAsyncOpNative();
     void noteAsyncOpNativeWithCustomMessage();
diff --git a/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserService.aidl b/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserService.aidl
index cddc91e..a19705f 100644
--- a/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserService.aidl
+++ b/tests/tests/appop/aidl/src/android/app/appops/cts/IAppOpsUserService.aidl
@@ -23,6 +23,7 @@
     void disableCollectorAndCallASyncOpsWhichWillBeCollected(in IAppOpsUserClient client);
     void callApiThatNotesSyncOpAndCheckLog(in IAppOpsUserClient client);
     void callApiThatNotesSyncOpAndClearLog(in IAppOpsUserClient client);
+    void callApiThatNotesSyncOpWithFeatureAndCheckLog(in IAppOpsUserClient client);
     void callApiThatCallsBackIntoServiceAndCheckLog(in IAppOpsUserClient client);
     void callApiThatNotesSyncOpFromNativeCodeAndCheckLog(in IAppOpsUserClient client);
     void callApiThatNotesSyncOpFromNativeCodeAndCheckMessage(in IAppOpsUserClient client);
@@ -37,6 +38,7 @@
     void callApiThatNotesSyncOpOtherUidAndCheckLog(in IAppOpsUserClient client);
     void callApiThatNotesSyncOpOtherUidNativelyAndCheckLog(in IAppOpsUserClient client);
     void callApiThatNotesAsyncOpAndCheckLog(in IAppOpsUserClient client);
+    void callApiThatNotesAsyncOpWithFeatureAndCheckLog(in IAppOpsUserClient client);
     void callApiThatNotesAsyncOpAndCheckDefaultMessage(in IAppOpsUserClient client);
     void callApiThatNotesAsyncOpAndCheckCustomMessage(in IAppOpsUserClient client);
     void callApiThatNotesAsyncOpNativelyAndCheckCustomMessage(in IAppOpsUserClient client);
diff --git a/tests/tests/appop/appopsTestUtilLib/src/android/app/appops/cts/AppOpsUtils.kt b/tests/tests/appop/appopsTestUtilLib/src/android/app/appops/cts/AppOpsUtils.kt
index a62cc00..1996823 100644
--- a/tests/tests/appop/appopsTestUtilLib/src/android/app/appops/cts/AppOpsUtils.kt
+++ b/tests/tests/appop/appopsTestUtilLib/src/android/app/appops/cts/AppOpsUtils.kt
@@ -27,6 +27,8 @@
 private const val LOG_TAG = "AppOpsUtils"
 private const val TIMEOUT_MILLIS = 10000L
 
+const val TEST_FEATURE_ID = "testFeature"
+
 /**
  * Resets a package's app ops configuration to the device default. See AppOpsManager for the
  * default op settings.
diff --git a/tests/tests/appop/jni/android/app/appops/cts/AppOpsLoggingTest.cpp b/tests/tests/appop/jni/android/app/appops/cts/AppOpsLoggingTest.cpp
index 83c2fd5..38826f2 100644
--- a/tests/tests/appop/jni/android/app/appops/cts/AppOpsLoggingTest.cpp
+++ b/tests/tests/appop/jni/android/app/appops/cts/AppOpsLoggingTest.cpp
@@ -26,30 +26,44 @@
 #endif
 #define LOG_TAG "AppOpsLoggingTest"
 
-// Note op from native code without supplying a message
-extern "C" JNIEXPORT void JNICALL
-Java_android_app_appops_cts_AppOpsLoggingTestKt_nativeNoteOp(JNIEnv* env, jobject obj,
-        jint op, jint uid, jstring callingPackageName) {
-    AppOpsManager appOpsManager;
-
-    const char *nativeCallingPackageName = env->GetStringUTFChars(callingPackageName, 0);
-
-    appOpsManager.noteOp(op, uid, String16(nativeCallingPackageName));
-
-    env->ReleaseStringUTFChars(callingPackageName, nativeCallingPackageName);
-}
-
 // Note op from native code
 extern "C" JNIEXPORT void JNICALL
-Java_android_app_appops_cts_AppOpsLoggingTestKt_nativeNoteOpWithMessage(JNIEnv* env, jobject obj,
-        jint op, jint uid, jstring callingPackageName, jstring message) {
+Java_android_app_appops_cts_AppOpsLoggingTestKt_nativeNoteOp(JNIEnv* env, jobject obj,
+        jint op, jint uid, jstring jCallingPackageName, jstring jFeatureId, jstring jMessage) {
     AppOpsManager appOpsManager;
 
-    const char *nativeCallingPackageName = env->GetStringUTFChars(callingPackageName, 0);
-    const char *nativeMessage = env->GetStringUTFChars(message, 0);
+    const char *nativeCallingPackageName = env->GetStringUTFChars(jCallingPackageName, 0);
+    String16 callingPackageName(nativeCallingPackageName);
 
-    appOpsManager.noteOp(op, uid, String16(nativeCallingPackageName), String16(nativeMessage));
+    const char *nativeFeatureId;
+    String16 *featureId;
+    if (jFeatureId != nullptr) {
+        nativeFeatureId = env->GetStringUTFChars(jFeatureId, 0);
+        featureId = new String16(nativeFeatureId);
+    } else {
+        featureId = new String16();
+    }
 
-    env->ReleaseStringUTFChars(callingPackageName, nativeCallingPackageName);
-    env->ReleaseStringUTFChars(message, nativeMessage);
+    const char *nativeMessage;
+    String16 *message;
+    if (jMessage != nullptr) {
+        nativeMessage = env->GetStringUTFChars(jMessage, 0);
+        message = new String16(nativeMessage);
+    } else {
+        message = new String16();
+    }
+
+    appOpsManager.noteOp(op, uid, callingPackageName, *featureId, *message);
+
+    env->ReleaseStringUTFChars(jCallingPackageName, nativeCallingPackageName);
+
+    if (jFeatureId != nullptr) {
+        env->ReleaseStringUTFChars(jFeatureId, nativeFeatureId);
+    }
+    delete featureId;
+
+    if (jMessage != nullptr) {
+        env->ReleaseStringUTFChars(jMessage, nativeMessage);
+    }
+    delete message;
 }
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 09eb36d..d319849 100644
--- a/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
+++ b/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
@@ -56,12 +56,12 @@
 private const val TEST_SERVICE_PKG = "android.app.appops.cts.appthatusesappops"
 private const val TIMEOUT_MILLIS = 10000L
 
-private external fun nativeNoteOp(op: Int, uid: Int, packageName: String)
-private external fun nativeNoteOpWithMessage(
+private external fun nativeNoteOp(
     op: Int,
     uid: Int,
     packageName: String,
-    message: String
+    featureId: String? = null,
+    message: String? = null
 )
 
 @AppModeFull(reason = "Test relies on other app to connect to. Instant apps can't see other apps")
@@ -150,12 +150,20 @@
 
     @Test
     fun selfNoteAndCheckLog() {
-        appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage)
+        appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage, null, null)
 
         assertThat(noted).isEmpty()
         assertThat(asyncNoted).isEmpty()
 
-        assertThat(selfNoted.map { it.first.op }).containsExactly(OPSTR_COARSE_LOCATION)
+        assertThat(selfNoted.map { it.first.featureId to it.first.op })
+            .containsExactly(null to OPSTR_COARSE_LOCATION)
+    }
+
+    @Test
+    fun selfNoteAndCheckFeature() {
+        appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage, TEST_FEATURE_ID, null)
+
+        assertThat(selfNoted.map { it.first.featureId }).containsExactly(TEST_FEATURE_ID)
     }
 
     @Test
@@ -167,7 +175,19 @@
 
         // All native notes will be reported as async notes
         eventually {
-            assertThat(asyncNoted.map { it.op }).containsExactly(OPSTR_COARSE_LOCATION)
+            assertThat(asyncNoted.map { it.featureId to it.op })
+                .containsExactly(null to OPSTR_COARSE_LOCATION)
+        }
+    }
+
+    @Test
+    fun nativeSelfNoteAndCheckFeature() {
+        nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), myUid, myPackage,
+            featureId = TEST_FEATURE_ID)
+
+        // All native notes will be reported as async notes
+        eventually {
+            assertThat(asyncNoted.map { it.featureId }).containsExactly(TEST_FEATURE_ID)
         }
     }
 
@@ -175,7 +195,8 @@
     fun selfNotesAreDeliveredAsAsyncOpsWhenCollectorIsRegistered() {
         appOpsManager.setNotedAppOpsCollector(null)
 
-        appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage)
+        appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage, TEST_FEATURE_ID, null)
+        appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage, null, "test msg")
 
         assertThat(noted).isEmpty()
         assertThat(selfNoted).isEmpty()
@@ -185,7 +206,9 @@
 
         assertThat(noted).isEmpty()
         assertThat(selfNoted).isEmpty()
-        assertThat(asyncNoted.map { it.op }).containsExactly(OPSTR_COARSE_LOCATION)
+        assertThat(asyncNoted.map { it.featureId to it.op }).containsExactly(
+            null to OPSTR_COARSE_LOCATION, TEST_FEATURE_ID to OPSTR_COARSE_LOCATION)
+        assertThat(asyncNoted.map { it.message }).contains("test msg")
     }
 
     @Test
@@ -212,6 +235,13 @@
     }
 
     @Test
+    fun noteSyncWithFeatureOpAndCheckLog() {
+        rethrowThrowableFrom {
+            testService.callApiThatNotesSyncOpWithFeatureAndCheckLog(AppOpsUserClient(context))
+        }
+    }
+
+    @Test
     fun callsBackIntoServiceAndCheckLog() {
         rethrowThrowableFrom {
             testService.callApiThatCallsBackIntoServiceAndCheckLog(
@@ -314,6 +344,13 @@
     }
 
     @Test
+    fun noteAsyncOpWithFeatureAndCheckLog() {
+        rethrowThrowableFrom {
+            testService.callApiThatNotesAsyncOpWithFeatureAndCheckLog(AppOpsUserClient(context))
+        }
+    }
+
+    @Test
     fun noteAsyncOpAndCheckDefaultMessage() {
         rethrowThrowableFrom {
             testService.callApiThatNotesAsyncOpAndCheckDefaultMessage(AppOpsUserClient(context))
@@ -469,14 +506,21 @@
         override fun noteSyncOp() {
             runWithShellPermissionIdentity {
                 appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, getCallingUid(),
-                        TEST_SERVICE_PKG)
+                        TEST_SERVICE_PKG, null, null)
+            }
+        }
+
+        override fun noteSyncOpWithFeature(featureId: String) {
+            runWithShellPermissionIdentity {
+                appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, getCallingUid(),
+                    TEST_SERVICE_PKG, featureId, null)
             }
         }
 
         override fun callBackIntoService() {
             runWithShellPermissionIdentity {
                 appOpsManager.noteOpNoThrow(OPSTR_FINE_LOCATION, getCallingUid(),
-                    TEST_SERVICE_PKG)
+                    TEST_SERVICE_PKG, null, null)
             }
 
             testService?.callApiThatNotesSyncOpAndClearLog(this)
@@ -485,7 +529,7 @@
         override fun noteNonPermissionSyncOp() {
             runWithShellPermissionIdentity {
                 appOpsManager.noteOpNoThrow(OPSTR_ACCESS_ACCESSIBILITY, getCallingUid(),
-                        TEST_SERVICE_PKG)
+                        TEST_SERVICE_PKG, null, null)
             }
         }
 
@@ -497,9 +541,10 @@
         override fun noteTwoSyncOp() {
             runWithShellPermissionIdentity {
                 appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, getCallingUid(),
-                        TEST_SERVICE_PKG)
+                        TEST_SERVICE_PKG, null, null)
 
-                appOpsManager.noteOpNoThrow(OPSTR_GET_ACCOUNTS, getCallingUid(), TEST_SERVICE_PKG)
+                appOpsManager.noteOpNoThrow(OPSTR_GET_ACCOUNTS, getCallingUid(), TEST_SERVICE_PKG,
+                    null, null)
             }
         }
 
@@ -519,7 +564,7 @@
         override fun noteSyncOpOneway() {
             runWithShellPermissionIdentity {
                 appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, getCallingUid(),
-                        TEST_SERVICE_PKG)
+                        TEST_SERVICE_PKG, null, null)
             }
         }
 
@@ -530,7 +575,7 @@
         }
 
         override fun noteSyncOpOtherUid() {
-            appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage)
+            appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, myUid, myPackage, null, null)
         }
 
         override fun noteSyncOpOtherUidNative() {
@@ -542,7 +587,19 @@
 
             handler.post {
                 runWithShellPermissionIdentity {
-                    appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, callingUid, TEST_SERVICE_PKG)
+                    appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, callingUid, TEST_SERVICE_PKG,
+                        null, null)
+                }
+            }
+        }
+
+        override fun noteAsyncOpWithFeature(featureId: String) {
+            val callingUid = getCallingUid()
+
+            handler.post {
+                runWithShellPermissionIdentity {
+                    appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, callingUid, TEST_SERVICE_PKG,
+                        featureId, null)
                 }
             }
         }
@@ -553,7 +610,7 @@
             handler.post {
                 runWithShellPermissionIdentity {
                     appOpsManager.noteOpNoThrow(OPSTR_COARSE_LOCATION, callingUid, TEST_SERVICE_PKG,
-                            "custom msg")
+                            null, "custom msg")
                 }
             }
         }
@@ -573,8 +630,8 @@
 
             handler.post {
                 runWithShellPermissionIdentity {
-                    nativeNoteOpWithMessage(strOpToOp(OPSTR_COARSE_LOCATION), callingUid,
-                            TEST_SERVICE_PKG, "native custom msg")
+                    nativeNoteOp(strOpToOp(OPSTR_COARSE_LOCATION), callingUid, TEST_SERVICE_PKG,
+                        message = "native custom msg")
                 }
             }
         }
diff --git a/tests/tests/appop/src/android/app/appops/cts/AppOpsTest.kt b/tests/tests/appop/src/android/app/appops/cts/AppOpsTest.kt
index ea600d0..a9c7aa8 100644
--- a/tests/tests/appop/src/android/app/appops/cts/AppOpsTest.kt
+++ b/tests/tests/appop/src/android/app/appops/cts/AppOpsTest.kt
@@ -51,15 +51,19 @@
 
 import java.util.HashMap
 import java.util.HashSet
+import java.util.concurrent.CompletableFuture
+import java.util.concurrent.Executor
+import java.util.concurrent.TimeUnit
 
 @RunWith(AndroidJUnit4::class)
 class AppOpsTest {
     // Notifying OnOpChangedListener callbacks is an async operation, so we define a timeout.
-    private val MODE_WATCHER_TIMEOUT_MS = 5000L
+    private val TIMEOUT_MS = 5000L
 
     private lateinit var mAppOps: AppOpsManager
     private lateinit var mContext: Context
     private lateinit var mOpPackageName: String
+    private val mMyUid = Process.myUid()
 
     companion object {
         // These permissions and opStrs must map to the same op codes.
@@ -218,6 +222,56 @@
     }
 
     @Test
+    fun overlappingActiveFeatureOps() {
+        runWithShellPermissionIdentity {
+            val gotActive = CompletableFuture<Unit>()
+            val gotInActive = CompletableFuture<Unit>()
+
+            val activeWatcher =
+                AppOpsManager.OnOpActiveChangedListener { _, _, packageName, active ->
+                    if (packageName == mOpPackageName) {
+                        if (active) {
+                            assertFalse(gotActive.isDone)
+                            gotActive.complete(Unit)
+                        } else {
+                            assertFalse(gotInActive.isDone)
+                            gotInActive.complete(Unit)
+                        }
+                    }
+                }
+
+            mAppOps.startWatchingActive(arrayOf(OPSTR_WRITE_CALENDAR), Executor { it.run() },
+                activeWatcher)
+            try {
+                mAppOps.startOp(OPSTR_WRITE_CALENDAR, mMyUid, mOpPackageName, "feature1", null)
+                assertTrue(mAppOps.isOpActive(OPSTR_WRITE_CALENDAR, mMyUid, mOpPackageName))
+                gotActive.get(TIMEOUT_MS, TimeUnit.MILLISECONDS)
+
+                mAppOps.startOp(OPSTR_WRITE_CALENDAR, Process.myUid(), mOpPackageName,
+                    "feature2", null)
+                assertTrue(mAppOps.isOpActive(OPSTR_WRITE_CALENDAR, mMyUid, mOpPackageName))
+                assertFalse(gotInActive.isDone)
+
+                mAppOps.finishOp(OPSTR_WRITE_CALENDAR, Process.myUid(), mOpPackageName,
+                    "feature1")
+
+                // Allow some time for premature "watchingActive" callbacks to arrive
+                Thread.sleep(500)
+
+                assertTrue(mAppOps.isOpActive(OPSTR_WRITE_CALENDAR, mMyUid, mOpPackageName))
+                assertFalse(gotInActive.isDone)
+
+                mAppOps.finishOp(OPSTR_WRITE_CALENDAR, Process.myUid(), mOpPackageName,
+                    "feature2")
+                assertFalse(mAppOps.isOpActive(OPSTR_WRITE_CALENDAR, mMyUid, mOpPackageName))
+                gotInActive.get(TIMEOUT_MS, TimeUnit.MILLISECONDS)
+            } finally {
+                mAppOps.stopWatchingActive(activeWatcher)
+            }
+        }
+    }
+
+    @Test
     fun testCheckPackagePassesCheck() {
         mAppOps.checkPackage(Process.myUid(), mOpPackageName)
         mAppOps.checkPackage(Process.SYSTEM_UID, "android")
@@ -258,13 +312,13 @@
             // Make a change to the app op's mode.
             Mockito.reset(watcher)
             setOpMode(mOpPackageName, OPSTR_WRITE_CALENDAR, MODE_ERRORED)
-            verify(watcher, timeout(MODE_WATCHER_TIMEOUT_MS))
+            verify(watcher, timeout(TIMEOUT_MS))
                     .onOpChanged(OPSTR_WRITE_CALENDAR, mOpPackageName)
 
             // Make another change to the app op's mode.
             Mockito.reset(watcher)
             setOpMode(mOpPackageName, OPSTR_WRITE_CALENDAR, MODE_ALLOWED)
-            verify(watcher, timeout(MODE_WATCHER_TIMEOUT_MS))
+            verify(watcher, timeout(TIMEOUT_MS))
                     .onOpChanged(OPSTR_WRITE_CALENDAR, mOpPackageName)
 
             // Set mode to the same value as before - expect no call to the listener.
diff --git a/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java b/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java
index b2a3bce..47db6d3 100644
--- a/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java
+++ b/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java
@@ -58,11 +58,13 @@
     private ITest mInterface;
     private String mExpectedName;
     private boolean mShouldBeRemote;
+    private boolean mShouldBeOld;
 
-    public JavaClientTest(Class serviceClass, String expectedName, boolean shouldBeRemote) {
+    public JavaClientTest(Class serviceClass, String expectedName, boolean shouldBeRemote, boolean shouldBeOld) {
         mServiceClass = serviceClass;
         mExpectedName = expectedName;
         mShouldBeRemote = shouldBeRemote;
+        mShouldBeOld = shouldBeOld;
     }
 
     @Parameterized.Parameters( name = "{0}" )
@@ -71,10 +73,11 @@
         // Whenever possible, the desired service should be accessed directly
         // in order to avoid this additional overhead.
         return Arrays.asList(new Object[][] {
-                {NativeService.Local.class, "CPP", false /*shouldBeRemote*/},
-                {JavaService.Local.class, "JAVA", false /*shouldBeRemote*/},
-                {NativeService.Remote.class, "CPP", true /*shouldBeRemote*/},
-                {JavaService.Remote.class, "JAVA", true /*shouldBeRemote*/},
+                {NativeService.Local.class, "CPP", false /*shouldBeRemote*/, false /*shouldBeOld*/},
+                {JavaService.Local.class, "JAVA", false /*shouldBeRemote*/, false /*shouldBeOld*/},
+                {NativeService.Remote.class, "CPP", true /*shouldBeRemote*/, false /*shouldBeOld*/},
+                {NativeService.RemoteOld.class, "CPP", true /*shouldBeRemote*/, true /*shouldBeOld*/},
+                {JavaService.Remote.class, "JAVA", true /*shouldBeRemote*/, false /*shouldBeOld*/},
             });
     }
 
@@ -531,6 +534,22 @@
     }
 
     @Test
+    public void testNewField() throws RemoteException {
+        Foo foo = new Foo();
+        foo.d = new Bar();
+        foo.e = new Bar();
+        foo.shouldContainTwoByteFoos = new byte[]{};
+        foo.shouldContainTwoIntFoos = new int[]{};
+        foo.shouldContainTwoLongFoos = new long[]{};
+        foo.g = new String[]{"a", "b", "c"};
+        Foo newFoo = mInterface.repeatFoo(foo);
+        if (mShouldBeOld) {
+            assertEquals(null, newFoo.g);
+        } else {
+            Assert.assertArrayEquals(foo.g, newFoo.g);
+        }
+    }
+    @Test
     public void testRenameFoo() throws RemoteException {
         Foo foo = new Foo();
         foo.d = new Bar();
diff --git a/tests/tests/calendarcommon/AndroidTest.xml b/tests/tests/calendarcommon/AndroidTest.xml
index 0785102..47799e2 100644
--- a/tests/tests/calendarcommon/AndroidTest.xml
+++ b/tests/tests/calendarcommon/AndroidTest.xml
@@ -20,6 +20,7 @@
     <!-- Instant apps can't access the calendar provider. -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
 
     <option name="not-shardable" value="true" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
diff --git a/tests/tests/calendarprovider/Android.bp b/tests/tests/calendarprovider/Android.bp
new file mode 100644
index 0000000..43ecb0d
--- /dev/null
+++ b/tests/tests/calendarprovider/Android.bp
@@ -0,0 +1,29 @@
+android_test {
+    name: "CtsCalendarProviderTestCases",
+    defaults: ["cts_defaults"],
+
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+
+    libs: [
+        "android.test.mock",
+        "android.test.base.stubs",
+        "android.test.runner.stubs",
+    ],
+
+    static_libs: [
+        "compatibility-device-util-axt",
+        "ctstestrunner-axt",
+        "junit",
+        "truth-prebuilt",
+        "mockito-target-minus-junit4",
+    ],
+
+    srcs: ["src/**/*.java"],
+
+    sdk_version: "test_current",
+    min_sdk_version: "29",
+}
diff --git a/tests/tests/calendarprovider/AndroidManifest.xml b/tests/tests/calendarprovider/AndroidManifest.xml
new file mode 100644
index 0000000..62562ff
--- /dev/null
+++ b/tests/tests/calendarprovider/AndroidManifest.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.provider.cts.calendar">
+
+    <uses-sdk android:targetSdkVersion="29" />
+
+    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
+    <uses-permission android:name="android.permission.READ_CALENDAR" />
+
+    <application>
+        <uses-library android:name="android.test.runner"/>
+    </application>
+
+    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.provider.cts.calendar">
+        <meta-data android:name="listener"
+            android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+</manifest>
+
diff --git a/tests/tests/calendarprovider/AndroidTest.xml b/tests/tests/calendarprovider/AndroidTest.xml
new file mode 100644
index 0000000..16d5ecf
--- /dev/null
+++ b/tests/tests/calendarprovider/AndroidTest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Config for CTS Provider test cases">
+    <option name="test-suite-tag" value="cts" />
+
+    <option name="config-descriptor:metadata" key="component" value="framework" />
+
+    <!-- Instant apps can't access the system providers. -->
+    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsCalendarProviderTestCases.apk" />
+    </target_preparer>
+
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
+        <option name="package" value="android.provider.cts.calendar" />
+        <option name="runtime-hint" value="2m00s" />
+    </test>
+</configuration>
diff --git a/tests/tests/calendarprovider/OWNERS b/tests/tests/calendarprovider/OWNERS
new file mode 100644
index 0000000..301c336
--- /dev/null
+++ b/tests/tests/calendarprovider/OWNERS
@@ -0,0 +1,3 @@
+# Bug component: 197771
+omakoto@google.com
+yamasani@google.com
diff --git a/tests/tests/provider/src/android/provider/cts/calendar/CalendarTest.java b/tests/tests/calendarprovider/src/android/provider/cts/calendar/CalendarTest.java
similarity index 98%
rename from tests/tests/provider/src/android/provider/cts/calendar/CalendarTest.java
rename to tests/tests/calendarprovider/src/android/provider/cts/calendar/CalendarTest.java
index c97d4d9..7a672c1 100644
--- a/tests/tests/provider/src/android/provider/cts/calendar/CalendarTest.java
+++ b/tests/tests/calendarprovider/src/android/provider/cts/calendar/CalendarTest.java
@@ -3280,7 +3280,7 @@
     @MediumTest
     public void testMutatorSetCorrectly() {
         String account = "ec_account";
-        String packageName = "android.provider.cts";
+        String packageName = "android.provider.cts.calendar";
         int seed = 0;
 
         // Clean up just in case
@@ -3763,36 +3763,4 @@
             }
         }
     }
-
-
-    /**
-     * Special version of the test runner that does some remote Emma coverage housekeeping.
-     */
-    // TODO: find if this is still used and if so convert to AndroidJUnitRunner framework
-    public static class CalendarEmmaTestRunner extends android.test.InstrumentationTestRunner {
-        private static final Uri EMMA_CONTENT_URI =
-            Uri.parse("content://" + CalendarContract.AUTHORITY + "/emma");
-        private ContentResolver mContentResolver;
-
-        @Override
-        public void onStart() {
-            mContentResolver = getTargetContext().getContentResolver();
-
-            ContentValues values = new ContentValues();
-            values.put("cmd", "start");
-            mContentResolver.insert(EMMA_CONTENT_URI, values);
-
-            super.onStart();
-        }
-
-        @Override
-        public void finish(int resultCode, Bundle results) {
-            ContentValues values = new ContentValues();
-            values.put("cmd", "stop");
-            values.put("outputFileName",
-                    Environment.getExternalStorageDirectory() + "/calendar-provider.ec");
-            mContentResolver.insert(EMMA_CONTENT_URI, values);
-            super.finish(resultCode, results);
-        }
-    }
 }
diff --git a/tests/tests/classloaderfactory/test-memcl/AndroidTest.xml b/tests/tests/classloaderfactory/test-memcl/AndroidTest.xml
index 4400ab5..a0a38a9 100644
--- a/tests/tests/classloaderfactory/test-memcl/AndroidTest.xml
+++ b/tests/tests/classloaderfactory/test-memcl/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="misc" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsClassLoaderFactoryInMemoryDexClassLoaderTestCases.apk" />
diff --git a/tests/tests/classloaderfactory/test-pathcl/AndroidTest.xml b/tests/tests/classloaderfactory/test-pathcl/AndroidTest.xml
index 50c79ef..95797ca 100644
--- a/tests/tests/classloaderfactory/test-pathcl/AndroidTest.xml
+++ b/tests/tests/classloaderfactory/test-pathcl/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="misc" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsClassLoaderFactoryPathClassLoaderTestCases.apk" />
diff --git a/tests/tests/contactsprovider/Android.bp b/tests/tests/contactsprovider/Android.bp
new file mode 100644
index 0000000..ed5cf51
--- /dev/null
+++ b/tests/tests/contactsprovider/Android.bp
@@ -0,0 +1,30 @@
+android_test {
+    name: "CtsContactsProviderTestCases",
+    defaults: ["cts_defaults"],
+
+    compile_multilib: "both",
+
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+
+    libs: [
+        "android.test.mock",
+        "android.test.base.stubs",
+        "android.test.runner.stubs",
+    ],
+
+    static_libs: [
+        "compatibility-device-util-axt",
+        "ctstestrunner-axt",
+        "junit",
+        "truth-prebuilt",
+    ],
+
+    srcs: ["src/**/*.java"],
+
+    sdk_version: "test_current",
+    min_sdk_version: "21",
+}
diff --git a/tests/tests/contactsprovider/AndroidManifest.xml b/tests/tests/contactsprovider/AndroidManifest.xml
new file mode 100644
index 0000000..f81bb5e
--- /dev/null
+++ b/tests/tests/contactsprovider/AndroidManifest.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.provider.cts.contacts">
+
+    <uses-sdk android:targetSdkVersion="29" />
+
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+
+    <!-- We need the calllog permissions for ContactsTest, which is the test for legacy provider. -->
+    <uses-permission android:name="android.permission.READ_CALL_LOG" />
+    <uses-permission android:name="android.permission.WRITE_CALL_LOG" />
+    <application>
+        <uses-library android:name="android.test.runner"/>
+
+        <service android:name=".account.MockAccountService"
+                 android:exported="true">
+            <intent-filter>
+                <action android:name="android.accounts.AccountAuthenticator"/>
+            </intent-filter>
+
+            <meta-data android:name="android.accounts.AccountAuthenticator"
+                       android:resource="@xml/contactprovider_authenticator"/>
+        </service>
+
+        <provider
+            android:name=".DummyGalProvider"
+            android:authorities="android.provider.cts.contacts.dgp"
+            android:exported="true"
+            android:readPermission="android.permission.BIND_DIRECTORY_SEARCH" >
+            <meta-data android:name="android.content.ContactDirectory" android:value="true" />
+        </provider>
+    </application>
+
+    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="android.provider.cts.contacts">
+        <meta-data android:name="listener"
+            android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+
+</manifest>
+
diff --git a/tests/tests/contactsprovider/AndroidTest.xml b/tests/tests/contactsprovider/AndroidTest.xml
new file mode 100644
index 0000000..2e9fee7
--- /dev/null
+++ b/tests/tests/contactsprovider/AndroidTest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Config for CTS Provider test cases">
+    <option name="test-suite-tag" value="cts" />
+
+    <option name="config-descriptor:metadata" key="component" value="framework" />
+    <!-- Instant apps can't access the system providers. -->
+    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsContactsProviderTestCases.apk" />
+    </target_preparer>
+
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
+        <option name="package" value="android.provider.cts.contacts" />
+        <option name="runtime-hint" value="10m00s" />
+    </test>
+</configuration>
diff --git a/tests/tests/contactsprovider/OWNERS b/tests/tests/contactsprovider/OWNERS
new file mode 100644
index 0000000..f1a239a
--- /dev/null
+++ b/tests/tests/contactsprovider/OWNERS
@@ -0,0 +1,3 @@
+# Bug component: 161000
+omakoto@google.com
+yamasani@google.com
diff --git a/tests/tests/contactsprovider/res/drawable/ic_cts_minitab_selected.png b/tests/tests/contactsprovider/res/drawable/ic_cts_minitab_selected.png
new file mode 100644
index 0000000..c730050
--- /dev/null
+++ b/tests/tests/contactsprovider/res/drawable/ic_cts_minitab_selected.png
Binary files differ
diff --git a/tests/tests/contactsprovider/res/drawable/ic_cts_selected.png b/tests/tests/contactsprovider/res/drawable/ic_cts_selected.png
new file mode 100644
index 0000000..72a065c
--- /dev/null
+++ b/tests/tests/contactsprovider/res/drawable/ic_cts_selected.png
Binary files differ
diff --git a/tests/tests/provider/res/drawable/size_48x48.jpg b/tests/tests/contactsprovider/res/drawable/size_48x48.jpg
similarity index 100%
rename from tests/tests/provider/res/drawable/size_48x48.jpg
rename to tests/tests/contactsprovider/res/drawable/size_48x48.jpg
Binary files differ
diff --git a/tests/tests/contactsprovider/res/drawable/testimage.jpg b/tests/tests/contactsprovider/res/drawable/testimage.jpg
new file mode 100644
index 0000000..754df0c
--- /dev/null
+++ b/tests/tests/contactsprovider/res/drawable/testimage.jpg
Binary files differ
diff --git a/tests/tests/contactsprovider/res/values/strings.xml b/tests/tests/contactsprovider/res/values/strings.xml
new file mode 100644
index 0000000..2aee454
--- /dev/null
+++ b/tests/tests/contactsprovider/res/values/strings.xml
@@ -0,0 +1,19 @@
+<!--
+  ~ Copyright (C) 2019 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="label">Contacts provider</string>
+</resources>
diff --git a/tests/tests/provider/res/xml/contactprovider_authenticator.xml b/tests/tests/contactsprovider/res/xml/contactprovider_authenticator.xml
similarity index 100%
rename from tests/tests/provider/res/xml/contactprovider_authenticator.xml
rename to tests/tests/contactsprovider/res/xml/contactprovider_authenticator.xml
diff --git a/tests/tests/provider/src/android/provider/cts/PhotoUtil.java b/tests/tests/contactsprovider/src/android/provider/cts/PhotoUtil.java
similarity index 95%
rename from tests/tests/provider/src/android/provider/cts/PhotoUtil.java
rename to tests/tests/contactsprovider/src/android/provider/cts/PhotoUtil.java
index 49d57a7..726d63d 100644
--- a/tests/tests/provider/src/android/provider/cts/PhotoUtil.java
+++ b/tests/tests/contactsprovider/src/android/provider/cts/PhotoUtil.java
@@ -16,7 +16,7 @@
 
 package android.provider.cts;
 
-import android.provider.cts.R;
+import android.provider.cts.contacts.R;
 
 import android.content.Context;
 import com.android.compatibility.common.util.FileUtils;
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/CommonDatabaseUtils.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/CommonDatabaseUtils.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/CommonDatabaseUtils.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/CommonDatabaseUtils.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactUtil.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactUtil.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactUtil.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactUtil.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContractIntentsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContractIntentsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContractIntentsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContractIntentsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_AggregationSuggestionsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_AggregationSuggestionsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_AggregationSuggestionsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_AggregationSuggestionsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_AllUriTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_AllUriTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_AllUriTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_AllUriTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EmailTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EmailTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EmailTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EmailTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EventTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EventTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EventTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_EventTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_ImTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_ImTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_ImTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_ImTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_OrganizationTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_OrganizationTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_OrganizationTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_OrganizationTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_PhoneTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_PhoneTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_PhoneTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_PhoneTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_RelationTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_RelationTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_RelationTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_RelationTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_SipAddressTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_SipAddressTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_SipAddressTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_SipAddressTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_StructuredPostalTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_StructuredPostalTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_StructuredPostalTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_CommonDataKinds_StructuredPostalTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactCountsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_ContactCountsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactCountsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_ContactCountsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DataTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DataTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DeletedContacts.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DeletedContacts.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DeletedContacts.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DeletedContacts.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DirectoryTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DirectoryTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DirectoryTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DirectoryTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_GroupMembershipTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_GroupMembershipTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_GroupMembershipTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_GroupMembershipTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_IsSuperPrimaryName.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_IsSuperPrimaryName.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_IsSuperPrimaryName.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_IsSuperPrimaryName.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_PhoneLookup.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_PhoneLookup.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_PhoneLookup.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_PhoneLookup.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_PhotoTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_PhotoTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_PhotoTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_PhotoTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_PinnedPositionsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_PinnedPositionsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_PinnedPositionsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_PinnedPositionsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ProviderStatus.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_ProviderStatus.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ProviderStatus.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_ProviderStatus.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_QuickContactsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_QuickContactsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_QuickContactsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_QuickContactsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_SearchSnippetsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_SearchSnippetsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_SearchSnippetsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_SearchSnippetsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_StatusUpdatesTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_StatusUpdatesTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_StatusUpdatesTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_StatusUpdatesTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_StructuredPhoneticName.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_StructuredPhoneticName.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_StructuredPhoneticName.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_StructuredPhoneticName.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/account/ContactsContract_Subquery.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_Subquery.java
similarity index 97%
rename from tests/tests/provider/src/android/provider/cts/contacts/account/ContactsContract_Subquery.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_Subquery.java
index ab15977..f0a7525 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/account/ContactsContract_Subquery.java
+++ b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_Subquery.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.provider.cts.contacts.account;
+package android.provider.cts.contacts;
 
 import android.content.ContentProviderClient;
 import android.content.ContentResolver;
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsContract_TestDataBuilder.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsMetadataProviderTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsMetadataProviderTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsMetadataProviderTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsMetadataProviderTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsProvider2_AccountRemovalTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsProvider2_AccountRemovalTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsProvider2_AccountRemovalTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsProvider2_AccountRemovalTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsTest.java
similarity index 99%
rename from tests/tests/provider/src/android/provider/cts/contacts/ContactsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsTest.java
index 8735c5a..c9e246d 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsTest.java
+++ b/tests/tests/contactsprovider/src/android/provider/cts/contacts/ContactsTest.java
@@ -220,12 +220,12 @@
         try {
             Context context = getInstrumentation().getTargetContext();
             InputStream inputStream = context.getResources().openRawResource(
-                    android.provider.cts.R.drawable.testimage);
+                    android.provider.cts.contacts.R.drawable.testimage);
             int size = inputStream.available();
             byte[] data =  new byte[size];
             inputStream.read(data);
             BitmapDrawable sourceDrawable = (BitmapDrawable) context.getResources().getDrawable(
-                    android.provider.cts.R.drawable.testimage);
+                    android.provider.cts.contacts.R.drawable.testimage);
             // Test: insert
             ContentValues value = new ContentValues();
             value.put(Photos.PERSON_ID, 1);
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/Contacts_ContactMethodsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_ContactMethodsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/Contacts_ContactMethodsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_ContactMethodsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/Contacts_OrganizationsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_OrganizationsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/Contacts_OrganizationsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_OrganizationsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/Contacts_PeopleTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_PeopleTest.java
similarity index 97%
rename from tests/tests/provider/src/android/provider/cts/contacts/Contacts_PeopleTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_PeopleTest.java
index 0737478..278fe5a 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/Contacts_PeopleTest.java
+++ b/tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_PeopleTest.java
@@ -252,7 +252,7 @@
         Context context = getInstrumentation().getTargetContext();
         try {
             InputStream inputStream = context.getResources().openRawResource(
-                    android.provider.cts.R.drawable.testimage);
+                    android.provider.cts.contacts.R.drawable.testimage);
             int size = inputStream.available();
             byte[] data =  new byte[size];
             inputStream.read(data);
@@ -270,12 +270,12 @@
             assertNull(photoStream);
 
             bitmap = People.loadContactPhoto(context, mPeopleRowsAdded.get(0),
-                    android.provider.cts.R.drawable.size_48x48, null);
+                    android.provider.cts.contacts.R.drawable.size_48x48, null);
             assertEquals(96, bitmap.getWidth());
             assertEquals(64, bitmap.getHeight());
 
             bitmap = People.loadContactPhoto(context, null,
-                    android.provider.cts.R.drawable.size_48x48, null);
+                    android.provider.cts.contacts.R.drawable.size_48x48, null);
             assertNotNull(bitmap);
         } catch (IOException e) {
             fail("Unexpected IOException");
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/Contacts_PhonesTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_PhonesTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/Contacts_PhonesTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_PhonesTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/Contacts_SettingsTest.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_SettingsTest.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/Contacts_SettingsTest.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/Contacts_SettingsTest.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/DataUtil.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/DataUtil.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/DataUtil.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/DataUtil.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/DatabaseAsserts.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/DatabaseAsserts.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/DatabaseAsserts.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/DatabaseAsserts.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/DeletedContactUtil.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/DeletedContactUtil.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/DeletedContactUtil.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/DeletedContactUtil.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/DummyGalProvider.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/DummyGalProvider.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/DummyGalProvider.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/DummyGalProvider.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/README.txt b/tests/tests/contactsprovider/src/android/provider/cts/contacts/README.txt
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/README.txt
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/README.txt
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/RawContactUtil.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/RawContactUtil.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/RawContactUtil.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/RawContactUtil.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/account/MockAccountService.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/account/MockAccountService.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/account/MockAccountService.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/account/MockAccountService.java
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/account/StaticAccountAuthenticator.java b/tests/tests/contactsprovider/src/android/provider/cts/contacts/account/StaticAccountAuthenticator.java
similarity index 100%
rename from tests/tests/provider/src/android/provider/cts/contacts/account/StaticAccountAuthenticator.java
rename to tests/tests/contactsprovider/src/android/provider/cts/contacts/account/StaticAccountAuthenticator.java
diff --git a/tests/tests/dynamic_linker/AndroidTest.xml b/tests/tests/dynamic_linker/AndroidTest.xml
index 95433a4..1133eaf 100644
--- a/tests/tests/dynamic_linker/AndroidTest.xml
+++ b/tests/tests/dynamic_linker/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="bionic" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsDynamicLinkerTestCases.apk" />
diff --git a/tests/tests/effect/AndroidTest.xml b/tests/tests/effect/AndroidTest.xml
index 87a3165..4364d85 100644
--- a/tests/tests/effect/AndroidTest.xml
+++ b/tests/tests/effect/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="media" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsEffectTestCases.apk" />
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java
index fa2cfda..93d3d8d 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapColorSpaceTest.java
@@ -39,7 +39,6 @@
 import androidx.test.InstrumentationRegistry;
 import androidx.test.filters.RequiresDevice;
 import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
 
 import com.android.compatibility.common.util.ColorUtils;
 
@@ -54,8 +53,11 @@
 import java.nio.IntBuffer;
 import java.util.Arrays;
 
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+
 @SmallTest
-@RunWith(AndroidJUnit4.class)
+@RunWith(JUnitParamsRunner.class)
 public class BitmapColorSpaceTest {
     private static final String LOG_TAG = "BitmapColorSpaceTest";
 
@@ -1036,8 +1038,13 @@
         assertTrue(pass);
     }
 
+    private Object[] compressFormats() {
+        return Bitmap.CompressFormat.values();
+    }
+
     @Test
-    public void testEncodeP3() {
+    @Parameters(method = "compressFormats")
+    public void testEncodeP3(Bitmap.CompressFormat format) {
         Bitmap b = null;
         ImageDecoder.Source src = ImageDecoder.createSource(mResources.getAssets(),
                 "blue-16bit-srgb.png");
@@ -1051,24 +1058,18 @@
             fail("Failed with " + e);
         }
 
-        for (Bitmap.CompressFormat format : new Bitmap.CompressFormat[] {
-                Bitmap.CompressFormat.JPEG,
-                Bitmap.CompressFormat.WEBP,
-                Bitmap.CompressFormat.PNG,
-        }) {
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
-            assertTrue("Failed to encode F16 to " + format, b.compress(format, 100, out));
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        assertTrue("Failed to encode F16 to " + format, b.compress(format, 100, out));
 
-            byte[] array = out.toByteArray();
-            src = ImageDecoder.createSource(ByteBuffer.wrap(array));
+        byte[] array = out.toByteArray();
+        src = ImageDecoder.createSource(ByteBuffer.wrap(array));
 
-            try {
-                Bitmap b2 = ImageDecoder.decodeBitmap(src);
-                assertEquals("Wrong color space for " + format,
-                        ColorSpace.get(ColorSpace.Named.DISPLAY_P3), b2.getColorSpace());
-            } catch (IOException e) {
-                fail("Failed with " + e);
-            }
+        try {
+            Bitmap b2 = ImageDecoder.decodeBitmap(src);
+            assertEquals("Wrong color space for " + format,
+                    ColorSpace.get(ColorSpace.Named.DISPLAY_P3), b2.getColorSpace());
+        } catch (IOException e) {
+            fail("Failed with " + e);
         }
     }
 
@@ -1088,11 +1089,7 @@
             fail("Failed with " + e);
         }
 
-        for (Bitmap.CompressFormat format : new Bitmap.CompressFormat[] {
-                Bitmap.CompressFormat.JPEG,
-                Bitmap.CompressFormat.WEBP,
-                Bitmap.CompressFormat.PNG,
-        }) {
+        for (Bitmap.CompressFormat format : Bitmap.CompressFormat.values()) {
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             assertTrue("Failed to encode 8888 to " + format, b.compress(format, 100, out));
 
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
index 1b934ac..a0cb980 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -45,6 +45,7 @@
 import androidx.test.InstrumentationRegistry;
 import androidx.test.filters.SmallTest;
 
+import com.android.compatibility.common.util.BitmapUtils;
 import com.android.compatibility.common.util.CddTest;
 
 import org.junit.Before;
@@ -253,7 +254,7 @@
         Bitmap bPng = decodeOpaqueImage(R.drawable.png_test, options);
         assertEquals(bPng.getConfig(), config);
         Bitmap bWebp = decodeOpaqueImage(R.drawable.webp_test, options);
-        compareBitmaps(bPng, bWebp, tolerance, true, bPng.isPremultiplied());
+        BitmapUtils.assertBitmapsMse(bPng, bWebp, tolerance, true, bPng.isPremultiplied());
     }
 
     @Test
@@ -271,7 +272,7 @@
         assertTrue(bPng.compress(CompressFormat.WEBP, 90, oStreamWebp));
         InputStream iStreamWebp = new ByteArrayInputStream(oStreamWebp.toByteArray());
         Bitmap bWebp2 = decodeOpaqueImage(iStreamWebp, options);
-        compareBitmaps(bPng, bWebp2, tolerance, true, bPng.isPremultiplied());
+        BitmapUtils.assertBitmapsMse(bPng, bWebp2, tolerance, true, bPng.isPremultiplied());
     }
 
     @Test
@@ -296,7 +297,7 @@
         assertEquals(bWebP1.getConfig(), Config.ARGB_8888);
         assertTrue(bWebP1.isPremultiplied());
         assertTrue(bWebP1.hasAlpha());
-        compareBitmaps(bPng, bWebP1, tolerance, true, bPng.isPremultiplied());
+        BitmapUtils.assertBitmapsMse(bPng, bWebP1, tolerance, true, bPng.isPremultiplied());
 
         // Compress the PNG image to WebP format (Quality=90) and decode it back.
         // This will test end-to-end WebP encoding and decoding.
@@ -308,7 +309,7 @@
         assertEquals(bWebP2.getConfig(), Config.ARGB_8888);
         assertTrue(bWebP2.isPremultiplied());
         assertTrue(bWebP2.hasAlpha());
-        compareBitmaps(bPng, bWebP2, tolerance, true, bPng.isPremultiplied());
+        BitmapUtils.assertBitmapsMse(bPng, bWebP2, tolerance, true, bPng.isPremultiplied());
     }
 
     @Test
@@ -698,7 +699,7 @@
 
         p.setDataPosition(0);
         Bitmap b2 = Bitmap.CREATOR.createFromParcel(p);
-        compareBitmaps(b, b2, 0, true, true);
+        assertTrue(BitmapUtils.compareBitmaps(b, b2));
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         assertTrue(b2.compress(Bitmap.CompressFormat.JPEG, 50, baos));
@@ -937,7 +938,7 @@
         assertEquals(height, argb4444.getHeight());
         // ARGB_4444 is deprecated and we should decode to ARGB_8888.
         assertEquals(Config.ARGB_8888, argb4444.getConfig());
-        compareBitmaps(reference, argb4444, 0, true, true);
+        assertTrue(BitmapUtils.compareBitmaps(reference, argb4444));
 
         opts.inPreferredConfig = Config.RGB_565;
         Bitmap rgb565 = BitmapFactory.decodeResource(mRes, id, opts);
@@ -950,7 +951,8 @@
             // the reference.  We lose information when decoding to 565, so there must
             // be some tolerance.  The tolerance is intentionally loose to allow us some
             // flexibility regarding if we dither and how we color convert.
-            compareBitmaps(reference, rgb565.copy(Config.ARGB_8888, false), 30, true, true);
+            BitmapUtils.assertBitmapsMse(reference, rgb565.copy(Config.ARGB_8888, false), 30, true,
+                    true);
         }
 
         opts.inPreferredConfig = Config.ALPHA_8;
@@ -963,7 +965,7 @@
             // Convert the ALPHA_8 bitmap to ARGB_8888 and test that it is identical to
             // the reference.  We must do this manually because we are abusing ALPHA_8
             // in order to represent grayscale.
-            compareBitmaps(reference, grayToARGB(alpha8), 0, true, true);
+            assertTrue(BitmapUtils.compareBitmaps(reference, grayToARGB(alpha8)));
             assertNull(alpha8.getColorSpace());
         }
 
@@ -975,7 +977,7 @@
         assertEquals(width, defaultBitmap.getWidth());
         assertEquals(height, defaultBitmap.getHeight());
         assertEquals(Config.ARGB_8888, defaultBitmap.getConfig());
-        compareBitmaps(reference, defaultBitmap, 0, true, true);
+        assertTrue(BitmapUtils.compareBitmaps(reference, defaultBitmap));
     }
 
     private static Bitmap grayToARGB(Bitmap gray) {
@@ -1046,67 +1048,4 @@
         fOutput.close();
         return (file.getPath());
     }
-
-    // Compare expected to actual to see if their diff is less then mseMargin.
-    // lessThanMargin is to indicate whether we expect the mean square error
-    // to be "less than" or "no less than".
-    private static void compareBitmaps(Bitmap expected, Bitmap actual,
-            int mseMargin, boolean lessThanMargin, boolean isPremultiplied) {
-        final int width = expected.getWidth();
-        final int height = expected.getHeight();
-
-        assertEquals("mismatching widths", width, actual.getWidth());
-        assertEquals("mismatching heights", height, actual.getHeight());
-        assertEquals("mismatching configs", expected.getConfig(),
-                actual.getConfig());
-
-        double mse = 0;
-        int[] expectedColors = new int [width * height];
-        int[] actualColors = new int [width * height];
-
-        // Bitmap.getPixels() returns colors with non-premultiplied ARGB values.
-        expected.getPixels(expectedColors, 0, width, 0, 0, width, height);
-        actual.getPixels(actualColors, 0, width, 0, 0, width, height);
-
-        for (int row = 0; row < height; ++row) {
-            for (int col = 0; col < width; ++col) {
-                int idx = row * width + col;
-                mse += distance(expectedColors[idx], actualColors[idx], isPremultiplied);
-            }
-        }
-        mse /= width * height;
-
-        if (lessThanMargin) {
-            assertTrue("MSE " + mse +  "larger than the threshold: " + mseMargin,
-                    mse <= mseMargin);
-        } else {
-            assertFalse("MSE " + mse +  "smaller than the threshold: " + mseMargin,
-                    mse <= mseMargin);
-        }
-    }
-
-    private static int multiplyAlpha(int color, int alpha) {
-        return (color * alpha + 127) / 255;
-    }
-
-    // For the Bitmap with Alpha, multiply the Alpha values to get the effective
-    // RGB colors and then compute the color-distance.
-    private static double distance(int expect, int actual, boolean isPremultiplied) {
-        if (isPremultiplied) {
-            final int a1 = Color.alpha(actual);
-            final int a2 = Color.alpha(expect);
-            final int r = multiplyAlpha(Color.red(actual), a1) -
-                    multiplyAlpha(Color.red(expect), a2);
-            final int g = multiplyAlpha(Color.green(actual), a1) -
-                    multiplyAlpha(Color.green(expect), a2);
-            final int b = multiplyAlpha(Color.blue(actual), a1) -
-                    multiplyAlpha(Color.blue(expect), a2);
-            return r * r + g * g + b * b;
-        } else {
-            final int r = Color.red(actual) - Color.red(expect);
-            final int g = Color.green(actual) - Color.green(expect);
-            final int b = Color.blue(actual) - Color.blue(expect);
-            return r * r + g * g + b * b;
-        }
-    }
 }
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
index cb56256..371a637 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
@@ -17,7 +17,6 @@
 package android.graphics.cts;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
@@ -31,7 +30,6 @@
 import android.graphics.BitmapFactory.Options;
 import android.graphics.BitmapRegionDecoder;
 import android.graphics.Canvas;
-import android.graphics.Color;
 import android.graphics.ColorSpace;
 import android.graphics.Rect;
 import android.os.ParcelFileDescriptor;
@@ -41,6 +39,8 @@
 import androidx.test.filters.SmallTest;
 import androidx.test.runner.AndroidJUnit4;
 
+import com.android.compatibility.common.util.BitmapUtils;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -125,9 +125,6 @@
     // MSE margin for WebP Region-Decoding for 'Config.RGB_565' is little bigger.
     private static final int MSE_MARGIN_WEB_P_CONFIG_RGB_565 = 8;
 
-    private final int[] mExpectedColors = new int [TILE_SIZE * TILE_SIZE];
-    private final int[] mActualColors = new int [TILE_SIZE * TILE_SIZE];
-
     private ArrayList<File> mFilesCreated = new ArrayList<>(NAMES_TEMP_FILES.length);
 
     private Resources mRes;
@@ -426,7 +423,8 @@
                             Rect crop = new Rect(0 ,0, cropWidth, cropHeight);
                             Bitmap reuseCropped = cropBitmap(reuseResult, crop);
                             Bitmap defaultCropped = cropBitmap(defaultResult, crop);
-                            compareBitmaps(reuseCropped, defaultCropped, 0, true);
+                            BitmapUtils.assertBitmapsMse(reuseCropped, defaultCropped, 0, true,
+                                    false);
                         }
                     }
                 }
@@ -684,7 +682,7 @@
                 Rect expectedRect = new Rect(left, top, left + actual.getWidth(),
                         top + actual.getHeight());
                 expected = cropBitmap(wholeImage, expectedRect);
-                compareBitmaps(expected, actual, mseMargin, true);
+                BitmapUtils.assertBitmapsMse(expected, actual, mseMargin, true, false);
                 actual.recycle();
                 expected.recycle();
             }
@@ -744,55 +742,4 @@
         File file = new File(path);
         return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
     }
-
-
-    // Compare expected to actual to see if their diff is less then mseMargin.
-    // lessThanMargin is to indicate whether we expect the diff to be
-    // "less than" or "no less than".
-    private void compareBitmaps(Bitmap expected, Bitmap actual,
-            int mseMargin, boolean lessThanMargin) {
-        assertEquals("mismatching widths", expected.getWidth(),
-                actual.getWidth());
-        assertEquals("mismatching heights", expected.getHeight(),
-                actual.getHeight());
-
-        double mse = 0;
-        int width = expected.getWidth();
-        int height = expected.getHeight();
-        int[] expectedColors;
-        int[] actualColors;
-        if (width == TILE_SIZE && height == TILE_SIZE) {
-            expectedColors = mExpectedColors;
-            actualColors = mActualColors;
-        } else {
-            expectedColors = new int [width * height];
-            actualColors = new int [width * height];
-        }
-
-        expected.getPixels(expectedColors, 0, width, 0, 0, width, height);
-        actual.getPixels(actualColors, 0, width, 0, 0, width, height);
-
-        for (int row = 0; row < height; ++row) {
-            for (int col = 0; col < width; ++col) {
-                int idx = row * width + col;
-                mse += distance(expectedColors[idx], actualColors[idx]);
-            }
-        }
-        mse /= width * height;
-
-        if (lessThanMargin) {
-            assertTrue("MSE too large for normal case: " + mse,
-                    mse <= mseMargin);
-        } else {
-            assertFalse("MSE too small for abnormal case: " + mse,
-                    mse <= mseMargin);
-        }
-    }
-
-    private static double distance(int exp, int actual) {
-        int r = Color.red(actual) - Color.red(exp);
-        int g = Color.green(actual) - Color.green(exp);
-        int b = Color.blue(actual) - Color.blue(exp);
-        return r * r + g * g + b * b;
-    }
 }
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
index fc510a7..12ad86e 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapTest.java
@@ -33,6 +33,7 @@
 import android.graphics.Color;
 import android.graphics.ColorSpace;
 import android.graphics.ColorSpace.Named;
+import android.graphics.ImageDecoder;
 import android.graphics.Matrix;
 import android.graphics.Paint;
 import android.graphics.Picture;
@@ -47,6 +48,7 @@
 import androidx.test.filters.LargeTest;
 import androidx.test.filters.SmallTest;
 
+import com.android.compatibility.common.util.BitmapUtils;
 import com.android.compatibility.common.util.ColorUtils;
 import com.android.compatibility.common.util.WidgetTestUtils;
 
@@ -56,11 +58,13 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.IntBuffer;
 import java.nio.ShortBuffer;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -131,9 +135,84 @@
         mBitmap.compress(CompressFormat.JPEG, 101, new ByteArrayOutputStream());
     }
 
+    private static Object[] compressFormats() {
+        return CompressFormat.values();
+    }
+
     @Test
-    public void testCompress() {
-        assertTrue(mBitmap.compress(CompressFormat.JPEG, 50, new ByteArrayOutputStream()));
+    @Parameters(method = "compressFormats")
+    public void testCompress(CompressFormat format) {
+        assertTrue(mBitmap.compress(format, 50, new ByteArrayOutputStream()));
+    }
+
+    private Bitmap decodeBytes(byte[] bytes) {
+        ByteBuffer buffer = ByteBuffer.wrap(bytes);
+        ImageDecoder.Source src = ImageDecoder.createSource(buffer);
+        try {
+            return ImageDecoder.decodeBitmap(src, (decoder, info, s) -> {
+                decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE);
+            });
+        } catch (IOException e) {
+            fail("Failed to decode with " + e);
+            return null;
+        }
+    }
+
+    // There are three color components and
+    // each should be within a square difference of 15 * 15.
+    private static final int MSE_MARGIN = 3 * (15 * 15);
+
+    @Test
+    public void testCompressWebpLossy() {
+        // For qualities < 100, WEBP performs a lossy decode.
+        byte[] last = null;
+        Bitmap lastBitmap = null;
+        for (int quality : new int[] { 25, 50, 80, 99 }) {
+            ByteArrayOutputStream webp = new ByteArrayOutputStream();
+            assertTrue(mBitmap.compress(CompressFormat.WEBP, quality, webp));
+            byte[] webpCompressed = webp.toByteArray();
+
+
+            ByteArrayOutputStream webpLossy = new ByteArrayOutputStream();
+            assertTrue(mBitmap.compress(CompressFormat.WEBP_LOSSY, quality, webpLossy));
+            byte[] webpLossyCompressed = webpLossy.toByteArray();
+
+            assertTrue("Compression did not match at quality " + quality,
+                    Arrays.equals(webpCompressed, webpLossyCompressed));
+
+            Bitmap result = decodeBytes(webpCompressed);
+            if (last != null) {
+                // Higher quality will generally result in a larger file.
+                assertTrue(webpCompressed.length > last.length);
+                if (!BitmapUtils.compareBitmapsMse(lastBitmap, result, MSE_MARGIN, true, false)) {
+                    fail("Bad comparison for quality " + quality);
+                }
+            }
+            last = webpCompressed;
+            lastBitmap = result;
+        }
+    }
+
+    @Test
+    @Parameters({ "0", "50", "80", "99", "100" })
+    public void testCompressWebpLossless(int quality) {
+        ByteArrayOutputStream webp = new ByteArrayOutputStream();
+        assertTrue(mBitmap.compress(CompressFormat.WEBP_LOSSLESS, quality, webp));
+        byte[] webpCompressed = webp.toByteArray();
+        Bitmap result = decodeBytes(webpCompressed);
+
+        assertTrue("WEBP_LOSSLESS did not losslessly compress at quality " + quality,
+                BitmapUtils.compareBitmaps(mBitmap, result));
+    }
+
+    @Test
+    public void testCompressWebp100MeansLossless() {
+        ByteArrayOutputStream webp = new ByteArrayOutputStream();
+        assertTrue(mBitmap.compress(CompressFormat.WEBP, 100, webp));
+        byte[] webpCompressed = webp.toByteArray();
+        Bitmap result = decodeBytes(webpCompressed);
+        assertTrue("WEBP_LOSSLESS did not losslessly compress at quality 100",
+                BitmapUtils.compareBitmaps(mBitmap, result));
     }
 
     @Test(expected=IllegalStateException.class)
diff --git a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
index d42e9ca..b3e6be5 100644
--- a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
@@ -38,21 +38,24 @@
         assertEquals(CompressFormat.JPEG, CompressFormat.valueOf("JPEG"));
         assertEquals(CompressFormat.PNG, CompressFormat.valueOf("PNG"));
         assertEquals(CompressFormat.WEBP, CompressFormat.valueOf("WEBP"));
+        assertEquals(CompressFormat.WEBP_LOSSY, CompressFormat.valueOf("WEBP_LOSSY"));
+        assertEquals(CompressFormat.WEBP_LOSSLESS, CompressFormat.valueOf("WEBP_LOSSLESS"));
     }
 
     @Test
     public void testValues(){
         CompressFormat[] comFormat = CompressFormat.values();
 
-        assertEquals(3, comFormat.length);
+        assertEquals(5, comFormat.length);
         assertEquals(CompressFormat.JPEG, comFormat[0]);
         assertEquals(CompressFormat.PNG, comFormat[1]);
         assertEquals(CompressFormat.WEBP, comFormat[2]);
+        assertEquals(CompressFormat.WEBP_LOSSY, comFormat[3]);
+        assertEquals(CompressFormat.WEBP_LOSSLESS, comFormat[4]);
 
-        //CompressFormat is used as a argument here for all the methods that use it
         Bitmap b = Bitmap.createBitmap(10, 24, Config.ARGB_8888);
-        assertTrue(b.compress(CompressFormat.JPEG, 24, new ByteArrayOutputStream()));
-        assertTrue(b.compress(CompressFormat.PNG, 24, new ByteArrayOutputStream()));
-        assertTrue(b.compress(CompressFormat.WEBP, 24, new ByteArrayOutputStream()));
+        for (CompressFormat format : comFormat) {
+            assertTrue(b.compress(format, 24, new ByteArrayOutputStream()));
+        }
     }
 }
diff --git a/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java b/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java
index 6b86de7..4c36c15 100644
--- a/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java
@@ -412,10 +412,12 @@
                             assertNotEquals(Bitmap.Config.HARDWARE, bm.getConfig());
 
                             if (!doScale && !doCrop) {
+                                BitmapFactory.Options options = new BitmapFactory.Options();
+                                options.inScaled = false;
                                 Bitmap reference = BitmapFactory.decodeResource(res,
-                                        record.resId, null);
+                                        record.resId, options);
                                 assertNotNull(reference);
-                                BitmapUtils.compareBitmaps(bm, reference);
+                                assertTrue(BitmapUtils.compareBitmaps(bm, reference));
                             }
                             break;
                         default:
@@ -1389,6 +1391,73 @@
         }
     }
 
+    @Test
+    public void testScaleAndCrop() {
+        class CropListener implements ImageDecoder.OnHeaderDecodedListener {
+            public boolean doCrop = true;
+            public Rect outScaledRect = null;
+            public Rect outCropRect = null;
+
+            @Override
+            public void onHeaderDecoded(ImageDecoder decoder, ImageDecoder.ImageInfo info,
+                                        ImageDecoder.Source src) {
+                // Use software for pixel comparison.
+                decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE);
+
+                // Scale to a size that is not directly supported by sampling.
+                Size originalSize = info.getSize();
+                int scaledWidth = originalSize.getWidth() * 2 / 3;
+                int scaledHeight = originalSize.getHeight() * 2 / 3;
+                decoder.setTargetSize(scaledWidth, scaledHeight);
+
+                outScaledRect = new Rect(0, 0, scaledWidth, scaledHeight);
+
+                if (doCrop) {
+                    outCropRect = new Rect(scaledWidth / 2, scaledHeight / 2,
+                            scaledWidth, scaledHeight);
+                    decoder.setCrop(outCropRect);
+                }
+            }
+        }
+        CropListener l = new CropListener();
+        ImageDecoder.Source src = mCreators[0].apply(R.drawable.png_test);
+
+        // Scale and crop in a single step.
+        Bitmap oneStepBm = null;
+        try {
+            oneStepBm = ImageDecoder.decodeBitmap(src, l);
+        } catch (IOException e) {
+            fail("Failed with exception " + e);
+        }
+        assertNotNull(oneStepBm);
+        assertNotNull(l.outCropRect);
+        assertEquals(l.outCropRect.width(), oneStepBm.getWidth());
+        assertEquals(l.outCropRect.height(), oneStepBm.getHeight());
+        Rect cropRect = new Rect(l.outCropRect);
+
+        assertNotNull(l.outScaledRect);
+        Rect scaledRect = new Rect(l.outScaledRect);
+
+        // Now just scale with ImageDecoder, and crop afterwards.
+        l.doCrop = false;
+        Bitmap twoStepBm = null;
+        try {
+            twoStepBm = ImageDecoder.decodeBitmap(src, l);
+        } catch (IOException e) {
+            fail("Failed with exception " + e);
+        }
+        assertNotNull(twoStepBm);
+        assertEquals(scaledRect.width(), twoStepBm.getWidth());
+        assertEquals(scaledRect.height(), twoStepBm.getHeight());
+
+        Bitmap cropped = Bitmap.createBitmap(twoStepBm, cropRect.left, cropRect.top,
+                cropRect.width(), cropRect.height());
+        assertNotNull(cropped);
+
+        // The two should look the same.
+        assertTrue(BitmapUtils.compareBitmaps(cropped, oneStepBm, .99));
+    }
+
     @Test(expected = IllegalArgumentException.class)
     public void testResizeZeroX() {
         ImageDecoder.Source src = mCreators[0].apply(R.drawable.png_test);
@@ -1873,6 +1942,7 @@
 
     @Test
     public void testRespectOrientation() {
+        boolean isWebp = false;
         // These 8 images test the 8 EXIF orientations. If the orientation is
         // respected, they all have the same dimensions: 100 x 80.
         // They are also identical (after adjusting), so compare them.
@@ -1898,6 +1968,7 @@
                 // The webp files may not look exactly the same as the jpegs.
                 // Recreate the reference.
                 reference = null;
+                isWebp = true;
             }
             Uri uri = getAsResourceUri(resId);
             ImageDecoder.Source src = ImageDecoder.createSource(getContentResolver(), uri);
@@ -1913,7 +1984,8 @@
                 if (reference == null) {
                     reference = bm;
                 } else {
-                    BitmapUtils.compareBitmaps(bm, reference);
+                    int mse = isWebp ? 70 : 1;
+                    BitmapUtils.assertBitmapsMse(bm, reference, mse, true, false);
                 }
             } catch (IOException e) {
                 fail("Decoding " + uri.toString() + " yielded " + e);
@@ -2380,7 +2452,7 @@
 
         Bitmap bm1 = drawToBitmap(first);
         Bitmap bm2 = drawToBitmap(second);
-        BitmapUtils.compareBitmaps(bm1, bm2);
+        assertTrue(BitmapUtils.compareBitmaps(bm1, bm2));
     }
 
     @Test
diff --git a/tests/tests/graphics/src/android/graphics/cts/YuvImageTest.java b/tests/tests/graphics/src/android/graphics/cts/YuvImageTest.java
index ad8f0af..61c2c4c 100644
--- a/tests/tests/graphics/src/android/graphics/cts/YuvImageTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/YuvImageTest.java
@@ -16,7 +16,6 @@
 package android.graphics.cts;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -34,6 +33,8 @@
 import androidx.test.filters.SmallTest;
 import androidx.test.runner.AndroidJUnit4;
 
+import com.android.compatibility.common.util.BitmapUtils;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -253,13 +254,13 @@
         Bitmap actual = null;
         boolean sameRect = rect1.equals(rect2) ? true : false;
 
-		Rect actualRect = new Rect(rect2);
+        Rect actualRect = new Rect(rect2);
         actual = compressDecompress(image, actualRect);
 
         Rect expectedRect = sameRect ? actualRect : rect1;
         expected = Bitmap.createBitmap(testBitmap, expectedRect.left, expectedRect.top,
                 expectedRect.width(), expectedRect.height());
-        compareBitmaps(expected, actual, MSE_MARGIN, sameRect);
+        BitmapUtils.assertBitmapsMse(expected, actual, MSE_MARGIN, sameRect, false);
     }
 
     // Compress rect in image.
@@ -275,7 +276,7 @@
         expected = Bitmap.createBitmap(testBitmap, newRect.left, newRect.top,
               newRect.width(), newRect.height());
 
-        compareBitmaps(expected, actual, MSE_MARGIN, true);
+        BitmapUtils.assertBitmapsMse(expected, actual, MSE_MARGIN, true, false);
     }
 
     // Compress rect in image to a jpeg and then decode the jpeg to a bitmap.
@@ -334,50 +335,6 @@
         return yuv;
     }
 
-    // Compare expected to actual to see if their diff is less then mseMargin.
-    // lessThanMargin is to indicate whether we expect the diff to be
-    // "less than" or "no less than".
-    private void compareBitmaps(Bitmap expected, Bitmap actual,
-            int mseMargin, boolean lessThanMargin) {
-        assertEquals("mismatching widths", expected.getWidth(),
-                actual.getWidth());
-        assertEquals("mismatching heights", expected.getHeight(),
-                actual.getHeight());
-
-        double mse = 0;
-        int width = expected.getWidth();
-        int height = expected.getHeight();
-        int[] expColors = new int [width * height];
-        expected.getPixels(expColors, 0, width, 0, 0, width, height);
-
-        int[] actualColors = new int [width * height];
-        actual.getPixels(actualColors, 0, width, 0, 0, width, height);
-
-        for (int row = 0; row < height; ++row) {
-            for (int col = 0; col < width; ++col) {
-                int idx = row * width + col;
-                mse += distance(expColors[idx], actualColors[idx]);
-            }
-        }
-        mse /= width * height;
-
-        Log.i(TAG, "MSE: " + mse);
-        if (lessThanMargin) {
-            assertTrue("MSE too large for normal case: " + mse,
-                    mse <= mseMargin);
-        } else {
-            assertFalse("MSE too small for abnormal case: " + mse,
-                    mse <= mseMargin);
-        }
-    }
-
-    private double distance(int exp, int actual) {
-        int r = Color.red(actual) - Color.red(exp);
-        int g = Color.green(actual) - Color.green(exp);
-        int b = Color.blue(actual) - Color.blue(exp);
-        return r * r + g * g + b * b;
-    }
-
     private void argb2yuv(int argb, byte[] yuv) {
         int r = Color.red(argb);
         int g = Color.green(argb);
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java
index 24f44f2..258af51 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java
@@ -525,7 +525,7 @@
             testDrawable.draw(canvas);
         }
 
-        BitmapUtils.compareBitmaps(expected, actual);
+        assertTrue(BitmapUtils.compareBitmaps(expected, actual));
     }
 
     @Test
@@ -604,7 +604,7 @@
                 drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
         Canvas canvas = new Canvas(test);
         drawable.draw(canvas);
-        BitmapUtils.compareBitmaps(expected, test);
+        assertTrue(BitmapUtils.compareBitmaps(expected, test));
     }
 
     @Test
diff --git a/tests/tests/hardware/AndroidManifest.xml b/tests/tests/hardware/AndroidManifest.xml
index 7ce0cbe..4b56763 100644
--- a/tests/tests/hardware/AndroidManifest.xml
+++ b/tests/tests/hardware/AndroidManifest.xml
@@ -72,7 +72,10 @@
         </activity>
 
         <activity android:name="android.hardware.input.cts.InputCtsActivity"
-            android:label="InputCtsActivity" />
+            android:label="InputCtsActivity"
+            android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation
+                    |screenLayout|fontScale|uiMode|orientation|density|screenSize
+                    |smallestScreenSize"/>
 
         <activity android:name="android.hardware.cts.FingerprintTestActivity"
             android:label="FingerprintTestActivity">
diff --git a/tests/tests/hardware/res/raw/asus_gamepad_keyeventtests.json b/tests/tests/hardware/res/raw/asus_gamepad_keyeventtests.json
index 73d77b5..e9068fe 100644
--- a/tests/tests/hardware/res/raw/asus_gamepad_keyeventtests.json
+++ b/tests/tests/hardware/res/raw/asus_gamepad_keyeventtests.json
@@ -5,6 +5,7 @@
       [0x01, 0x01, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_A"},
       {"action": "UP", "keycode": "BUTTON_A"}
@@ -17,6 +18,7 @@
       [0x01, 0x02, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_B"},
       {"action": "UP", "keycode": "BUTTON_B"}
@@ -29,6 +31,7 @@
       [0x01, 0x04, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_X"},
       {"action": "UP", "keycode": "BUTTON_X"}
@@ -41,6 +44,7 @@
       [0x01, 0x08, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_Y"},
       {"action": "UP", "keycode": "BUTTON_Y"}
@@ -53,6 +57,7 @@
       [0x01, 0x10, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_L1"},
       {"action": "UP", "keycode": "BUTTON_L1"}
@@ -65,6 +70,7 @@
       [0x01, 0x20, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_R1"},
       {"action": "UP", "keycode": "BUTTON_R1"}
@@ -77,6 +83,7 @@
       [0x01, 0x40, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_THUMBL"},
       {"action": "UP", "keycode": "BUTTON_THUMBL"}
@@ -89,6 +96,7 @@
       [0x01, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_THUMBR"},
       {"action": "UP", "keycode": "BUTTON_THUMBR"}
@@ -101,6 +109,7 @@
       [0x01, 0x00, 0x81, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_MODE"},
       {"action": "UP", "keycode": "BUTTON_MODE"}
@@ -113,9 +122,10 @@
       [0x01, 0x00, 0x82, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BACK"},
       {"action": "UP", "keycode": "BACK"}
     ]
   }
-]
\ No newline at end of file
+]
diff --git a/tests/tests/hardware/res/raw/asus_gamepad_motioneventtests.json b/tests/tests/hardware/res/raw/asus_gamepad_motioneventtests.json
index e104040..f44d3ce2 100644
--- a/tests/tests/hardware/res/raw/asus_gamepad_motioneventtests.json
+++ b/tests/tests/hardware/res/raw/asus_gamepad_motioneventtests.json
@@ -15,7 +15,8 @@
       [0x01, 0x00, 0x80, 0xa0, 0xff, 0x71, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x83, 0x73, 0x71, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x83, 0x80, 0x72, 0x80, 0x00, 0x00]
-                ],
+    ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_X": 0.059, "AXIS_Y": 0.0745, "AXIS_Z": -0.106}},
       {"action": "MOVE", "axes": {"AXIS_X": 0.153, "AXIS_Y": 0.9373, "AXIS_Z": -0.106}},
@@ -31,6 +32,7 @@
       [0x01, 0x00, 0x60, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_X": -1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_X": 0}}
@@ -43,6 +45,7 @@
       [0x01, 0x00, 0x20, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_X": 1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_X": 0}}
@@ -55,6 +58,7 @@
       [0x01, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": -1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": 0}}
@@ -67,6 +71,7 @@
       [0x01, 0x00, 0x40, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": 1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": 0}}
@@ -81,6 +86,7 @@
       [0x01, 0x00, 0x80, 0x20, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x7a, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_X": -0.827}},
       {"action": "MOVE", "axes": {"AXIS_X": -1.0}},
@@ -97,6 +103,7 @@
       [0x01, 0x00, 0x80, 0x74, 0x80, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x7f, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_X": 0.655}},
       {"action": "MOVE", "axes": {"AXIS_X": 1.0}},
@@ -116,6 +123,7 @@
       [0x01, 0x00, 0x80, 0x80, 0x4a, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Y": -0.031}},
       {"action": "MOVE", "axes": {"AXIS_Y": -0.333}},
@@ -135,6 +143,7 @@
       [0x01, 0x00, 0x80, 0x80, 0xd1, 0x80, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Y": 0.184}},
       {"action": "MOVE", "axes": {"AXIS_Y": 1.0}},
@@ -152,6 +161,7 @@
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x21, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Z": -0.200}},
       {"action": "MOVE", "axes": {"AXIS_Z": -0.851}},
@@ -173,6 +183,7 @@
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x93, 0x80, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x8c, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Z": 0.114}},
       {"action": "MOVE", "axes": {"AXIS_Z": 0.231}},
@@ -193,6 +204,7 @@
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x55, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_RZ": -0.239}},
       {"action": "MOVE", "axes": {"AXIS_RZ": -1.0}},
@@ -211,6 +223,7 @@
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x82, 0x00, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_RZ": 0.129}},
       {"action": "MOVE", "axes": {"AXIS_RZ": 1.0}},
@@ -228,6 +241,7 @@
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x90, 0x00],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_LTRIGGER": 0.651, "AXIS_BRAKE": 0.651}},
       {"action": "MOVE", "axes": {"AXIS_LTRIGGER": 1.0, "AXIS_BRAKE": 1.0}},
@@ -244,6 +258,7 @@
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0xa5],
       [0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_RTRIGGER": 0.686, "AXIS_GAS": 0.686}},
       {"action": "MOVE", "axes": {"AXIS_RTRIGGER": 1.0, "AXIS_GAS": 1.0}},
@@ -251,6 +266,4 @@
       {"action": "MOVE", "axes": {"AXIS_RTRIGGER": 0, "AXIS_GAS": 0}}
     ]
   }
-
-
-]
\ No newline at end of file
+]
diff --git a/tests/tests/hardware/res/raw/microsoft_sculpttouch_motioneventtests.json b/tests/tests/hardware/res/raw/microsoft_sculpttouch_motioneventtests.json
new file mode 100644
index 0000000..d4b58d6
--- /dev/null
+++ b/tests/tests/hardware/res/raw/microsoft_sculpttouch_motioneventtests.json
@@ -0,0 +1,28 @@
+[
+  {
+    "name": "Left click",
+    "reports": [
+      [0x1a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
+      [0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
+    ],
+    "source": "MOUSE_RELATIVE",
+    "events": [
+      {
+        "action": "DOWN",
+        "buttonState": ["PRIMARY"],
+        "axes": {"AXIS_PRESSURE": 1}
+      },
+      {
+        "action": "BUTTON_PRESS",
+        "buttonState": ["PRIMARY"],
+        "axes": {"AXIS_PRESSURE": 1}
+      },
+      {"action": "BUTTON_RELEASE",
+        "axes": {"AXIS_PRESSURE": 0}
+      },
+      {"action": "UP",
+        "axes": {"AXIS_PRESSURE": 0}
+      }
+    ]
+  }
+]
diff --git a/tests/tests/hardware/res/raw/microsoft_sculpttouch_register.json b/tests/tests/hardware/res/raw/microsoft_sculpttouch_register.json
new file mode 100644
index 0000000..a9fd5ab
--- /dev/null
+++ b/tests/tests/hardware/res/raw/microsoft_sculpttouch_register.json
@@ -0,0 +1,39 @@
+{
+  "id": 1,
+  "command": "register",
+  "name": "Microsoft Sculpt Touch Mouse (Test)",
+  "vid": 0x045e,
+  "pid": 0x077c,
+  "descriptor": [
+    0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x05, 0x01, 0x09, 0x02, 0xa1, 0x02,
+    0x85, 0x1a, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x05,
+    0x95, 0x05, 0x75, 0x01, 0x15, 0x00, 0x25, 0x01, 0x81, 0x02, 0x75, 0x03,
+    0x95, 0x01, 0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x95, 0x02,
+    0x75, 0x10, 0x16, 0x01, 0x80, 0x26, 0xff, 0x7f, 0x81, 0x06, 0xa1, 0x02,
+    0x85, 0x12, 0x09, 0x48, 0x95, 0x01, 0x75, 0x02, 0x15, 0x00, 0x25, 0x01,
+    0x35, 0x01, 0x45, 0x10, 0xb1, 0x02, 0x85, 0x1a, 0x09, 0x38, 0x35, 0x00,
+    0x45, 0x00, 0x95, 0x01, 0x75, 0x10, 0x16, 0x01, 0x80, 0x26, 0xff, 0x7f,
+    0x81, 0x06, 0xc0, 0xa1, 0x02, 0x85, 0x12, 0x09, 0x48, 0x75, 0x02, 0x15,
+    0x00, 0x25, 0x01, 0x35, 0x01, 0x45, 0x10, 0xb1, 0x02, 0x35, 0x00, 0x45,
+    0x00, 0x75, 0x04, 0xb1, 0x01, 0x85, 0x1a, 0x05, 0x0c, 0x95, 0x01, 0x75,
+    0x10, 0x16, 0x01, 0x80, 0x26, 0xff, 0x7f, 0x0a, 0x38, 0x02, 0x81, 0x06,
+    0xc0, 0xc0, 0xc0, 0xc0, 0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x05, 0x01,
+    0x09, 0x02, 0xa1, 0x02, 0x85, 0x1f, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x95,
+    0x01, 0x75, 0x10, 0x16, 0x01, 0x80, 0x26, 0xff, 0x7f, 0x81, 0x06, 0x85,
+    0x17, 0x06, 0x00, 0xff, 0x0a, 0x06, 0xff, 0x0a, 0x0f, 0xff, 0x15, 0x00,
+    0x25, 0x01, 0x35, 0x01, 0x45, 0x10, 0x95, 0x02, 0x75, 0x02, 0xb1, 0x02,
+    0x0a, 0x04, 0xff, 0x35, 0x00, 0x45, 0x00, 0x95, 0x01, 0x75, 0x01, 0xb1,
+    0x02, 0x75, 0x03, 0xb1, 0x01, 0xc0, 0x85, 0x16, 0x05, 0x0c, 0x19, 0x00,
+    0x2a, 0xff, 0x03, 0x95, 0x01, 0x75, 0x10, 0x15, 0x00, 0x26, 0xff, 0x03,
+    0x81, 0x00, 0x06, 0x00, 0xff, 0x1a, 0x01, 0xfd, 0x2a, 0xff, 0xfd, 0x15,
+    0x01, 0x26, 0xff, 0x00, 0x75, 0x08, 0x81, 0x00, 0x81, 0x01, 0xc0, 0x05,
+    0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x22, 0x06, 0x00, 0xff, 0x15, 0x00,
+    0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x17, 0x0a, 0x0a, 0xfa, 0xb1, 0x02,
+    0x85, 0x24, 0x06, 0x00, 0xff, 0x95, 0x1f, 0x0a, 0x0a, 0xfa, 0xb1, 0x02,
+    0x85, 0x27, 0x06, 0x00, 0xff, 0x0a, 0x0a, 0xfa, 0x81, 0x02, 0xc0, 0x05,
+    0x01, 0x09, 0x06, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x07, 0x1a, 0xe0, 0x00,
+    0x2a, 0xe7, 0x00, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x75, 0x08, 0x95,
+    0x01, 0x81, 0x01, 0x19, 0x00, 0x2a, 0x91, 0x00, 0x26, 0xff, 0x00, 0x95,
+    0x06, 0x81, 0x00, 0xc0
+  ]
+}
diff --git a/tests/tests/hardware/res/raw/sony_dualshock4_keyeventtests.json b/tests/tests/hardware/res/raw/sony_dualshock4_keyeventtests.json
index 4271249..14470b1 100644
--- a/tests/tests/hardware/res/raw/sony_dualshock4_keyeventtests.json
+++ b/tests/tests/hardware/res/raw/sony_dualshock4_keyeventtests.json
@@ -15,6 +15,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_A"},
       {"action": "UP", "keycode": "BUTTON_A"}
@@ -37,6 +38,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_B"},
       {"action": "UP", "keycode": "BUTTON_B"}
@@ -59,6 +61,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_X"},
       {"action": "UP", "keycode": "BUTTON_X"}
@@ -81,6 +84,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_Y"},
       {"action": "UP", "keycode": "BUTTON_Y"}
@@ -103,6 +107,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_L1"},
       {"action": "UP", "keycode": "BUTTON_L1"}
@@ -125,6 +130,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_R1"},
       {"action": "UP", "keycode": "BUTTON_R1"}
@@ -147,6 +153,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_L2"},
       {"action": "UP", "keycode": "BUTTON_L2"}
@@ -169,6 +176,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_R2"},
       {"action": "UP", "keycode": "BUTTON_R2"}
@@ -191,6 +199,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_THUMBL"},
       {"action": "UP", "keycode": "BUTTON_THUMBL"}
@@ -213,6 +222,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_THUMBR"},
       {"action": "UP", "keycode": "BUTTON_THUMBR"}
@@ -235,6 +245,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_SELECT"},
       {"action": "UP", "keycode": "BUTTON_SELECT"}
@@ -257,6 +268,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_START"},
       {"action": "UP", "keycode": "BUTTON_START"}
@@ -279,6 +291,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99,
       0x23, 0xe0, 0x5d]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "DOWN", "keycode": "BUTTON_MODE"},
       {"action": "UP", "keycode": "BUTTON_MODE"}
diff --git a/tests/tests/hardware/res/raw/sony_dualshock4_motioneventtests.json b/tests/tests/hardware/res/raw/sony_dualshock4_motioneventtests.json
index dcb61ee..55e9e5b 100644
--- a/tests/tests/hardware/res/raw/sony_dualshock4_motioneventtests.json
+++ b/tests/tests/hardware/res/raw/sony_dualshock4_motioneventtests.json
@@ -9,6 +9,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
     ]
   },
@@ -29,6 +30,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_X": -1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_X": 0}}
@@ -51,6 +53,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_X": 1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_X": 0}}
@@ -73,6 +76,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": -1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": 0}}
@@ -95,6 +99,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": 1}},
       {"action": "MOVE", "axes": {"AXIS_HAT_Y": 0}}
@@ -123,6 +128,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_X": -0.5}},
       {"action": "MOVE", "axes": {"AXIS_X": -1}},
@@ -152,6 +158,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_X": 0.51}},
       {"action": "MOVE", "axes": {"AXIS_X": 1}},
@@ -181,6 +188,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Y": -0.5}},
       {"action": "MOVE", "axes": {"AXIS_Y": -1}},
@@ -210,6 +218,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Y": 0.51}},
       {"action": "MOVE", "axes": {"AXIS_Y": 1}},
@@ -239,6 +248,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Z": -0.5}},
       {"action": "MOVE", "axes": {"AXIS_Z": -1}},
@@ -268,6 +278,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_Z": 0.51}},
       {"action": "MOVE", "axes": {"AXIS_Z": 1}},
@@ -297,6 +308,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_RZ": -0.5}},
       {"action": "MOVE", "axes": {"AXIS_RZ": -1}},
@@ -326,6 +338,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_RZ": 0.51}},
       {"action": "MOVE", "axes": {"AXIS_RZ": 1}},
@@ -355,6 +368,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_LTRIGGER": 0.5, "AXIS_BRAKE": 0.5}},
       {"action": "MOVE", "axes": {"AXIS_LTRIGGER": 1.0, "AXIS_BRAKE": 1.0}},
@@ -384,6 +398,7 @@
       0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
       0x2e, 0x80, 0xf2]
     ],
+    "source": "JOYSTICK",
     "events": [
       {"action": "MOVE", "axes": {"AXIS_RTRIGGER": 0.5, "AXIS_GAS": 0.5}},
       {"action": "MOVE", "axes": {"AXIS_RTRIGGER": 1.0, "AXIS_GAS": 1.0}},
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/AsusGamepadTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/AsusGamepadTest.java
similarity index 92%
rename from tests/tests/hardware/src/android/hardware/input/cts/tests/AsusGamepadTestCase.java
rename to tests/tests/hardware/src/android/hardware/input/cts/tests/AsusGamepadTest.java
index a4b8e919..943a9fa 100644
--- a/tests/tests/hardware/src/android/hardware/input/cts/tests/AsusGamepadTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/AsusGamepadTest.java
@@ -26,8 +26,8 @@
 
 @MediumTest
 @RunWith(AndroidJUnit4.class)
-public class AsusGamepadTestCase extends InputTestCase {
-    public AsusGamepadTestCase() {
+public class AsusGamepadTest extends InputTestCase {
+    public AsusGamepadTest() {
         super(R.raw.asus_gamepad_register);
     }
 
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
index 1f4d277..42e9397 100644
--- a/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
@@ -25,6 +25,7 @@
 import android.view.InputEvent;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
+import android.view.View;
 
 import androidx.annotation.NonNull;
 import androidx.test.platform.app.InstrumentationRegistry;
@@ -46,17 +47,22 @@
 
 public abstract class InputTestCase {
     private static final float TOLERANCE = 0.005f;
+    private static final long TIMEOUT_DELTA = 10000;
 
     private final BlockingQueue<InputEvent> mEvents;
 
     private InputListener mInputListener;
     private Instrumentation mInstrumentation;
+    private View mDecorView;
     private HidDevice mHidDevice;
     private HidJsonParser mParser;
     // Stores the name of the currently running test
     private String mCurrentTestCase;
     private int mRegisterResourceId; // raw resource that contains json for registering a hid device
 
+    // State used for motion events
+    private int mLastButtonState;
+
     InputTestCase(int registerResourceId) {
         mEvents = new LinkedBlockingQueue<>();
         mInputListener = new InputListener();
@@ -71,6 +77,7 @@
     public void setUp() {
         mInstrumentation = InstrumentationRegistry.getInstrumentation();
         mActivityRule.getActivity().setInputCallback(mInputListener);
+        mDecorView = mActivityRule.getActivity().getWindow().getDecorView();
         mParser = new HidJsonParser(mInstrumentation.getTargetContext());
         int hidDeviceId = mParser.readDeviceId(mRegisterResourceId);
         String registerCommand = mParser.readRegisterCommand(mRegisterResourceId);
@@ -89,7 +96,7 @@
      *
      * If other KeyEvents are received by the application prior to the expected KeyEvent, or no
      * KeyEvents are received within a reasonable amount of time, then this will throw an
-     * AssertionFailedError.
+     * {@link AssertionError}.
      *
      * Only action and keyCode are being compared.
      */
@@ -98,8 +105,9 @@
         if (receivedKeyEvent == null) {
             failWithMessage("Did not receive " + expectedKeyEvent);
         }
-        assertEquals(mCurrentTestCase, expectedKeyEvent.getAction(), receivedKeyEvent.getAction());
-        assertEquals(mCurrentTestCase,
+        assertEquals(mCurrentTestCase + " (action)",
+                expectedKeyEvent.getAction(), receivedKeyEvent.getAction());
+        assertEquals(mCurrentTestCase + " (keycode)",
                 expectedKeyEvent.getKeyCode(), receivedKeyEvent.getKeyCode());
     }
 
@@ -120,7 +128,21 @@
         if (event.getHistorySize() > 0) {
             failWithMessage("expected each MotionEvent to only have a single entry");
         }
-        assertEquals(mCurrentTestCase, expectedEvent.getAction(), event.getAction());
+        assertEquals(mCurrentTestCase + " (action)",
+                expectedEvent.getAction(), event.getAction());
+        assertEquals(mCurrentTestCase + " (source)",
+                expectedEvent.getSource(), event.getSource());
+        assertEquals(mCurrentTestCase + " (button state)",
+                expectedEvent.getButtonState(), event.getButtonState());
+        if (event.getActionMasked() == MotionEvent.ACTION_BUTTON_PRESS
+                || event.getActionMasked() == MotionEvent.ACTION_BUTTON_RELEASE) {
+            // Only checking getActionButton() for ACTION_BUTTON_PRESS or ACTION_BUTTON_RELEASE
+            // because for actions other than ACTION_BUTTON_PRESS and ACTION_BUTTON_RELEASE the
+            // returned value of getActionButton() is undefined.
+            assertEquals(mCurrentTestCase + " (action button)",
+                    mLastButtonState ^ event.getButtonState(), event.getActionButton());
+            mLastButtonState = event.getButtonState();
+        }
         for (int axis = MotionEvent.AXIS_X; axis <= MotionEvent.AXIS_GENERIC_16; axis++) {
             assertEquals(mCurrentTestCase + " (" + MotionEvent.axisToString(axis) + ")",
                     expectedEvent.getAxisValue(axis), event.getAxisValue(axis), TOLERANCE);
@@ -156,13 +178,19 @@
             // Make sure we received the expected input events
             for (int i = 0; i < testData.events.size(); i++) {
                 final InputEvent event = testData.events.get(i);
-                if (event instanceof MotionEvent) {
-                    assertReceivedMotionEvent((MotionEvent) event);
-                } else if (event instanceof KeyEvent) {
-                    assertReceivedKeyEvent((KeyEvent) event);
-                } else {
-                    fail("Entry " + i + " is neither a KeyEvent nor a MotionEvent: " + event);
+                try {
+                    if (event instanceof MotionEvent) {
+                        assertReceivedMotionEvent((MotionEvent) event);
+                        continue;
+                    }
+                    if (event instanceof KeyEvent) {
+                        assertReceivedKeyEvent((KeyEvent) event);
+                        continue;
+                    }
+                } catch (AssertionError error) {
+                    throw new AssertionError("Assertion on entry " + i + " failed.", error);
                 }
+                fail("Entry " + i + " is neither a KeyEvent nor a MotionEvent: " + event);
             }
         }
         assertNoMoreEvents();
@@ -235,6 +263,7 @@
                             event.getXPrecision(), event.getYPrecision(),
                             event.getDeviceId(), event.getEdgeFlags(),
                             event.getSource(), event.getFlags());
+            singleEvent.setActionButton(event.getActionButton());
             events.add(singleEvent);
         }
 
@@ -245,6 +274,7 @@
                         event.getXPrecision(), event.getYPrecision(),
                         event.getDeviceId(), event.getEdgeFlags(),
                         event.getSource(), event.getFlags());
+        singleEvent.setActionButton(event.getActionButton());
         events.add(singleEvent);
         return events;
     }
@@ -277,4 +307,23 @@
             }
         }
     }
+
+    protected class PointerCaptureSession implements AutoCloseable {
+        protected PointerCaptureSession() {
+            requestPointerCaptureSync();
+        }
+
+        @Override
+        public void close() {
+            releasePointerCaptureSync();
+        }
+
+        private void requestPointerCaptureSync() {
+            mInstrumentation.runOnMainSync(mDecorView::requestPointerCapture);
+        }
+
+        private void releasePointerCaptureSync() {
+            mInstrumentation.runOnMainSync(mDecorView::releasePointerCapture);
+        }
+    }
 }
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4TestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/MicrosoftSculpttouchTest.java
similarity index 70%
copy from tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4TestCase.java
copy to tests/tests/hardware/src/android/hardware/input/cts/tests/MicrosoftSculpttouchTest.java
index 909ef04..ac3e3a3 100644
--- a/tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4TestCase.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/MicrosoftSculpttouchTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,19 +26,16 @@
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class SonyDualshock4TestCase extends InputTestCase {
+public class MicrosoftSculpttouchTest extends InputTestCase {
 
-    public SonyDualshock4TestCase() {
-        super(R.raw.sony_dualshock4_register);
-    }
-
-    @Test
-    public void testAllKeys() {
-        testInputEvents(R.raw.sony_dualshock4_keyeventtests);
+    public MicrosoftSculpttouchTest() {
+        super(R.raw.microsoft_sculpttouch_register);
     }
 
     @Test
     public void testAllMotions() {
-        testInputEvents(R.raw.sony_dualshock4_motioneventtests);
+        try (PointerCaptureSession session = new PointerCaptureSession()) {
+            testInputEvents(R.raw.microsoft_sculpttouch_motioneventtests);
+        }
     }
 }
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4TestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4Test.java
similarity index 91%
rename from tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4TestCase.java
rename to tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4Test.java
index 909ef04..409c84f 100644
--- a/tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4TestCase.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/SonyDualshock4Test.java
@@ -26,9 +26,9 @@
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class SonyDualshock4TestCase extends InputTestCase {
+public class SonyDualshock4Test extends InputTestCase {
 
-    public SonyDualshock4TestCase() {
+    public SonyDualshock4Test() {
         super(R.raw.sony_dualshock4_register);
     }
 
diff --git a/tests/tests/icu/AndroidTest.xml b/tests/tests/icu/AndroidTest.xml
index 51ae4fa..9e1729a 100644
--- a/tests/tests/icu/AndroidTest.xml
+++ b/tests/tests/icu/AndroidTest.xml
@@ -20,6 +20,7 @@
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <!-- Enable multi-lib since ICU4J is backed by native codes in libcore and ICU4C. -->
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsIcuTestCases.apk" />
diff --git a/tests/tests/jvmti/attaching/AndroidTest.xml b/tests/tests/jvmti/attaching/AndroidTest.xml
index 8948004..fc82f9d 100644
--- a/tests/tests/jvmti/attaching/AndroidTest.xml
+++ b/tests/tests/jvmti/attaching/AndroidTest.xml
@@ -21,6 +21,7 @@
     <!-- Requires debuggable -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="component" value="art" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/tests/libcoreapievolution/AndroidTest.xml b/tests/tests/libcoreapievolution/AndroidTest.xml
index 5f8d6e9..bfa6cdf 100644
--- a/tests/tests/libcoreapievolution/AndroidTest.xml
+++ b/tests/tests/libcoreapievolution/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/tests/libcoreapievolution/src/android/apievolution/cts/ApiEvolutionTest.java b/tests/tests/libcoreapievolution/src/android/apievolution/cts/ApiEvolutionTest.java
index 8fea09b..0bf86a3 100644
--- a/tests/tests/libcoreapievolution/src/android/apievolution/cts/ApiEvolutionTest.java
+++ b/tests/tests/libcoreapievolution/src/android/apievolution/cts/ApiEvolutionTest.java
@@ -16,6 +16,12 @@
 
 package android.apievolution.cts;
 
+import android.telephony.CellIdentity;
+import android.telephony.CellIdentityNr;
+import android.telephony.CellInfoNr;
+import android.telephony.CellSignalStrength;
+import android.telephony.CellSignalStrengthNr;
+
 import org.junit.Test;
 
 import java.lang.annotation.Annotation;
@@ -70,7 +76,7 @@
     @Test
     public void testCovariantReturnTypeMethods_annotation_concurrentHashMap() throws Exception {
         assertSyntheticMethodOverloadExists(ConcurrentHashMap.class, "keySet", null, Set.class,
-                ConcurrentHashMap.KeySetView.class, true);
+                ConcurrentHashMap.KeySetView.class, true /* requireIdenticalExceptions */);
     }
 
     @Test public void testCovariantReturnTypeMethods_annotation_byteBuffer() throws Exception {
@@ -102,6 +108,26 @@
     }
 
     /**
+     * Ensures that {@link CellInfoNr#getCellIdentity()} returns a {@link CellIdentityNr}.
+     * This is not a libcore/ API but testing it here avoids duplicating test support code.
+     */
+    @Test public void testCellIdentityNr_Override() throws Exception {
+        assertSyntheticMethodOverloadExists(CellInfoNr.class, "getCellIdentity", null,
+            CellIdentity.class, CellIdentityNr.class, true /* requireIdenticalExceptions */);
+    }
+
+    /**
+     * Ensures that {@link CellInfoNr#getCellSignalStrength()} returns a {@link
+     * CellSignalStrengthNr}. This is not a libcore/ API but testing it here avoids duplicating
+     * test support code.
+     */
+    @Test public void testCellCellSignalStrength_Override() throws Exception {
+        assertSyntheticMethodOverloadExists(CellInfoNr.class, "getCellSignalStrength", null,
+            CellSignalStrength.class, CellSignalStrengthNr.class,
+            true /* requireIdenticalExceptions */);
+    }
+
+    /**
      * Asserts the presence of synthetic methods overloads for methods that return {@code this} on
      * {@link Buffer} subclasses, and which are annotated with {@code @CovariantReturnType}.
      * In OpenJDK 9 the return types were changed from {@link Buffer} to be the subclass's type
diff --git a/tests/tests/libcorelegacy22/AndroidTest.xml b/tests/tests/libcorelegacy22/AndroidTest.xml
index f496e9e..33e08c0 100644
--- a/tests/tests/libcorelegacy22/AndroidTest.xml
+++ b/tests/tests/libcorelegacy22/AndroidTest.xml
@@ -17,6 +17,9 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="libcore" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <!-- Test is eligible to run on Android Multiuser users other than SYSTEM.
+         See source.android.com/devices/tech/admin/multi-user#user_types -->
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index a46b19c..286fbb7 100644
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -16,6 +16,16 @@
 
 package android.location.cts;
 
+import static android.location.LocationManager.FUSED_PROVIDER;
+import static android.location.LocationManager.GPS_PROVIDER;
+import static android.location.LocationManager.KEY_LOCATION_CHANGED;
+import static android.location.LocationManager.KEY_PROVIDER_ENABLED;
+import static android.location.LocationManager.KEY_PROXIMITY_ENTERING;
+import static android.location.LocationManager.NETWORK_PROVIDER;
+import static android.location.LocationManager.PASSIVE_PROVIDER;
+
+import static org.junit.Assert.assertNotEquals;
+
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -23,22 +33,32 @@
 import android.content.IntentFilter;
 import android.content.pm.PackageManager;
 import android.location.Criteria;
+import android.location.GnssMeasurementsEvent;
+import android.location.GnssNavigationMessage;
 import android.location.GnssStatus;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.location.LocationProvider;
+import android.location.LocationRequest;
 import android.location.OnNmeaMessageListener;
 import android.os.Bundle;
-import android.os.Handler;
+import android.os.CancellationSignal;
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.SystemClock;
 import android.os.UserManager;
-import android.test.UiThreadTest;
 import android.util.Log;
 
+import com.android.internal.util.Preconditions;
+
 import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
 
 /**
  * Requires the permissions
@@ -51,815 +71,98 @@
 
     private static final String TAG = "LocationManagerTest";
 
-    private static final long TEST_TIME_OUT = 5000;
+    private static final long TIMEOUT_MS = 5000;
+    private static final long FAILURE_TIMEOUT_MS = 200;
 
-    private static final String TEST_MOCK_PROVIDER_NAME = "test_provider";
-
-    private static final String UNKNOWN_PROVIDER_NAME = "unknown_provider";
-
-    private static final String FUSED_PROVIDER_NAME = "fused";
-
-    private LocationManager mManager;
+    private static final String TEST_PROVIDER = "test_provider";
 
     private Context mContext;
+    private LocationManager mManager;
 
-    private PendingIntent mPendingIntent;
+    private static Location createLocation(String provider, double latitude, double longitude) {
+        Location location = new Location(provider);
+        location.setLatitude(latitude);
+        location.setLongitude(longitude);
+        location.setAccuracy(1.0f);
+        location.setTime(System.currentTimeMillis());
+        location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
+        return location;
+    }
 
-    private TestIntentReceiver mIntentReceiver;
+    private static Executor directExecutor() {
+        return Runnable::run;
+    }
+
+    private static void assertLocationEquals(Location expected, Location actual) {
+        if (expected == actual) {
+            return;
+        }
+
+        if (expected == null || actual == null) {
+            // gives nicer error message
+            assertEquals(expected, actual);
+            return;
+        }
+
+        assertEquals(expected.getProvider(), actual.getProvider());
+        assertEquals(expected.getLatitude(), actual.getLatitude());
+        assertEquals(expected.getLongitude(), actual.getLongitude());
+        assertEquals(expected.getTime(), actual.getTime());
+        assertEquals(expected.getElapsedRealtimeNanos(), actual.getElapsedRealtimeNanos());
+    }
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         mContext = getInstrumentation().getTargetContext();
+        mManager = mContext.getSystemService(LocationManager.class);
 
-        mManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
+        assertNotNull(mManager);
 
-        // remove test provider if left over from an aborted run
-        LocationProvider lp = mManager.getProvider(TEST_MOCK_PROVIDER_NAME);
-        if (lp != null) {
-            mManager.removeTestProvider(TEST_MOCK_PROVIDER_NAME);
+        for (String provider : mManager.getAllProviders()) {
+            if (PASSIVE_PROVIDER.equals(provider)) {
+                continue;
+            }
+            mManager.removeTestProvider(provider);
         }
 
-        addTestProvider(TEST_MOCK_PROVIDER_NAME);
-    }
-
-    /**
-     * Helper method to add a test provider with given name.
-     */
-    private void addTestProvider(final String providerName) {
-        mManager.addTestProvider(providerName, true, //requiresNetwork,
-                false, // requiresSatellite,
-                true,  // requiresCell,
-                false, // hasMonetaryCost,
-                false, // supportsAltitude,
-                false, // supportsSpeed,
-                false, // supportsBearing,
-                Criteria.POWER_MEDIUM, // powerRequirement
-                Criteria.ACCURACY_FINE); // accuracy
-        mManager.setTestProviderEnabled(providerName, true);
+        mManager.addTestProvider(TEST_PROVIDER,
+                true,
+                false,
+                true,
+                false,
+                false,
+                false,
+                false,
+                Criteria.POWER_MEDIUM,
+                Criteria.ACCURACY_FINE);
+        mManager.setTestProviderEnabled(TEST_PROVIDER, true);
     }
 
     @Override
     protected void tearDown() throws Exception {
-        LocationProvider provider = mManager.getProvider(TEST_MOCK_PROVIDER_NAME);
-        if (provider != null) {
-            mManager.removeTestProvider(TEST_MOCK_PROVIDER_NAME);
+        for (String provider : mManager.getAllProviders()) {
+            if (PASSIVE_PROVIDER.equals(provider)) {
+                continue;
+            }
+            mManager.removeTestProvider(provider);
         }
-        if (mPendingIntent != null) {
-            mManager.removeProximityAlert(mPendingIntent);
-        }
-        if (mIntentReceiver != null) {
-            mContext.unregisterReceiver(mIntentReceiver);
-        }
+
         super.tearDown();
     }
 
-    public void testRemoveTestProvider() {
-        // this test assumes TEST_MOCK_PROVIDER_NAME was created in setUp.
-        LocationProvider provider = mManager.getProvider(TEST_MOCK_PROVIDER_NAME);
-        assertNotNull(provider);
-
-        try {
-            mManager.addTestProvider(TEST_MOCK_PROVIDER_NAME, true, //requiresNetwork,
-                    false, // requiresSatellite,
-                    true,  // requiresCell,
-                    false, // hasMonetaryCost,
-                    false, // supportsAltitude,
-                    false, // supportsSpeed,
-                    false, // supportsBearing,
-                    Criteria.POWER_MEDIUM, // powerRequirement
-                    Criteria.ACCURACY_FINE); // accuracy
-            fail("Should throw IllegalArgumentException when provider already exists!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        mManager.removeTestProvider(TEST_MOCK_PROVIDER_NAME);
-        provider = mManager.getProvider(TEST_MOCK_PROVIDER_NAME);
-        assertNull(provider);
-
-        try {
-            mManager.removeTestProvider(UNKNOWN_PROVIDER_NAME);
-            fail("Should throw IllegalArgumentException when no provider exists!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    public void testGetProviders() {
-        List<String> providers = mManager.getAllProviders();
-        assertTrue(providers.size() >= 2);
-        assertTrue(hasTestProvider(providers));
-
-        assertEquals(hasGpsFeature(), hasGpsProvider(providers));
-
-        int oldSizeAllProviders = providers.size();
-
-        providers = mManager.getProviders(false);
-        assertEquals(oldSizeAllProviders, providers.size());
-        assertTrue(hasTestProvider(providers));
-
-        providers = mManager.getProviders(true);
-        assertTrue(providers.size() >= 1);
-        assertTrue(hasTestProvider(providers));
-        int oldSizeTrueProviders = providers.size();
-
-        mManager.setTestProviderEnabled(TEST_MOCK_PROVIDER_NAME, false);
-        providers = mManager.getProviders(true);
-        assertEquals(oldSizeTrueProviders - 1, providers.size());
-        assertFalse(hasTestProvider(providers));
-
-        providers = mManager.getProviders(false);
-        assertEquals(oldSizeAllProviders, providers.size());
-        assertTrue(hasTestProvider(providers));
-
-        mManager.removeTestProvider(TEST_MOCK_PROVIDER_NAME);
-        providers = mManager.getAllProviders();
-        assertEquals(oldSizeAllProviders - 1, providers.size());
-        assertFalse(hasTestProvider(providers));
-    }
-
-    private boolean hasTestProvider(List<String> providers) {
-        return hasProvider(providers, TEST_MOCK_PROVIDER_NAME);
-    }
-
-    private boolean hasGpsProvider(List<String> providers) {
-        return hasProvider(providers, LocationManager.GPS_PROVIDER);
-    }
-
-    private boolean hasGpsFeature() {
-        return mContext.getPackageManager().hasSystemFeature(
-                PackageManager.FEATURE_LOCATION_GPS);
-    }
-
-    private boolean hasProvider(List<String> providers, String providerName) {
-        for (String provider : providers) {
-            if (provider != null && provider.equals(providerName)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public void testGetProvider() {
-        LocationProvider p = mManager.getProvider(TEST_MOCK_PROVIDER_NAME);
-        assertNotNull(p);
-        assertEquals(TEST_MOCK_PROVIDER_NAME, p.getName());
-
-        p = mManager.getProvider(LocationManager.GPS_PROVIDER);
-        if (hasGpsFeature()) {
-            assertNotNull(p);
-            assertEquals(LocationManager.GPS_PROVIDER, p.getName());
-        } else {
-            assertNull(p);
-        }
-
-        p = mManager.getProvider(UNKNOWN_PROVIDER_NAME);
-        assertNull(p);
-
-        try {
-            mManager.getProvider(null);
-            fail("Should throw IllegalArgumentException when provider is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    public void testGetProvidersWithCriteria() {
-        Criteria criteria = new Criteria();
-        List<String> providers = mManager.getProviders(criteria, true);
-        assertTrue(providers.size() >= 1);
-        assertTrue(hasTestProvider(providers));
-
-        criteria = new Criteria();
-        criteria.setPowerRequirement(Criteria.POWER_HIGH);
-        String p = mManager.getBestProvider(criteria, true);
-        if (p != null) { // we may not have any enabled providers
-            assertTrue(mManager.isProviderEnabled(p));
-        }
-
-        criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
-        p = mManager.getBestProvider(criteria, false);
-        assertNotNull(p);
-
-        criteria.setPowerRequirement(Criteria.POWER_LOW);
-        p = mManager.getBestProvider(criteria, true);
-        if (p != null) { // we may not have any enabled providers
-            assertTrue(mManager.isProviderEnabled(p));
-        }
-
-        criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
-        p = mManager.getBestProvider(criteria, false);
-        assertNotNull(p);
-    }
-
-    /**
-     * Returns true if the {@link LocationManager} reports that the device includes this flavor
-     * of location provider.
-     */
-    private boolean deviceHasProvider(String provider) {
-        List<String> providers = mManager.getAllProviders();
-        for (String aProvider : providers) {
-            if (aProvider.equals(provider)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Ensures the test provider is removed. {@link LocationManager#removeTestProvider(String)}
-     * throws an {@link java.lang.IllegalArgumentException} if there is no such test provider,
-     * so we have to add it before we clear it.
-     */
-    private void forceRemoveTestProvider(String provider) {
-        addTestProvider(provider);
-        mManager.removeTestProvider(provider);
-    }
-
-    public void testLocationUpdatesWithLocationListener() throws InterruptedException {
-        doLocationUpdatesWithLocationListener(TEST_MOCK_PROVIDER_NAME);
-
-        try {
-            mManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
-                    (LocationListener) null);
-            fail("Should throw IllegalArgumentException if param listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestLocationUpdates(null, 0, 0, new MockLocationListener());
-            fail("Should throw IllegalArgumentException if param provider is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates( (LocationListener) null );
-            fail("Should throw IllegalArgumentException if listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Helper method to test a location update with given mock location provider
-     *
-     * @param providerName name of provider to test. Must already exist.
-     * @throws InterruptedException
-     */
-    private void doLocationUpdatesWithLocationListener(final String providerName)
-            throws InterruptedException {
-        final double latitude1 = 10;
-        final double longitude1 = 40;
-        final double latitude2 = 35;
-        final double longitude2 = 80;
-        final MockLocationListener listener = new MockLocationListener();
-
-        // update location and notify listener
-        new Thread(new Runnable() {
-            public void run() {
-                Looper.prepare();
-                mManager.requestLocationUpdates(providerName, 0, 0, listener);
-                listener.setLocationRequested();
-                Looper.loop();
-            }
-        }).start();
-        // wait for location requested to be called first, otherwise setLocation can be called
-        // before there is a listener attached
-        assertTrue(listener.hasCalledLocationRequested(TEST_TIME_OUT));
-        updateLocation(providerName, latitude1, longitude1);
-        assertTrue(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-        Location location = listener.getLocation();
-        assertEquals(providerName, location.getProvider());
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertEquals(true, location.isFromMockProvider());
-
-        // update location without notifying listener
-        listener.reset();
-        assertFalse(listener.hasCalledOnLocationChanged(0));
-        mManager.removeUpdates(listener);
-        updateLocation(providerName, latitude2, longitude2);
-        assertFalse(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-    }
-
-    /**
-     * Verifies that all real location providers can be replaced by a mock provider.
-     * <p/>
-     * This feature is quite useful for developer automated testing.
-     * This test may fail if another unknown test provider already exists, because there is no
-     * known way to determine if a given provider is a test provider.
-     * @throws InterruptedException
-     */
-    public void testReplaceRealProvidersWithMocks() throws InterruptedException {
-        for (String providerName : mManager.getAllProviders()) {
-            if (!providerName.equals(TEST_MOCK_PROVIDER_NAME) &&
-                !providerName.equals(LocationManager.PASSIVE_PROVIDER)) {
-                addTestProvider(providerName);
-                try {
-                    // run the update location test logic to ensure location updates can be injected
-                    doLocationUpdatesWithLocationListener(providerName);
-                } finally {
-                    mManager.removeTestProvider(providerName);
-                }
-            }
-        }
-    }
-
-    public void testLocationUpdatesWithLocationListenerAndLooper() throws InterruptedException {
-        double latitude1 = 60;
-        double longitude1 = 20;
-        double latitude2 = 40;
-        double longitude2 = 30;
-        final MockLocationListener listener = new MockLocationListener();
-
-        // update location and notify listener
-        HandlerThread handlerThread = new HandlerThread("testLocationUpdates");
-        handlerThread.start();
-        mManager.requestLocationUpdates(TEST_MOCK_PROVIDER_NAME, 0, 0, listener,
-                handlerThread.getLooper());
-
-        updateLocation(latitude1, longitude1);
-        assertTrue(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-        Location location = listener.getLocation();
-        assertEquals(TEST_MOCK_PROVIDER_NAME, location.getProvider());
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertEquals(true, location.isFromMockProvider());
-
-        // update location without notifying listener
-        mManager.removeUpdates(listener);
-        listener.reset();
-        updateLocation(latitude2, longitude2);
-        assertFalse(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-
-        try {
-            mManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
-                    (LocationListener) null, Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestLocationUpdates(null, 0, 0, listener, Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param provider is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates((LocationListener) null );
-            fail("Should throw IllegalArgumentException if listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    public void testLocationUpdatesWithPendingIntent() throws InterruptedException {
-        double latitude1 = 20;
-        double longitude1 = 40;
-        double latitude2 = 30;
-        double longitude2 = 50;
-
-        // update location and receive broadcast.
-        registerIntentReceiver();
-        mManager.requestLocationUpdates(TEST_MOCK_PROVIDER_NAME, 0, 0, mPendingIntent);
-        updateLocation(latitude1, longitude1);
-        waitForReceiveBroadcast();
-
-        assertNotNull(mIntentReceiver.getLastReceivedIntent());
-        Location location = mManager.getLastKnownLocation(TEST_MOCK_PROVIDER_NAME);
-        assertEquals(TEST_MOCK_PROVIDER_NAME, location.getProvider());
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertEquals(true, location.isFromMockProvider());
-
-        // update location without receiving broadcast.
-        mManager.removeUpdates(mPendingIntent);
-        mIntentReceiver.clearReceivedIntents();
-        updateLocation(latitude2, longitude2);
-        waitForReceiveBroadcast();
-        assertNull(mIntentReceiver.getLastReceivedIntent());
-
-        try {
-            mManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
-                    (PendingIntent) null);
-            fail("Should throw IllegalArgumentException if param intent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestLocationUpdates(null, 0, 0, mPendingIntent);
-            fail("Should throw IllegalArgumentException if param provider is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates( (PendingIntent) null );
-            fail("Should throw IllegalArgumentException if intent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    public void testSingleUpdateWithLocationListenerAndLooper() throws InterruptedException {
-        double latitude1 = 60;
-        double longitude1 = 20;
-        double latitude2 = 40;
-        double longitude2 = 30;
-        double latitude3 = 10;
-        double longitude3 = 50;
-        final MockLocationListener listener = new MockLocationListener();
-
-        // update location and notify listener
-        HandlerThread handlerThread = new HandlerThread("testLocationUpdates4");
-        handlerThread.start();
-        mManager.requestSingleUpdate(TEST_MOCK_PROVIDER_NAME, listener, handlerThread.getLooper());
-
-        updateLocation(latitude1, longitude1);
-        assertTrue(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-        Location location = listener.getLocation();
-        assertEquals(TEST_MOCK_PROVIDER_NAME, location.getProvider());
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertEquals(true, location.isFromMockProvider());
-
-        // Any further location change doesn't trigger an update.
-        updateLocation(latitude2, longitude2);
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-
-        // update location without notifying listener
-        mManager.removeUpdates(listener);
-        listener.reset();
-        updateLocation(latitude3, longitude3);
-        assertFalse(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-
-        try {
-            mManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, mPendingIntent);
-            fail("Should throw IllegalArgumentException if PendingIntent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, (LocationListener) null,
-                    Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestSingleUpdate((String) null, listener, Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param provider is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates((LocationListener) null );
-            fail("Should throw IllegalArgumentException if listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    public void testLocationUpdatesWithCriteriaAndPendingIntent() throws InterruptedException {
-        double latitude1 = 10;
-        double longitude1 = 20;
-        double latitude2 = 30;
-        double longitude2 = 40;
-
-        registerIntentReceiver();
-        mockFusedLocation();
-
-        // Update location and receive broadcast.
-        Criteria criteria = createLocationCriteria();
-        mManager.requestLocationUpdates(0, 0 , criteria, mPendingIntent);
-        updateFusedLocation(latitude1, longitude1);
-        waitForReceiveBroadcast();
-
-        assertNotNull(mIntentReceiver.getLastReceivedIntent());
-        Location location = (Location) mIntentReceiver.getLastReceivedIntent().getExtras()
-                .get(LocationManager.KEY_LOCATION_CHANGED);
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertTrue(location.hasAccuracy());
-        assertEquals(1.0f, location.getAccuracy());
-        assertEquals(true, location.isFromMockProvider());
-
-        // Update location without receiving broadcast.
-        mManager.removeUpdates(mPendingIntent);
-        mIntentReceiver.clearReceivedIntents();
-        updateFusedLocation(latitude2, longitude2);
-        waitForReceiveBroadcast();
-        assertNull(mIntentReceiver.getLastReceivedIntent());
-
-        // Missing arguments throw exceptions.
-        try {
-            mManager.requestLocationUpdates(0, 0, criteria, (PendingIntent) null);
-            fail("Should throw IllegalArgumentException if param intent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestLocationUpdates(0, 0, null, mPendingIntent);
-            fail("Should throw IllegalArgumentException if param criteria is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates( (PendingIntent) null );
-            fail("Should throw IllegalArgumentException if param PendingIntent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        unmockFusedLocation();
-    }
-
-    public void testSingleUpdateWithCriteriaAndPendingIntent() throws InterruptedException {
-        double latitude1 = 10;
-        double longitude1 = 20;
-        double latitude2 = 30;
-        double longitude2 = 40;
-        double latitude3 = 50;
-        double longitude3 = 60;
-
-        registerIntentReceiver();
-        mockFusedLocation();
-
-        // Update location and receive broadcast.
-        Criteria criteria = createLocationCriteria();
-        mManager.requestSingleUpdate(criteria, mPendingIntent);
-        updateFusedLocation(latitude1, longitude1);
-        waitForReceiveBroadcast();
-
-        assertNotNull(mIntentReceiver.getLastReceivedIntent());
-        Location location = (Location) mIntentReceiver.getLastReceivedIntent().getExtras()
-                .get(LocationManager.KEY_LOCATION_CHANGED);
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertTrue(location.hasAccuracy());
-        assertEquals(1.0f, location.getAccuracy());
-        assertEquals(true, location.isFromMockProvider());
-
-        // Any further location change doesn't trigger an update.
-        updateFusedLocation(latitude2, longitude2);
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-
-        // Update location without receiving broadcast.
-        mManager.removeUpdates(mPendingIntent);
-        mIntentReceiver.clearReceivedIntents();
-        updateFusedLocation(latitude3, longitude3);
-        waitForReceiveBroadcast();
-        assertNull(mIntentReceiver.getLastReceivedIntent());
-
-        // Missing arguments throw exceptions.
-        try {
-            mManager.requestSingleUpdate(criteria, (PendingIntent) null);
-            fail("Should throw IllegalArgumentException if param intent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestSingleUpdate((Criteria) null, mPendingIntent);
-            fail("Should throw IllegalArgumentException if param criteria is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates( (PendingIntent) null );
-            fail("Should throw IllegalArgumentException if param PendingIntent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        unmockFusedLocation();
-    }
-
-    public void testLocationUpdatesWithCriteriaAndLocationListenerAndLooper()
-            throws InterruptedException {
-        double latitude1 = 40;
-        double longitude1 = 10;
-        double latitude2 = 20;
-        double longitude2 = 30;
-       final MockLocationListener listener = new MockLocationListener();
-        mockFusedLocation();
-
-        // update location and notify listener
-        HandlerThread handlerThread = new HandlerThread("testLocationUpdates1");
-        handlerThread.start();
-        Criteria criteria = createLocationCriteria();
-        mManager.requestLocationUpdates(0, 0, criteria, listener, handlerThread.getLooper());
-
-        updateFusedLocation(latitude1, longitude1);
-        assertTrue(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-        Location location = listener.getLocation();
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertTrue(location.hasAccuracy());
-        assertEquals(1.0f, location.getAccuracy());
-        assertEquals(true, location.isFromMockProvider());
-
-        // update location without notifying listener
-        mManager.removeUpdates(listener);
-        listener.reset();
-        updateFusedLocation(latitude2, longitude2);
-        assertFalse(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-
-        // Missing arguments throw exceptions.
-        try {
-            mManager.requestLocationUpdates(0, 0, criteria, (LocationListener) null,
-                    Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestLocationUpdates(0, 0, null, listener, Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param criteria is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates( (LocationListener) null );
-            fail("Should throw IllegalArgumentException if listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        unmockFusedLocation();
-    }
-
-    public void testSingleUpdateWithCriteriaAndLocationListenerAndLooper()
-            throws InterruptedException {
-        double latitude1 = 40;
-        double longitude1 = 10;
-        double latitude2 = 20;
-        double longitude2 = 30;
-        double latitude3 = 60;
-        double longitude3 = 50;
-        final MockLocationListener listener = new MockLocationListener();
-        mockFusedLocation();
-
-        // update location and notify listener
-        HandlerThread handlerThread = new HandlerThread("testLocationUpdates2");
-        handlerThread.start();
-        Criteria criteria = createLocationCriteria();
-        mManager.requestSingleUpdate(criteria, listener, handlerThread.getLooper());
-
-        updateFusedLocation(latitude1, longitude1);
-        assertTrue(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-        Location location = listener.getLocation();
-        assertEquals(FUSED_PROVIDER_NAME, location.getProvider());
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertTrue(location.hasAccuracy());
-        assertEquals(1.0f, location.getAccuracy());
-        assertEquals(true, location.isFromMockProvider());
-
-        // Any further location change doesn't trigger an update.
-        updateFusedLocation(latitude2, longitude2);
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-
-        // update location without notifying listener
-        mManager.removeUpdates(listener);
-        listener.reset();
-        updateFusedLocation(latitude3, longitude3);
-        assertFalse(listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-
-        // Missing arguments throw exceptions.
-        try {
-            mManager.requestLocationUpdates(0, 0, criteria, (LocationListener) null,
-                    Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestLocationUpdates(0, 0, null, listener, Looper.myLooper());
-            fail("Should throw IllegalArgumentException if param criteria is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates( (LocationListener) null );
-            fail("Should throw IllegalArgumentException if listener is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        unmockFusedLocation();
-    }
-
-    public void testSingleUpdateWithPendingIntent() throws InterruptedException {
-        double latitude1 = 20;
-        double longitude1 = 40;
-        double latitude2 = 30;
-        double longitude2 = 50;
-        double latitude3 = 10;
-        double longitude3 = 60;
-
-        // update location and receive broadcast.
-        registerIntentReceiver();
-        mManager.requestLocationUpdates(TEST_MOCK_PROVIDER_NAME, 0, 0, mPendingIntent);
-        updateLocation(latitude1, longitude1);
-        waitForReceiveBroadcast();
-
-        assertNotNull(mIntentReceiver.getLastReceivedIntent());
-        Location location = mManager.getLastKnownLocation(TEST_MOCK_PROVIDER_NAME);
-        assertEquals(TEST_MOCK_PROVIDER_NAME, location.getProvider());
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertEquals(true, location.isFromMockProvider());
-
-        // Any further location change doesn't trigger an update.
-        updateLocation(latitude2, longitude2);
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-
-        // update location without receiving broadcast.
-        mManager.removeUpdates(mPendingIntent);
-        mIntentReceiver.clearReceivedIntents();
-        updateLocation(latitude3, longitude3);
-        waitForReceiveBroadcast();
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-
-        try {
-            mManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
-                    (PendingIntent) null);
-            fail("Should throw IllegalArgumentException if param intent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.requestLocationUpdates(null, 0, 0, mPendingIntent);
-            fail("Should throw IllegalArgumentException if param provider is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-
-        try {
-            mManager.removeUpdates( (PendingIntent) null );
-            fail("Should throw IllegalArgumentException if intent is null!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
-    }
-
-    public void testAddProximityAlert() {
-        Intent i = new Intent();
-        i.setAction("android.location.cts.TEST_GET_GPS_STATUS_ACTION");
-        PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_ONE_SHOT);
-
-        mManager.addProximityAlert(0, 0, 1.0f, 5000, pi);
-        mManager.removeProximityAlert(pi);
-    }
-
-    @UiThreadTest
-    public void testNmeaListener() {
-        MockGnssNmeaListener gnssListener = new MockGnssNmeaListener();
-        mManager.addNmeaListener(gnssListener);
-        mManager.removeNmeaListener(gnssListener);
-
-        HandlerThread handlerThread = new HandlerThread("testNmeaListener");
-        handlerThread.start();
-        mManager.addNmeaListener(gnssListener, new Handler(handlerThread.getLooper()));
-        mManager.removeNmeaListener(gnssListener);
-
-        mManager.addNmeaListener((OnNmeaMessageListener) null);
-        mManager.removeNmeaListener((OnNmeaMessageListener) null);
+    public void testIsLocationEnabled() {
+        assertTrue(mManager.isLocationEnabled());
     }
 
     public void testIsProviderEnabled() {
-        // this test assumes enabled TEST_MOCK_PROVIDER_NAME was created in setUp.
-        assertNotNull(mManager.getProvider(TEST_MOCK_PROVIDER_NAME));
-        assertTrue(mManager.isProviderEnabled(TEST_MOCK_PROVIDER_NAME));
+        assertTrue(mManager.isProviderEnabled(TEST_PROVIDER));
 
-        mManager.clearTestProviderEnabled(TEST_MOCK_PROVIDER_NAME);
-        assertFalse(mManager.isProviderEnabled(TEST_MOCK_PROVIDER_NAME));
+        mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+        assertFalse(mManager.isProviderEnabled(TEST_PROVIDER));
 
-        mManager.setTestProviderEnabled(TEST_MOCK_PROVIDER_NAME, true);
-        assertTrue(mManager.isProviderEnabled(TEST_MOCK_PROVIDER_NAME));
+        mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+        assertTrue(mManager.isProviderEnabled(TEST_PROVIDER));
 
         try {
             mManager.isProviderEnabled(null);
@@ -867,43 +170,20 @@
         } catch (IllegalArgumentException e) {
             // expected
         }
-
-        try {
-            mManager.setTestProviderEnabled(UNKNOWN_PROVIDER_NAME, false);
-            fail("Should throw IllegalArgumentException if provider is unknown!");
-        } catch (IllegalArgumentException e) {
-            // expected
-        }
     }
 
-    public void testGetLastKnownLocation() throws InterruptedException {
-        double latitude1 = 20;
-        double longitude1 = 40;
-        double latitude2 = 10;
-        double longitude2 = 70;
+    public void testGetLastKnownLocation() {
+        Location loc1 = createLocation(TEST_PROVIDER, 6, 5);
+        Location loc2 = createLocation(TEST_PROVIDER, 10, 7);
 
-        registerIntentReceiver();
-        mManager.requestLocationUpdates(TEST_MOCK_PROVIDER_NAME, 0, 0, mPendingIntent);
-        updateLocation(latitude1, longitude1);
-        waitForReceiveBroadcast();
+        mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+        assertLocationEquals(loc1, mManager.getLastKnownLocation(TEST_PROVIDER));
 
-        assertNotNull(mIntentReceiver.getLastReceivedIntent());
-        Location location = mManager.getLastKnownLocation(TEST_MOCK_PROVIDER_NAME);
-        assertEquals(TEST_MOCK_PROVIDER_NAME, location.getProvider());
-        assertEquals(latitude1, location.getLatitude());
-        assertEquals(longitude1, location.getLongitude());
-        assertEquals(true, location.isFromMockProvider());
+        mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+        assertLocationEquals(loc2, mManager.getLastKnownLocation(TEST_PROVIDER));
 
-        mIntentReceiver.clearReceivedIntents();
-        updateLocation(latitude2, longitude2);
-        waitForReceiveBroadcast();
-
-        assertNotNull(mIntentReceiver.getLastReceivedIntent());
-        location = mManager.getLastKnownLocation(TEST_MOCK_PROVIDER_NAME);
-        assertEquals(TEST_MOCK_PROVIDER_NAME, location.getProvider());
-        assertEquals(latitude2, location.getLatitude());
-        assertEquals(longitude2, location.getLongitude());
-        assertEquals(true, location.isFromMockProvider());
+        mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+        assertNull(mManager.getLastKnownLocation(TEST_PROVIDER));
 
         try {
             mManager.getLastKnownLocation(null);
@@ -913,462 +193,984 @@
         }
     }
 
-    /**
-     * Test case for bug 33091107, where a malicious app used to be able to fool a real provider
-     * into providing a mock location that isn't marked as being mock.
-     */
-    public void testLocationShouldStillBeMarkedMockWhenProvidersDoNotMatch()
-            throws InterruptedException {
-        double latitude = 20;
-        double longitude = 40;
+    public void testGetCurrentLocation() throws Exception {
+        Location loc = createLocation(TEST_PROVIDER, 5, 6);
 
-        List<String> providers = mManager.getAllProviders();
-        if (providers.isEmpty()) {
-            // Device doesn't have any providers. Can't perform this test, and no need to do so:
-            // no providers that malicious app could fool
-            return;
+        try (GetCurrentLocationCapture capture = new GetCurrentLocationCapture()) {
+            mManager.getCurrentLocation(TEST_PROVIDER, capture.getCancellationSignal(),
+                    Executors.newSingleThreadExecutor(), capture);
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc);
+            assertLocationEquals(loc, capture.getNextLocation(TIMEOUT_MS));
         }
-        String realProviderToFool = providers.get(0);
 
-        // Register for location updates, then set a mock location and ensure it is marked "mock"
-        updateLocationAndWait(TEST_MOCK_PROVIDER_NAME, realProviderToFool, latitude, longitude);
-    }
+        // TODO: test timeout case
 
-    @UiThreadTest
-    public void testGnssStatusListener() {
-        MockGnssStatusCallback callback = new MockGnssStatusCallback();
-        mManager.registerGnssStatusCallback(callback);
-        mManager.unregisterGnssStatusCallback(callback);
-
-        mManager.registerGnssStatusCallback(null);
-        mManager.unregisterGnssStatusCallback(null);
-
-        HandlerThread handlerThread = new HandlerThread("testStatusUpdates");
-        handlerThread.start();
-
-        mManager.registerGnssStatusCallback(callback, new Handler(handlerThread.getLooper()));
-        mManager.unregisterGnssStatusCallback(callback);
-    }
-
-    /**
-     * Tests basic proximity alert when entering proximity
-     */
-    public void testEnterProximity() throws Exception {
-        if (!isSystemUser()) {
-            Log.i(TAG, "Skipping test on secondary user");
-            return;
-        }
-        // need to mock the fused location provider for proximity tests
-        mockFusedLocation();
-
-        doTestEnterProximity(10000);
-
-        unmockFusedLocation();
-    }
-
-    /**
-     * Tests proximity alert when entering proximity, with no expiration
-     */
-    public void testEnterProximity_noexpire() throws Exception {
-        if (!isSystemUser()) {
-            Log.i(TAG, "Skipping test on secondary user");
-            return;
-        }
-        // need to mock the fused location provider for proximity tests
-        mockFusedLocation();
-
-        doTestEnterProximity(-1);
-
-        unmockFusedLocation();
-    }
-
-    /**
-     * Tests basic proximity alert when exiting proximity
-     */
-    public void testExitProximity() throws Exception {
-        if (!isSystemUser()) {
-            Log.i(TAG, "Skipping test on secondary user");
-            return;
-        }
-        // need to mock the fused location provider for proximity tests
-        mockFusedLocation();
-
-        // first do enter proximity scenario
-        doTestEnterProximity(-1);
-
-        // now update to trigger exit proximity proximity
-        mIntentReceiver.clearReceivedIntents();
-        updateLocationAndWait(FUSED_PROVIDER_NAME, 20, 20);
-        waitForReceiveBroadcast();
-        assertProximityType(false);
-
-        unmockFusedLocation();
-    }
-
-    /**
-     * Tests basic proximity alert when initially within proximity
-     */
-    public void testInitiallyWithinProximity() throws Exception {
-        if (!isSystemUser()) {
-            Log.i(TAG, "Skipping test on secondary user");
-            return;
-        }
-        // need to mock the fused location provider for proximity tests
-        mockFusedLocation();
-
-        updateLocationAndWait(FUSED_PROVIDER_NAME, 0, 0);
-        registerProximityListener(0, 0, 1000, 10000);
-        waitForReceiveBroadcast();
-        assertProximityType(true);
-
-        unmockFusedLocation();
-    }
-
-    /**
-     * Helper variant for testing enter proximity scenario
-     * TODO: add additional parameters as more scenarios are added
-     *
-     * @param expiration - expiration of proximity alert
-     */
-    private void doTestEnterProximity(long expiration) throws Exception {
-        // update location to outside proximity range
-        updateLocationAndWait(FUSED_PROVIDER_NAME, 30, 30);
-        registerProximityListener(0, 0, 1000, expiration);
-
-        // Adding geofences is asynchronous, the return of LocationManager.addProximityAlert
-        // doesn't mean that geofences are already being monitored. Wait for a few milliseconds
-        // so that GeofenceManager is actively monitoring locations before we send the mock
-        // location to avoid flaky tests.
-        Thread.sleep(500);
-
-        updateLocationAndWait(FUSED_PROVIDER_NAME, 0, 0);
-        waitForReceiveBroadcast();
-        assertProximityType(true);
-    }
-
-
-    private void updateLocationAndWait(String providerName, double latitude, double longitude)
-            throws InterruptedException {
-        updateLocationAndWait(providerName, providerName, latitude, longitude);
-    }
-
-    /**
-     * Like {@link #updateLocationAndWait(String, double, double)}, but allows inconsistent providers
-     * to be used in the calls to {@link Location#Location(String)} and {@link
-     * LocationManager#setTestProviderLocation(String, Location)}
-     *
-     * @param testProviderName used in {@link LocationManager#setTestProviderLocation(String,
-     * Location)}
-     * @param locationProviderName used in {@link Location#Location(String)}
-     */
-    private void updateLocationAndWait(String testProviderName, String locationProviderName,
-        double latitude, double longitude) throws InterruptedException {
-
-        // Register a listener for the location we are about to set.
-        MockLocationListener listener = new MockLocationListener();
-        HandlerThread handlerThread = new HandlerThread("updateLocationAndWait");
-        handlerThread.start();
-        mManager.requestLocationUpdates(locationProviderName, 0, 0, listener,
-                handlerThread.getLooper());
-
-        // Set the location.
-        updateLocation(testProviderName, locationProviderName, latitude, longitude);
-
-        // Make sure we received the location, and it is the right one.
-        assertTrue("Listener not called", listener.hasCalledOnLocationChanged(TEST_TIME_OUT));
-        Location location = listener.getLocation();
-        assertEquals("Bad provider name", locationProviderName, location.getProvider());
-        assertEquals("Bad latitude", latitude, location.getLatitude());
-        assertEquals("Bad longitude", longitude, location.getLongitude());
-        assertTrue("Bad isMock", location.isFromMockProvider());
-
-        // Remove the listener.
-        mManager.removeUpdates(listener);
-    }
-
-    private void registerIntentReceiver() {
-        String intentKey = "LocationManagerTest";
-        Intent proximityIntent = new Intent(intentKey);
-        mPendingIntent = PendingIntent.getBroadcast(mContext, 0, proximityIntent,
-                PendingIntent.FLAG_CANCEL_CURRENT);
-        mIntentReceiver = new TestIntentReceiver(intentKey);
-        mContext.registerReceiver(mIntentReceiver, mIntentReceiver.getFilter());
-    }
-
-    /**
-     * Registers the proximity intent receiver
-     */
-    private void registerProximityListener(double latitude, double longitude, float radius,
-            long expiration) {
-        registerIntentReceiver();
-        mManager.addProximityAlert(latitude, longitude, radius, expiration, mPendingIntent);
-    }
-
-    /**
-     * Blocks until receive intent notification or time out.
-     *
-     * @throws InterruptedException
-     */
-    private void waitForReceiveBroadcast() throws InterruptedException {
-        synchronized (mIntentReceiver) {
-            mIntentReceiver.wait(TEST_TIME_OUT);
+        try {
+            mManager.getCurrentLocation((String) null, null, Executors.newSingleThreadExecutor(),
+                    (location) -> {
+                    });
+            fail("Should throw IllegalArgumentException if provider is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
         }
     }
 
-    /**
-     * Asserts that the received intent had the enter proximity property set as
-     * expected
-     *
-     * @param expectedEnterProximity - true if enter proximity expected, false
-     *            if exit expected
-     */
-    private void assertProximityType(boolean expectedEnterProximity) throws Exception {
-        Intent intent = mIntentReceiver.getLastReceivedIntent();
-        assertNotNull("Did not receive any intent", intent);
-        boolean proximityTest = intent.getBooleanExtra(
-                LocationManager.KEY_PROXIMITY_ENTERING, !expectedEnterProximity);
-        assertEquals("proximity alert not set to expected enter proximity value",
-                expectedEnterProximity, proximityTest);
+    public void testGetCurrentLocation_DirectExecutor() throws Exception {
+        Location loc = createLocation(TEST_PROVIDER, 2, 1);
+
+        try (GetCurrentLocationCapture capture = new GetCurrentLocationCapture()) {
+            mManager.getCurrentLocation(TEST_PROVIDER, capture.getCancellationSignal(),
+                    directExecutor(), capture);
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc);
+            assertLocationEquals(loc, capture.getNextLocation(TIMEOUT_MS));
+        }
     }
 
-    private void updateLocation(final String providerName, final double latitude,
-            final double longitude) {
-        updateLocation(providerName, providerName, latitude, longitude);
+    public void testGetCurrentLocation_Cancellation() throws Exception {
+        Location loc = createLocation(TEST_PROVIDER, 1, 2);
+
+        try (GetCurrentLocationCapture capture = new GetCurrentLocationCapture()) {
+            mManager.getCurrentLocation(TEST_PROVIDER, capture.getCancellationSignal(),
+                    directExecutor(),
+                    capture);
+            capture.getCancellationSignal().cancel();
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+        }
     }
 
-    /**
-     * Like {@link #updateLocation(String, double, double)}, but allows inconsistent providers to be
-     * used in the calls to {@link Location#Location(String)} and
-     * {@link LocationManager#setTestProviderLocation(String, Location)}.
-     */
-    private void updateLocation(String testProviderName, String locationProviderName,
-        double latitude, double longitude) {
-        Location location = new Location(locationProviderName);
-        location.setLatitude(latitude);
-        location.setLongitude(longitude);
-        location.setAccuracy(1.0f);
-        location.setTime(System.currentTimeMillis());
-        location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
-        mManager.setTestProviderLocation(testProviderName, location);
+    public void testGetCurrentLocation_ProviderDisabled() throws Exception {
+        try (GetCurrentLocationCapture capture = new GetCurrentLocationCapture()) {
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            mManager.getCurrentLocation(TEST_PROVIDER, capture.getCancellationSignal(),
+                    directExecutor(),
+                    capture);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+        }
+
+        try (GetCurrentLocationCapture capture = new GetCurrentLocationCapture()) {
+            mManager.getCurrentLocation(TEST_PROVIDER, capture.getCancellationSignal(),
+                    directExecutor(),
+                    capture);
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+        }
     }
 
-    private void updateLocation(final double latitude, final double longitude) {
-        updateLocation(TEST_MOCK_PROVIDER_NAME, latitude, longitude);
+    public void testRequestLocationUpdates() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 1, 4);
+        Location loc2 = createLocation(TEST_PROVIDER, 2, 5);
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0,
+                    Executors.newSingleThreadExecutor(), capture);
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertLocationEquals(loc2, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertEquals(Boolean.FALSE, capture.getNextProviderChange(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+            assertEquals(Boolean.TRUE, capture.getNextProviderChange(TIMEOUT_MS));
+
+            mManager.removeUpdates(capture);
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertNull(capture.getNextProviderChange(FAILURE_TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+            assertNull(capture.getNextProviderChange(FAILURE_TIMEOUT_MS));
+        }
+
+        try {
+            mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0, (LocationListener) null);
+            fail("Should throw IllegalArgumentException if listener is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0, null, capture);
+            fail("Should throw IllegalArgumentException if executor is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(null, 0, 0, capture);
+            fail("Should throw IllegalArgumentException if provider is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            mManager.removeUpdates((LocationListener) null);
+            fail("Should throw IllegalArgumentException if listener is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
     }
 
-    private void updateFusedLocation(final double latitude, final double longitude) {
-      updateLocation(FUSED_PROVIDER_NAME, latitude, longitude);
- }
+    public void testRequestLocationUpdates_PendingIntent() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 1, 4);
+        Location loc2 = createLocation(TEST_PROVIDER, 2, 5);
 
-    private Criteria createLocationCriteria() {
+        try (LocationPendingIntentCapture capture = new LocationPendingIntentCapture(mContext)) {
+            mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0, capture.getPendingIntent());
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertLocationEquals(loc2, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertEquals(Boolean.FALSE, capture.getNextProviderChange(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+            assertEquals(Boolean.TRUE, capture.getNextProviderChange(TIMEOUT_MS));
+
+            mManager.removeUpdates(capture.getPendingIntent());
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertNull(capture.getNextProviderChange(FAILURE_TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+            assertNull(capture.getNextProviderChange(FAILURE_TIMEOUT_MS));
+        }
+
+        try {
+            mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0, (PendingIntent) null);
+            fail("Should throw IllegalArgumentException if pending intent is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try (LocationPendingIntentCapture capture = new LocationPendingIntentCapture(mContext)) {
+            mManager.requestLocationUpdates(null, 0, 0, capture.getPendingIntent());
+            fail("Should throw IllegalArgumentException if provider is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            mManager.removeUpdates((PendingIntent) null);
+            fail("Should throw IllegalArgumentException if pending intent is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testRequestLocationUpdates_DirectExecutor() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 1, 4);
+        Location loc2 = createLocation(TEST_PROVIDER, 2, 5);
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0, directExecutor(), capture);
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertLocationEquals(loc2, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertEquals(Boolean.FALSE, capture.getNextProviderChange(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+            assertEquals(Boolean.TRUE, capture.getNextProviderChange(TIMEOUT_MS));
+        }
+    }
+
+    public void testRequestLocationUpdates_Looper() throws Exception {
+        HandlerThread thread = new HandlerThread("locationTestThread");
+        thread.start();
+        Looper looper = thread.getLooper();
+        try {
+
+            Location loc1 = createLocation(TEST_PROVIDER, 1, 4);
+            Location loc2 = createLocation(TEST_PROVIDER, 2, 5);
+
+            try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+                mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0, capture, looper);
+
+                mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+                assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+                mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+                assertLocationEquals(loc2, capture.getNextLocation(TIMEOUT_MS));
+                mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+                assertEquals(Boolean.FALSE, capture.getNextProviderChange(TIMEOUT_MS));
+                mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+                assertEquals(Boolean.TRUE, capture.getNextProviderChange(TIMEOUT_MS));
+            }
+
+        } finally {
+            looper.quit();
+        }
+    }
+
+    public void testRequestLocationUpdates_Criteria() throws Exception {
+        // make the test provider the "perfect" provider
+        mManager.addTestProvider(TEST_PROVIDER,
+                false,
+                false,
+                false,
+                false,
+                true,
+                true,
+                true,
+                Criteria.POWER_LOW,
+                Criteria.ACCURACY_FINE);
+
         Criteria criteria = new Criteria();
         criteria.setAccuracy(Criteria.ACCURACY_FINE);
-        criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
-        criteria.setAltitudeRequired(false);
-        criteria.setBearingRequired(false);
-        criteria.setCostAllowed(false);
-        criteria.setSpeedRequired(false);
-        return criteria;
-     }
+        criteria.setPowerRequirement(Criteria.POWER_LOW);
 
-    private void mockFusedLocation() {
-        addTestProvider(FUSED_PROVIDER_NAME);
-    }
+        Location loc1 = createLocation(TEST_PROVIDER, 1, 4);
+        Location loc2 = createLocation(TEST_PROVIDER, 2, 5);
 
-    private void unmockFusedLocation() {
-        mManager.removeTestProvider(FUSED_PROVIDER_NAME);
-    }
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(0, 0, criteria, directExecutor(), capture);
 
-    /**
-     * Helper class that receives a proximity intent and notifies the main class
-     * when received
-     */
-    private static class TestIntentReceiver extends BroadcastReceiver {
-        private String mExpectedAction;
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertLocationEquals(loc2, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertEquals(Boolean.FALSE, capture.getNextProviderChange(TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+            assertEquals(Boolean.TRUE, capture.getNextProviderChange(TIMEOUT_MS));
 
-        private Intent mLastReceivedIntent;
+            mManager.removeUpdates(capture);
 
-        public TestIntentReceiver(String expectedAction) {
-            mExpectedAction = expectedAction;
-            mLastReceivedIntent = null;
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+            assertNull(capture.getNextProviderChange(FAILURE_TIMEOUT_MS));
+            mManager.setTestProviderEnabled(TEST_PROVIDER, true);
+            assertNull(capture.getNextProviderChange(FAILURE_TIMEOUT_MS));
         }
 
-        public IntentFilter getFilter() {
-            IntentFilter filter = new IntentFilter(mExpectedAction);
-            return filter;
+
+        try {
+            mManager.requestLocationUpdates(0, 0, criteria, null, Looper.getMainLooper());
+            fail("Should throw IllegalArgumentException if listener is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(0, 0, criteria, null, capture);
+            fail("Should throw IllegalArgumentException if executor is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(0, 0, null, directExecutor(), capture);
+            fail("Should throw IllegalArgumentException if criteria is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testRequestLocationUpdates_ReplaceRequest() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 1, 4);
+        Location loc2 = createLocation(TEST_PROVIDER, 2, 5);
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(TEST_PROVIDER, 1000, 1000, directExecutor(), capture);
+            mManager.requestLocationUpdates(TEST_PROVIDER, 0, 0, directExecutor(), capture);
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertLocationEquals(loc2, capture.getNextLocation(TIMEOUT_MS));
+        }
+    }
+
+    public void testRequestLocationUpdates_NumUpdates() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 10, 3);
+        Location loc2 = createLocation(TEST_PROVIDER, 2, 8);
+
+        LocationRequest request = LocationRequest.createFromDeprecatedProvider(TEST_PROVIDER, 0, 0,
+                false);
+        request.setNumUpdates(1);
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(request, directExecutor(), capture);
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+        }
+    }
+
+    public void testRequestLocationUpdates_MinTime() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 0, 0);
+        Location loc2 = createLocation(TEST_PROVIDER, 1, 1);
+
+        LocationRequest request = LocationRequest.createFromDeprecatedProvider(TEST_PROVIDER, 5000,
+                0, false);
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(request, directExecutor(), capture);
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+        }
+    }
+
+    public void testRequestLocationUpdates_MinDistance() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 0, 0);
+        Location loc2 = createLocation(TEST_PROVIDER, 0, 1);
+
+        LocationRequest request = LocationRequest.createFromDeprecatedProvider(TEST_PROVIDER, 0,
+                10000, false);
+
+        try (LocationListenerCapture capture = new LocationListenerCapture(mManager)) {
+            mManager.requestLocationUpdates(request, directExecutor(), capture);
+
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            assertLocationEquals(loc1, capture.getNextLocation(TIMEOUT_MS));
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc2);
+            assertNull(capture.getNextLocation(FAILURE_TIMEOUT_MS));
+        }
+    }
+
+    public void testGetAllProviders() {
+        List<String> providers = mManager.getAllProviders();
+        if (hasGpsFeature()) {
+            assertTrue(providers.contains(LocationManager.GPS_PROVIDER));
+        }
+        assertTrue(providers.contains(PASSIVE_PROVIDER));
+        assertTrue(providers.contains(TEST_PROVIDER));
+
+        mManager.removeTestProvider(TEST_PROVIDER);
+
+        providers = mManager.getAllProviders();
+        assertTrue(providers.contains(PASSIVE_PROVIDER));
+        assertFalse(providers.contains(TEST_PROVIDER));
+    }
+
+    public void testGetProviders() {
+        List<String> providers = mManager.getProviders(false);
+        assertTrue(providers.contains(TEST_PROVIDER));
+
+        providers = mManager.getProviders(true);
+        assertTrue(providers.contains(TEST_PROVIDER));
+
+        mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+
+        providers = mManager.getProviders(false);
+        assertTrue(providers.contains(TEST_PROVIDER));
+
+        providers = mManager.getProviders(true);
+        assertFalse(providers.contains(TEST_PROVIDER));
+    }
+
+    public void testGetProviders_Criteria() {
+        Criteria criteria = new Criteria();
+
+        List<String> providers = mManager.getProviders(criteria, false);
+        assertTrue(providers.contains(TEST_PROVIDER));
+
+        providers = mManager.getProviders(criteria, true);
+        assertTrue(providers.contains(TEST_PROVIDER));
+
+        criteria.setPowerRequirement(Criteria.POWER_LOW);
+
+        providers = mManager.getProviders(criteria, false);
+        assertFalse(providers.contains(TEST_PROVIDER));
+
+        providers = mManager.getProviders(criteria, true);
+        assertFalse(providers.contains(TEST_PROVIDER));
+    }
+
+    public void testGetBestProvider() {
+        List<String> allProviders = mManager.getAllProviders();
+        Criteria criteria = new Criteria();
+
+        String bestProvider = mManager.getBestProvider(criteria, false);
+        if (allProviders.contains(GPS_PROVIDER)) {
+            assertEquals(GPS_PROVIDER, bestProvider);
+        } else if (allProviders.contains(NETWORK_PROVIDER)) {
+            assertEquals(NETWORK_PROVIDER, bestProvider);
+        } else {
+            assertEquals(TEST_PROVIDER, bestProvider);
+        }
+
+        // the "perfect" provider - this test case only works if there is no real provider on the
+        // device with the same "perfect" properties
+        mManager.addTestProvider(TEST_PROVIDER,
+                false,
+                false,
+                false,
+                false,
+                true,
+                true,
+                true,
+                Criteria.POWER_LOW,
+                Criteria.ACCURACY_FINE);
+
+        criteria.setAccuracy(Criteria.ACCURACY_FINE);
+        criteria.setPowerRequirement(Criteria.POWER_LOW);
+        assertEquals(TEST_PROVIDER, mManager.getBestProvider(criteria, false));
+
+        mManager.setTestProviderEnabled(TEST_PROVIDER, false);
+        assertNotEquals(TEST_PROVIDER, mManager.getBestProvider(criteria, true));
+    }
+
+    public void testGetProvider() {
+        LocationProvider provider = mManager.getProvider(TEST_PROVIDER);
+        assertNotNull(provider);
+        assertEquals(TEST_PROVIDER, provider.getName());
+
+        provider = mManager.getProvider(LocationManager.GPS_PROVIDER);
+        if (hasGpsFeature()) {
+            assertNotNull(provider);
+            assertEquals(LocationManager.GPS_PROVIDER, provider.getName());
+        } else {
+            assertNull(provider);
+        }
+
+        try {
+            mManager.getProvider(null);
+            fail("Should throw IllegalArgumentException when provider is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testSendExtraCommand() {
+        for (String provider : mManager.getAllProviders()) {
+            boolean res = mManager.sendExtraCommand(provider, "dontCrash", null);
+            assertTrue(res);
+
+            try {
+                mManager.sendExtraCommand(provider, null, null);
+                fail("Should throw IllegalArgumentException if command is null!");
+            } catch (IllegalArgumentException e) {
+                // expected
+            }
+        }
+
+        try {
+            mManager.sendExtraCommand(null, "crash", null);
+            fail("Should throw IllegalArgumentException if provider is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testAddTestProvider() {
+        // overwriting providers should not crash
+        for (String provider : mManager.getAllProviders()) {
+            if (PASSIVE_PROVIDER.equals(provider)) {
+                continue;
+            }
+
+            mManager.addTestProvider(provider, true,
+                    false,
+                    true,
+                    false,
+                    false,
+                    false,
+                    false,
+                    Criteria.POWER_MEDIUM,
+                    Criteria.ACCURACY_FINE);
+            mManager.setTestProviderLocation(provider, createLocation(provider, 0, 0));
+        }
+
+        try {
+            mManager.addTestProvider("passive",
+                    true,
+                    false,
+                    true,
+                    false,
+                    false,
+                    false,
+                    false,
+                    Criteria.POWER_MEDIUM,
+                    Criteria.ACCURACY_FINE);
+            fail("Should throw IllegalArgumentException if provider is passive!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            mManager.addTestProvider(null,
+                    true,
+                    false,
+                    true,
+                    false,
+                    false,
+                    false,
+                    false,
+                    Criteria.POWER_MEDIUM,
+                    Criteria.ACCURACY_FINE);
+            fail("Should throw IllegalArgumentException if provider is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testSetTestProviderLocation() throws Exception {
+        Location loc1 = createLocation(TEST_PROVIDER, 1, 2);
+        Location loc2 = createLocation(TEST_PROVIDER, 2, 1);
+
+        for (String provider : mManager.getAllProviders()) {
+            if (TEST_PROVIDER.equals(provider)) {
+                try (GetCurrentLocationCapture capture = new GetCurrentLocationCapture()) {
+                    mManager.getCurrentLocation(provider, capture.getCancellationSignal(),
+                            directExecutor(), capture);
+                    mManager.setTestProviderLocation(provider, loc1);
+
+                    Location received = capture.getNextLocation(TIMEOUT_MS);
+                    assertLocationEquals(loc1, received);
+                    assertTrue(received.isFromMockProvider());
+                    assertLocationEquals(loc1, mManager.getLastKnownLocation(provider));
+
+                    mManager.setTestProviderEnabled(provider, false);
+                    mManager.setTestProviderLocation(provider, loc2);
+                    assertNull(mManager.getLastKnownLocation(provider));
+                }
+            } else {
+                try {
+                    mManager.setTestProviderLocation(provider, loc1);
+                    fail("Should throw IllegalArgumentException since " + provider
+                            + " is not a test provider!");
+                } catch (IllegalArgumentException e) {
+                    // expected
+                }
+            }
+        }
+
+        try {
+            mManager.setTestProviderLocation(TEST_PROVIDER, null);
+            fail("Should throw IllegalArgumentException since location is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        mManager.removeTestProvider(TEST_PROVIDER);
+        try {
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc1);
+            fail("Should throw IllegalArgumentException since " + TEST_PROVIDER
+                    + " is not a test provider!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            mManager.setTestProviderLocation(null, loc1);
+            fail("Should throw IllegalArgumentException since provider is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testSetTestProviderLocation_B33091107() throws Exception {
+        // test for b/33091107, where a malicious app could fool a real provider into providing a
+        // mock location that isn't marked as being mock
+
+        List<String> providers = mManager.getAllProviders();
+        if (providers.size() <= 2) {
+            // can't perform the test without any real providers, and no need to do so since there
+            // are no providers a malicious app could fool
+            assertTrue(providers.contains(TEST_PROVIDER));
+            assertTrue(providers.contains(PASSIVE_PROVIDER));
+            return;
+        }
+
+        providers.remove(TEST_PROVIDER);
+        providers.remove(PASSIVE_PROVIDER);
+
+        String realProvider = providers.get(0);
+        Location loc = createLocation(realProvider, 2, 2);
+
+        try (GetCurrentLocationCapture capture = new GetCurrentLocationCapture()) {
+            mManager.getCurrentLocation(TEST_PROVIDER, capture.getCancellationSignal(),
+                    directExecutor(), capture);
+            mManager.setTestProviderLocation(TEST_PROVIDER, loc);
+
+            Location received = capture.getNextLocation(TIMEOUT_MS);
+            assertLocationEquals(loc, received);
+            assertTrue(received.isFromMockProvider());
+
+            Location realProvideLocation = mManager.getLastKnownLocation(realProvider);
+            if (realProvideLocation != null) {
+                try {
+                    assertLocationEquals(loc, realProvideLocation);
+                    fail("real provider saw " + TEST_PROVIDER + " location!");
+                } catch (AssertionError e) {
+                    // pass
+                }
+            }
+        }
+    }
+
+    public void testRemoveTestProvider() {
+        // removing providers should not crash
+        for (String provider : mManager.getAllProviders()) {
+            mManager.removeTestProvider(provider);
+        }
+    }
+
+    public void testAddProximityAlert() throws Exception {
+        if (isNotSystemUser()) {
+            Log.i(TAG, "Skipping test on secondary user");
+            return;
+        }
+
+        mManager.addTestProvider(FUSED_PROVIDER,
+                true,
+                false,
+                true,
+                false,
+                false,
+                false,
+                false,
+                Criteria.POWER_MEDIUM,
+                Criteria.ACCURACY_FINE);
+        mManager.setTestProviderEnabled(FUSED_PROVIDER, true);
+        mManager.setTestProviderLocation(FUSED_PROVIDER, createLocation(FUSED_PROVIDER, 30, 30));
+
+        try (ProximityPendingIntentCapture capture = new ProximityPendingIntentCapture(mContext)) {
+            mManager.addProximityAlert(0, 0, 1000, -1, capture.getPendingIntent());
+
+            // adding a proximity alert is asynchronous for no good reason, so we have to wait and
+            // hope the alert is added in the mean time.
+            Thread.sleep(500);
+
+            mManager.setTestProviderLocation(FUSED_PROVIDER, createLocation(FUSED_PROVIDER, 0, 0));
+            assertEquals(Boolean.TRUE, capture.getNextProximityChange(TIMEOUT_MS));
+
+            mManager.setTestProviderLocation(FUSED_PROVIDER,
+                    createLocation(FUSED_PROVIDER, 30, 30));
+            assertEquals(Boolean.FALSE, capture.getNextProximityChange(TIMEOUT_MS));
+        }
+
+        try {
+            mManager.addProximityAlert(0, 0, 1000, -1, null);
+            fail("Should throw IllegalArgumentException if pending intent is null!");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try (ProximityPendingIntentCapture capture = new ProximityPendingIntentCapture(mContext)) {
+            try {
+                mManager.addProximityAlert(0, 0, 0, -1, capture.getPendingIntent());
+                fail("Should throw IllegalArgumentException if radius == 0!");
+            } catch (IllegalArgumentException e) {
+                // expected
+            }
+
+            try {
+                mManager.addProximityAlert(0, 0, -1, -1, capture.getPendingIntent());
+                fail("Should throw IllegalArgumentException if radius < 0!");
+            } catch (IllegalArgumentException e) {
+                // expected
+            }
+
+            try {
+                mManager.addProximityAlert(1000, 1000, 1000, -1, capture.getPendingIntent());
+                fail("Should throw IllegalArgumentException if lat/lon are illegal!");
+            } catch (IllegalArgumentException e) {
+                // expected
+            }
+        }
+    }
+
+    public void testAddProximityAlert_StartProximate() throws Exception {
+        if (isNotSystemUser()) {
+            Log.i(TAG, "Skipping test on secondary user");
+            return;
+        }
+
+        mManager.addTestProvider(FUSED_PROVIDER,
+                true,
+                false,
+                true,
+                false,
+                false,
+                false,
+                false,
+                Criteria.POWER_MEDIUM,
+                Criteria.ACCURACY_FINE);
+        mManager.setTestProviderEnabled(FUSED_PROVIDER, true);
+        mManager.setTestProviderLocation(FUSED_PROVIDER, createLocation(FUSED_PROVIDER, 0, 0));
+
+        try (ProximityPendingIntentCapture capture = new ProximityPendingIntentCapture(mContext)) {
+            mManager.addProximityAlert(0, 0, 1000, -1, capture.getPendingIntent());
+            assertEquals(Boolean.TRUE, capture.getNextProximityChange(TIMEOUT_MS));
+        }
+    }
+
+    public void testAddProximityAlert_Expires() throws Exception {
+        if (isNotSystemUser()) {
+            Log.i(TAG, "Skipping test on secondary user");
+            return;
+        }
+
+        mManager.addTestProvider(FUSED_PROVIDER,
+                true,
+                false,
+                true,
+                false,
+                false,
+                false,
+                false,
+                Criteria.POWER_MEDIUM,
+                Criteria.ACCURACY_FINE);
+        mManager.setTestProviderEnabled(FUSED_PROVIDER, true);
+        mManager.setTestProviderLocation(FUSED_PROVIDER, createLocation(FUSED_PROVIDER, 30, 30));
+
+        try (ProximityPendingIntentCapture capture = new ProximityPendingIntentCapture(mContext)) {
+            mManager.addProximityAlert(0, 0, 1000, 1, capture.getPendingIntent());
+
+            // adding a proximity alert is asynchronous for no good reason, so we have to wait and
+            // hope the alert is added in the mean time.
+            Thread.sleep(500);
+
+            mManager.setTestProviderLocation(FUSED_PROVIDER, createLocation(FUSED_PROVIDER, 0, 0));
+            assertNull(capture.getNextProximityChange(FAILURE_TIMEOUT_MS));
+        }
+    }
+
+    public void testGetGnssYearOfHardware() {
+        mManager.getGnssYearOfHardware();
+    }
+
+    public void testGetGnssHardwareModelName() {
+        mManager.getGnssHardwareModelName();
+    }
+
+    public void testRegisterGnssStatusCallback() {
+        GnssStatus.Callback callback = new GnssStatus.Callback() {
+        };
+
+        mManager.registerGnssStatusCallback(directExecutor(), callback);
+        mManager.unregisterGnssStatusCallback(callback);
+    }
+
+    public void testAddNmeaListener() {
+        OnNmeaMessageListener listener = (message, timestamp) -> {
+        };
+
+        mManager.addNmeaListener(directExecutor(), listener);
+        mManager.removeNmeaListener(listener);
+    }
+
+    public void testRegisterGnssMeasurementsCallback() {
+        GnssMeasurementsEvent.Callback callback = new GnssMeasurementsEvent.Callback() {
+        };
+
+        mManager.registerGnssMeasurementsCallback(directExecutor(), callback);
+        mManager.unregisterGnssMeasurementsCallback(callback);
+    }
+
+    public void testRegisterGnssNavigationMessageCallback() {
+        GnssNavigationMessage.Callback callback = new GnssNavigationMessage.Callback() {
+        };
+
+        mManager.registerGnssNavigationMessageCallback(directExecutor(), callback);
+        mManager.unregisterGnssNavigationMessageCallback(callback);
+    }
+
+    private boolean hasGpsFeature() {
+        return mContext.getPackageManager().hasSystemFeature(
+                PackageManager.FEATURE_LOCATION_GPS);
+    }
+
+    private boolean isNotSystemUser() {
+        return !mContext.getSystemService(UserManager.class).isSystemUser();
+    }
+
+    private static class LocationListenerCapture implements LocationListener, AutoCloseable {
+
+        private final LocationManager mLocationManager;
+        private final LinkedBlockingQueue<Location> mLocations;
+        private final LinkedBlockingQueue<Boolean> mProviderChanges;
+
+        public LocationListenerCapture(LocationManager locationManager) {
+            mLocationManager = locationManager;
+            mLocations = new LinkedBlockingQueue<>();
+            mProviderChanges = new LinkedBlockingQueue<>();
+        }
+
+        public Location getNextLocation(long timeoutMs) throws InterruptedException {
+            return mLocations.poll(timeoutMs, TimeUnit.MILLISECONDS);
+        }
+
+        public Boolean getNextProviderChange(long timeoutMs) throws InterruptedException {
+            return mProviderChanges.poll(timeoutMs, TimeUnit.MILLISECONDS);
+        }
+
+        @Override
+        public void onLocationChanged(Location location) {
+            mLocations.add(location);
+        }
+
+        @Override
+        public void onStatusChanged(String provider, int status, Bundle extras) {
+        }
+
+        @Override
+        public void onProviderEnabled(String provider) {
+            mProviderChanges.add(true);
+        }
+
+        @Override
+        public void onProviderDisabled(String provider) {
+            mProviderChanges.add(false);
+        }
+
+        @Override
+        public void close() {
+            mLocationManager.removeUpdates(this);
+        }
+    }
+
+    private static class LocationPendingIntentCapture extends BroadcastReceiver implements
+            AutoCloseable {
+
+        private static final String ACTION = "android.location.cts.LOCATION_BROADCAST";
+        private static final AtomicInteger sRequestCode = new AtomicInteger(0);
+
+        private final Context mContext;
+        private final LocationManager mLocationManager;
+        private final PendingIntent mPendingIntent;
+        private final LinkedBlockingQueue<Location> mLocations;
+        private final LinkedBlockingQueue<Boolean> mProviderChanges;
+
+        public LocationPendingIntentCapture(Context context) {
+            mContext = context;
+            mLocationManager = context.getSystemService(LocationManager.class);
+            mPendingIntent = PendingIntent.getBroadcast(context, sRequestCode.getAndIncrement(),
+                    new Intent(ACTION).setPackage(context.getPackageName()),
+                    PendingIntent.FLAG_CANCEL_CURRENT);
+            mLocations = new LinkedBlockingQueue<>();
+            mProviderChanges = new LinkedBlockingQueue<>();
+
+            context.registerReceiver(this, new IntentFilter(ACTION));
+        }
+
+        public PendingIntent getPendingIntent() {
+            return mPendingIntent;
+        }
+
+        /**
+         * May not be called from the main thread. Tests do not run on the main thread so this
+         * generally shouldn't be a problem.
+         */
+        public Location getNextLocation(long timeoutMs) throws InterruptedException {
+            Preconditions.checkState(Looper.myLooper() != Looper.getMainLooper());
+            return mLocations.poll(timeoutMs, TimeUnit.MILLISECONDS);
+        }
+
+        /**
+         * May not be called from the main thread. Tests do not run on the main thread so this
+         * generally shouldn't be a problem.
+         */
+        public Boolean getNextProviderChange(long timeoutMs) throws InterruptedException {
+            Preconditions.checkState(Looper.myLooper() != Looper.getMainLooper());
+            return mProviderChanges.poll(timeoutMs, TimeUnit.MILLISECONDS);
+        }
+
+        @Override
+        public void close() {
+            mLocationManager.removeUpdates(mPendingIntent);
+            mContext.unregisterReceiver(this);
+            mPendingIntent.cancel();
         }
 
         @Override
         public void onReceive(Context context, Intent intent) {
-            if (intent != null && mExpectedAction.equals(intent.getAction())) {
-                synchronized (this) {
-                    mLastReceivedIntent = intent;
-                    notify();
-                }
+            if (intent.hasExtra(KEY_PROVIDER_ENABLED)) {
+                mProviderChanges.add(intent.getBooleanExtra(KEY_PROVIDER_ENABLED, false));
+            } else if (intent.hasExtra(KEY_LOCATION_CHANGED)) {
+                mLocations.add(intent.getParcelableExtra(KEY_LOCATION_CHANGED));
             }
         }
-
-        public Intent getLastReceivedIntent() {
-            return mLastReceivedIntent;
-        }
-
-        public void clearReceivedIntents() {
-            mLastReceivedIntent = null;
-        }
     }
 
-    private static class MockLocationListener implements LocationListener {
-        private String mProvider;
-        private int mStatus;
-        private Location mLocation;
-        private Object mStatusLock = new Object();
-        private Object mLocationLock = new Object();
-        private Object mLocationRequestLock = new Object();
+    private static class ProximityPendingIntentCapture extends BroadcastReceiver implements
+            AutoCloseable {
 
-        private boolean mHasCalledOnLocationChanged;
+        private static final String ACTION = "android.location.cts.LOCATION_BROADCAST";
+        private static final AtomicInteger sRequestCode = new AtomicInteger(0);
 
-        private boolean mHasCalledOnProviderDisabled;
+        private final Context mContext;
+        private final LocationManager mLocationManager;
+        private final PendingIntent mPendingIntent;
+        private final LinkedBlockingQueue<Boolean> mProximityChanges;
 
-        private boolean mHasCalledOnProviderEnabled;
+        public ProximityPendingIntentCapture(Context context) {
+            mContext = context;
+            mLocationManager = context.getSystemService(LocationManager.class);
+            mPendingIntent = PendingIntent.getBroadcast(context, sRequestCode.getAndIncrement(),
+                    new Intent(ACTION).setPackage(context.getPackageName()),
+                    PendingIntent.FLAG_CANCEL_CURRENT);
+            mProximityChanges = new LinkedBlockingQueue<>();
 
-        private boolean mHasCalledOnStatusChanged;
+            context.registerReceiver(this, new IntentFilter(ACTION));
+        }
 
-        private boolean mHasCalledRequestLocation;
-
-        public void reset(){
-            mHasCalledOnLocationChanged = false;
-            mHasCalledOnProviderDisabled = false;
-            mHasCalledOnProviderEnabled = false;
-            mHasCalledOnStatusChanged = false;
-            mHasCalledRequestLocation = false;
-            mProvider = null;
-            mStatus = 0;
+        public PendingIntent getPendingIntent() {
+            return mPendingIntent;
         }
 
         /**
-         * Call to inform listener that location has been updates have been requested
+         * May not be called from the main thread. Tests do not run on the main thread so this
+         * generally shouldn't be a problem.
          */
-        public void setLocationRequested() {
-            synchronized (mLocationRequestLock) {
-                mHasCalledRequestLocation = true;
-                mLocationRequestLock.notify();
-            }
+        public Boolean getNextProximityChange(long timeoutMs) throws InterruptedException {
+            Preconditions.checkState(Looper.myLooper() != Looper.getMainLooper());
+            return mProximityChanges.poll(timeoutMs, TimeUnit.MILLISECONDS);
         }
 
-        public boolean hasCalledLocationRequested(long timeout) throws InterruptedException {
-            synchronized (mLocationRequestLock) {
-                if (timeout > 0 && !mHasCalledRequestLocation) {
-                    mLocationRequestLock.wait(timeout);
-                }
-            }
-            return mHasCalledRequestLocation;
-        }
-
-        /**
-         * Check whether onLocationChanged() has been called. Wait up to timeout milliseconds
-         * for the callback.
-         * @param timeout Maximum time to wait for the callback, 0 to return immediately.
-         */
-        public boolean hasCalledOnLocationChanged(long timeout) throws InterruptedException {
-            synchronized (mLocationLock) {
-                if (timeout > 0 && !mHasCalledOnLocationChanged) {
-                    mLocationLock.wait(timeout);
-                }
-            }
-            return mHasCalledOnLocationChanged;
-        }
-
-        public boolean hasCalledOnProviderDisabled() {
-            return mHasCalledOnProviderDisabled;
-        }
-
-        public boolean hasCalledOnProviderEnabled() {
-            return mHasCalledOnProviderEnabled;
-        }
-
-        public boolean hasCalledOnStatusChanged(long timeout) throws InterruptedException {
-            synchronized(mStatusLock) {
-                // wait(0) would wait forever
-                if (timeout > 0 && !mHasCalledOnStatusChanged) {
-                    mStatusLock.wait(timeout);
-                }
-            }
-            return mHasCalledOnStatusChanged;
-        }
-
-        public void onLocationChanged(Location location) {
-            mLocation = location;
-            synchronized (mLocationLock) {
-                mHasCalledOnLocationChanged = true;
-                mLocationLock.notify();
-            }
-        }
-
-        public void onProviderDisabled(String provider) {
-            mHasCalledOnProviderDisabled = true;
-        }
-
-        public void onProviderEnabled(String provider) {
-            mHasCalledOnProviderEnabled = true;
-        }
-
-        public void onStatusChanged(String provider, int status, Bundle extras) {
-            mProvider = provider;
-            mStatus = status;
-            synchronized (mStatusLock) {
-                mHasCalledOnStatusChanged = true;
-                mStatusLock.notify();
-            }
-        }
-
-        public String getProvider() {
-            return mProvider;
-        }
-
-        public int getStatus() {
-            return mStatus;
-        }
-
-        public Location getLocation() {
-            return mLocation;
-        }
-    }
-
-    private static class MockGnssNmeaListener implements OnNmeaMessageListener {
-        private boolean mIsNmeaReceived;
-
         @Override
-        public void onNmeaMessage(String name, long timestamp) {
-            mIsNmeaReceived = true;
+        public void close() {
+            mLocationManager.removeProximityAlert(mPendingIntent);
+            mContext.unregisterReceiver(this);
+            mPendingIntent.cancel();
         }
 
-        public boolean isNmeaRecevied() {
-            return mIsNmeaReceived;
-        }
-
-        public void reset() {
-            mIsNmeaReceived = false;
-        }
-    }
-
-    private static class MockGnssStatusCallback extends GnssStatus.Callback {
         @Override
-        public void onSatelliteStatusChanged(GnssStatus status) {
-            for (int i = 0; i < status.getSatelliteCount(); ++i) {
-                status.getAzimuthDegrees(i);
-                status.getCn0DbHz(i);
-                status.getConstellationType(i);
-                status.getElevationDegrees(i);
-                status.getSvid(i);
-                status.hasAlmanacData(i);
-                status.hasEphemerisData(i);
-                status.usedInFix(i);
+        public void onReceive(Context context, Intent intent) {
+            if (intent.hasExtra(KEY_PROXIMITY_ENTERING)) {
+                mProximityChanges.add(intent.getBooleanExtra(KEY_PROXIMITY_ENTERING, false));
             }
         }
     }
 
-    private boolean isSystemUser() {
-        UserManager userManager = mContext.getSystemService(UserManager.class);
-        return userManager.isSystemUser();
+    private static class GetCurrentLocationCapture implements Consumer<Location>, AutoCloseable {
+
+        private final CancellationSignal mCancellationSignal;
+        private final LinkedBlockingQueue<Location> locations;
+
+        public GetCurrentLocationCapture() {
+            locations = new LinkedBlockingQueue<>();
+            mCancellationSignal = new CancellationSignal();
+        }
+
+        public CancellationSignal getCancellationSignal() {
+            return mCancellationSignal;
+        }
+
+        public Location getNextLocation(long timeoutMs) throws InterruptedException {
+            return locations.poll(timeoutMs, TimeUnit.MILLISECONDS);
+        }
+
+        @Override
+        public void accept(Location location) {
+            locations.add(location);
+        }
+
+        @Override
+        public void close() {
+            mCancellationSignal.cancel();
+        }
     }
 }
diff --git a/tests/tests/media/src/android/media/cts/AudioAttributesTest.java b/tests/tests/media/src/android/media/cts/AudioAttributesTest.java
index 0666efe..86642e1 100644
--- a/tests/tests/media/src/android/media/cts/AudioAttributesTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioAttributesTest.java
@@ -16,6 +16,8 @@
 
 package android.media.cts;
 
+import static org.testng.Assert.assertThrows;
+
 import android.media.AudioAttributes;
 import android.media.AudioManager;
 import android.os.Parcel;
@@ -80,6 +82,38 @@
         }
     }
 
+    // -----------------------------------------------------------------
+    // Builder tests
+    // ----------------------------------
+    public void testInvalidUsage() {
+        assertThrows(IllegalArgumentException.class,
+                () -> { new AudioAttributes.Builder()
+                        .setUsage(Integer.MIN_VALUE / 2) // some invalid value
+                        .build();
+                });
+    }
+
+    public void testInvalidContentType() {
+        assertThrows(IllegalArgumentException.class,
+                () -> {
+                    new AudioAttributes.Builder()
+                            .setContentType(Integer.MIN_VALUE / 2) // some invalid value
+                            .build();
+                } );
+    }
+
+    public void testDefaultUnknown() {
+        final AudioAttributes aa = new AudioAttributes.Builder()
+                .setFlags(AudioAttributes.ALLOW_CAPTURE_BY_ALL)
+                .build();
+        assertEquals("Unexpected default usage", AudioAttributes.USAGE_UNKNOWN, aa.getUsage());
+        assertEquals("Unexpected default content type",
+                AudioAttributes.CONTENT_TYPE_UNKNOWN, aa.getContentType());
+    }
+
+    // -----------------------------------------------------------------
+    // Capture policy tests
+    // ----------------------------------
     public void testAllowedCapturePolicy() throws Exception {
         for (int setPolicy : new int[] { AudioAttributes.ALLOW_CAPTURE_BY_ALL,
                                       AudioAttributes.ALLOW_CAPTURE_BY_SYSTEM,
diff --git a/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java b/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
index f0c3d1d..fbc9b7c 100644
--- a/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
@@ -874,4 +874,19 @@
             MediaUtils.skipTest(TAG, "AAC and FLAC encoders not present");
         }
     }
+
+    public void testLowLatencyFeatureIsSupportedOnly() throws IOException {
+        MediaCodecList list = new MediaCodecList(MediaCodecList.ALL_CODECS);
+        for (MediaCodecInfo info : list.getCodecInfos()) {
+            for (String type : info.getSupportedTypes()) {
+                CodecCapabilities caps = info.getCapabilitiesForType(type);
+                if (caps.isFeatureSupported(CodecCapabilities.FEATURE_LowLatency)) {
+                    assertFalse(
+                        info.getName() + "(" + type + ") "
+                            + " supports low latency, but low latency shall not be required",
+                        caps.isFeatureRequired(CodecCapabilities.FEATURE_LowLatency));
+                }
+            }
+        }
+    }
 }
diff --git a/tests/tests/nativemedia/aaudio/AndroidTest.xml b/tests/tests/nativemedia/aaudio/AndroidTest.xml
index 12da94e..6d116c2 100644
--- a/tests/tests/nativemedia/aaudio/AndroidTest.xml
+++ b/tests/tests/nativemedia/aaudio/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <option name="not-shardable" value="true" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
diff --git a/tests/tests/os/src/android/os/cts/ParcelTest.java b/tests/tests/os/src/android/os/cts/ParcelTest.java
index 68c0a46..0fd3d38 100644
--- a/tests/tests/os/src/android/os/cts/ParcelTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelTest.java
@@ -3428,4 +3428,34 @@
 
         assertNotNull("Service should have started without crashing.", connection.get());
     }
+
+    public void testObjectResize() throws Exception {
+        Parcel p;
+        IBinder b1 = new Binder();
+        IBinder b2 = new Binder();
+
+        p = Parcel.obtain();
+        p.writeStrongBinder(b1);
+        p.setDataSize(0);
+        p.writeStrongBinder(b2);
+
+        p.setDataPosition(0);
+        assertEquals("Object in parcel should match the binder written after the resize", b2,
+                p.readStrongBinder());
+        p.recycle();
+
+        p = Parcel.obtain();
+        p.writeStrongBinder(b1);
+        final int secondBinderPos = p.dataPosition();
+        p.writeStrongBinder(b1);
+        p.setDataSize(secondBinderPos);
+        p.writeStrongBinder(b2);
+
+        p.setDataPosition(0);
+        assertEquals("Object at the start of the parcel parcel should match the first binder", b1,
+                p.readStrongBinder());
+        assertEquals("Object in parcel should match the binder written after the resize", b2,
+                p.readStrongBinder());
+        p.recycle();
+    }
 }
diff --git a/tests/tests/packageinstaller/nopermission/AndroidTest.xml b/tests/tests/packageinstaller/nopermission/AndroidTest.xml
index 9eb96cb..2229230 100644
--- a/tests/tests/packageinstaller/nopermission/AndroidTest.xml
+++ b/tests/tests/packageinstaller/nopermission/AndroidTest.xml
@@ -19,6 +19,7 @@
     <option name="config-descriptor:metadata" key="component" value="framework" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
 
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="mkdir -p /data/local/tmp/cts/nopermission" />
diff --git a/tests/tests/packageinstaller/nopermission25/AndroidTest.xml b/tests/tests/packageinstaller/nopermission25/AndroidTest.xml
index 176e6c5..bd9a85e 100644
--- a/tests/tests/packageinstaller/nopermission25/AndroidTest.xml
+++ b/tests/tests/packageinstaller/nopermission25/AndroidTest.xml
@@ -20,6 +20,7 @@
     <option name="config-descriptor:metadata" key="component" value="framework" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
 
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <option name="run-command" value="mkdir -p /data/local/tmp/cts/nopermission" />
diff --git a/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp b/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp
new file mode 100644
index 0000000..91fcec3
--- /dev/null
+++ b/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsAppThatRequestsStoragePermission28",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/tests/permission/AppThatRequestStoragePermission28/Android.mk b/tests/tests/permission/AppThatRequestStoragePermission28/Android.mk
deleted file mode 100644
index ace3264..0000000
--- a/tests/tests/permission/AppThatRequestStoragePermission28/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_PACKAGE_NAME := CtsAppThatRequestsStoragePermission28
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp b/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp
new file mode 100644
index 0000000..343de69
--- /dev/null
+++ b/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsAppThatRequestsStoragePermission29",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/tests/permission/AppThatRequestStoragePermission29/Android.mk b/tests/tests/permission/AppThatRequestStoragePermission29/Android.mk
deleted file mode 100644
index aa9fabf..0000000
--- a/tests/tests/permission/AppThatRequestStoragePermission29/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_PACKAGE_NAME := CtsAppThatRequestsStoragePermission29
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/permission/AppThatRunsRationaleTests/Android.bp b/tests/tests/permission/AppThatRunsRationaleTests/Android.bp
index 3447de4..7251822 100644
--- a/tests/tests/permission/AppThatRunsRationaleTests/Android.bp
+++ b/tests/tests/permission/AppThatRunsRationaleTests/Android.bp
@@ -14,7 +14,7 @@
 // limitations under the License.
 //
 
-android_test {
+android_test_helper_app {
     name: "CtsAppThatRunsRationaleTests",
     defaults: ["cts_defaults"],
 
diff --git a/tests/tests/permission/testapps/Android.mk b/tests/tests/permission/testapps/Android.mk
deleted file mode 100644
index 1d314d2..0000000
--- a/tests/tests/permission/testapps/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp
new file mode 100644
index 0000000..3710ad3
--- /dev/null
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsAdversarialPermissionDefinerApp",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    certificate: ":cts-testkey1",
+}
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.mk b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.mk
deleted file mode 100644
index e81acdc..0000000
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
-LOCAL_PACKAGE_NAME := CtsAdversarialPermissionDefinerApp
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp
new file mode 100644
index 0000000..6c996b4
--- /dev/null
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsAdversarialPermissionUserApp",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    certificate: ":cts-testkey2",
+}
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.mk b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.mk
deleted file mode 100644
index 8856eb8..0000000
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
-LOCAL_PACKAGE_NAME := CtsAdversarialPermissionUserApp
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/Android.mk b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/Android.mk
deleted file mode 100644
index 1d314d2..0000000
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp
new file mode 100644
index 0000000..42c25e6
--- /dev/null
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsRuntimePermissionDefinerApp",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    certificate: ":cts-testkey1",
+}
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.mk b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.mk
deleted file mode 100644
index 8e22243..0000000
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
-LOCAL_PACKAGE_NAME := CtsRuntimePermissionDefinerApp
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp
new file mode 100644
index 0000000..cb77194
--- /dev/null
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsRuntimePermissionUserApp",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    certificate: ":cts-testkey2",
+}
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.mk b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.mk
deleted file mode 100644
index 112a132..0000000
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
-LOCAL_PACKAGE_NAME := CtsRuntimePermissionUserApp
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp
new file mode 100644
index 0000000..8c87819
--- /dev/null
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+android_test_helper_app {
+    name: "CtsVictimPermissionDefinerApp",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    certificate: ":cts-testkey1",
+}
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.mk b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.mk
deleted file mode 100644
index e7f4072..0000000
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
-
-LOCAL_PACKAGE_NAME := CtsVictimPermissionDefinerApp
-
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index 16ad73f..6670dc0 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -1550,7 +1550,7 @@
          @hide This should only be used by Settings and SystemUI.
     -->
     <permission android:name="android.permission.NETWORK_SETTINGS"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- Allows SetupWizard to call methods in Networking services
          <p>Not for use by any other third-party or privileged applications.
@@ -2068,7 +2068,7 @@
          @hide
     -->
     <permission android:name="android.permission.BIND_TELEPHONY_DATA_SERVICE"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- Must be required by a NetworkService to ensure that only the
          system can bind to it.
@@ -2093,7 +2093,7 @@
          @hide
     -->
     <permission android:name="android.permission.BIND_EUICC_SERVICE"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- ================================== -->
     <!-- Permissions for sdcard interaction -->
@@ -2199,7 +2199,7 @@
          types of interactions
          @hide -->
     <permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
-        android:protectionLevel="signature|installer" />
+        android:protectionLevel="signature|installer|telephony" />
 
     <!-- @SystemApi Allows an application to start its own activities, but on a different profile
          associated with the user. For example, an application running on the main profile of a user
@@ -2821,7 +2821,7 @@
     <!-- Allows an application to be the status bar.  Currently used only by SystemUI.apk
     @hide -->
     <permission android:name="android.permission.STATUS_BAR_SERVICE"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- Allows an application to trigger bugreports via the shell app (which uses bugreport API)
     @hide -->
@@ -2876,7 +2876,7 @@
          @hide
     -->
     <permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony|wifi" />
 
     <!-- @SystemApi Allows an application to use
          {@link android.view.WindowManager.LayoutsParams#SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS}
@@ -2953,7 +2953,7 @@
          @hide
     -->
     <permission android:name="android.permission.SET_ACTIVITY_WATCHER"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- @SystemApi Allows an application to call the activity manager shutdown() API
          to put the higher-level system there into a shutdown state.
@@ -3431,6 +3431,13 @@
     <permission android:name="android.permission.GET_RUNTIME_PERMISSIONS"
         android:protectionLevel="signature" />
 
+    <!-- @SystemApi Allows the system to restore runtime permission state. This might grant
+    permissions, hence this is a more scoped, less powerful variant of GRANT_RUNTIME_PERMISSIONS.
+    Among other restrictions this cannot override user choices.
+    @hide -->
+    <permission android:name="android.permission.RESTORE_RUNTIME_PERMISSIONS"
+                android:protectionLevel="signature" />
+
     <!-- @SystemApi Allows an application to change policy_fixed permissions.
     @hide -->
     <permission android:name="android.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY"
@@ -3449,7 +3456,7 @@
     <!-- @SystemApi Allows an application to manage the holders of a role.
          @hide -->
     <permission android:name="android.permission.MANAGE_ROLE_HOLDERS"
-        android:protectionLevel="signature|installer" />
+        android:protectionLevel="signature|installer|telephony" />
 
     <!-- @SystemApi Allows an application to observe role holder changes.
          @hide -->
@@ -3660,7 +3667,7 @@
          @hide
      -->
     <permission android:name="android.permission.DEVICE_POWER"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- Allows toggling battery saver on the system.
          Superseded by DEVICE_POWER permission. @hide @SystemApi
@@ -3695,13 +3702,13 @@
          <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.BROADCAST_SMS"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- Allows an application to broadcast a WAP PUSH receipt notification.
          <p>Not for use by third-party applications.
     -->
     <permission android:name="android.permission.BROADCAST_WAP_PUSH"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- @SystemApi Allows an application to broadcast privileged networking requests.
          <p>Not for use by third-party applications.
@@ -4325,13 +4332,13 @@
          {@link android.provider.BlockedNumberContract}.
          @hide -->
     <permission android:name="android.permission.READ_BLOCKED_NUMBERS"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- Allows the holder to write blocked numbers. See
          {@link android.provider.BlockedNumberContract}.
          @hide -->
     <permission android:name="android.permission.WRITE_BLOCKED_NUMBERS"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- Must be required by an {@link android.service.vr.VrListenerService}, to ensure that only
          the system can bind to it.
@@ -4489,7 +4496,7 @@
     <!-- @hide Permission that allows configuring appops.
      <p>Not for use by third-party applications. -->
     <permission android:name="android.permission.MANAGE_APPOPS"
-        android:protectionLevel="signature" />
+        android:protectionLevel="signature|telephony" />
 
     <!-- @hide Permission that allows background clipboard access.
          <p>Not for use by third-party applications. -->
@@ -4891,6 +4898,14 @@
             </intent-filter>
         </receiver>
 
+        <receiver android:name="com.android.server.updates.EmergencyNumberDbInstallReceiver"
+            android:permission="android.permission.UPDATE_CONFIG">
+            <intent-filter>
+                <action android:name="android.os.action.UPDATE_EMERGENCY_NUMBER_DB" />
+                <data android:scheme="content" android:host="*" android:mimeType="*/*" />
+            </intent-filter>
+        </receiver>
+
         <service android:name="android.hardware.location.GeofenceHardwareService"
             android:permission="android.permission.LOCATION_HARDWARE"
             android:exported="false" />
diff --git a/tests/tests/permission2/src/android/permission2/cts/NoLocationPermissionTest.java b/tests/tests/permission2/src/android/permission2/cts/NoLocationPermissionTest.java
deleted file mode 100644
index 2301980..0000000
--- a/tests/tests/permission2/src/android/permission2/cts/NoLocationPermissionTest.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Copyright (C) 2008 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.permission2.cts;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.os.Bundle;
-import android.os.Looper;
-import android.telephony.CellInfo;
-import android.telephony.CellLocation;
-import android.telephony.PhoneStateListener;
-import android.telephony.TelephonyManager;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.UiThreadTest;
-
-import java.util.List;
-
-/**
- * Verify the location access without specific permissions.
- */
-public class NoLocationPermissionTest extends InstrumentationTestCase {
-    private static final String TEST_PROVIDER_NAME = "testProvider";
-
-    private LocationManager mLocationManager;
-    private List<String> mAllProviders;
-    private boolean mHasTelephony;
-    private Context mContext;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mContext = getInstrumentation().getTargetContext();
-        mLocationManager = (LocationManager) mContext.getSystemService(
-                Context.LOCATION_SERVICE);
-        mAllProviders = mLocationManager.getAllProviders();
-        mHasTelephony = mContext.getPackageManager().hasSystemFeature(
-                PackageManager.FEATURE_TELEPHONY);
-
-        assertNotNull(mLocationManager);
-        assertNotNull(mAllProviders);
-    }
-
-    private boolean isKnownLocationProvider(String provider) {
-        return mAllProviders.contains(provider);
-    }
-
-    /**
-     * Verify that listen or get cell location requires permissions.
-     * <p>
-     * Requires Permission: {@link
-     * android.Manifest.permission#ACCESS_FINE_LOCATION}
-     */
-    @UiThreadTest
-    public void testListenCellLocation() {
-        if (!mHasTelephony) {
-            return;
-        }
-
-        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
-                Context.TELEPHONY_SERVICE);
-        PhoneStateListener phoneStateListener = new PhoneStateListener() {
-            @Override
-            public void onCellLocationChanged(CellLocation location) {
-                if (location != null) {
-                    fail("Test process should not have received CellLocation");
-                }
-            }
-
-        };
-        try {
-            telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION);
-        } catch (SecurityException e) {
-            // expected
-        }
-
-        try {
-            CellLocation cellLocation = telephonyManager.getCellLocation();
-            if (cellLocation != null) {
-                fail("Test process should not have gotten a nonnull value from getCellLocation.");
-            }
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that get cell location requires permissions.
-     * <p>
-     * Requires Permission: {@link
-     * android.Manifest.permission#ACCESS_FINE_LOCATION}
-     */
-    @UiThreadTest
-    public void testListenCellLocation2() {
-        if (!mHasTelephony) {
-            return;
-        }
-
-        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
-                Context.TELEPHONY_SERVICE);
-        try {
-            List<CellInfo> cellInfos = telephonyManager.getAllCellInfo();
-            if (cellInfos != null && cellInfos.size() > 0) {
-                fail("Test process should not have received CellInfo");
-            }
-        } catch (SecurityException e) {
-            // expected
-        }
-
-        try {
-            telephonyManager.requestCellInfoUpdate(mContext.getMainExecutor(),
-                    new TelephonyManager.CellInfoCallback() {
-                        @Override
-                        public void onCellInfo(List<CellInfo> cellInfos) {
-                            if (cellInfos != null && cellInfos.size() > 0) {
-                                fail("Test process should not have received CellInfo");
-                            }
-                        }
-                    });
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Helper method to verify that calling requestLocationUpdates with given
-     * provider throws SecurityException.
-     * 
-     * @param provider the String provider name.
-     */
-    private void checkRequestLocationUpdates(String provider) {
-        if (!isKnownLocationProvider(provider)) {
-            // skip this test if the provider is unknown
-            return;
-        }
-
-        LocationListener mockListener = new MockLocationListener();
-        Looper looper = Looper.myLooper();
-        try {
-            mLocationManager.requestLocationUpdates(provider, 0, 0, mockListener);
-            fail("LocationManager.requestLocationUpdates did not" +
-                    " throw SecurityException as expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-
-        try {
-            mLocationManager.requestLocationUpdates(provider, 0, 0, mockListener, looper);
-            fail("LocationManager.requestLocationUpdates did not" +
-                    " throw SecurityException as expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that listening for network requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @UiThreadTest
-    public void testRequestLocationUpdatesNetwork() {
-        checkRequestLocationUpdates(LocationManager.NETWORK_PROVIDER);
-    }
-
-    /**
-     * Verify that listening for GPS location requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @UiThreadTest
-    public void testRequestLocationUpdatesGps() {
-        checkRequestLocationUpdates(LocationManager.GPS_PROVIDER);
-    }
-
-    /**
-     * Verify that adding a proximity alert requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @SmallTest
-    public void testAddProximityAlert() {
-        PendingIntent mockPendingIntent = PendingIntent.getBroadcast(mContext,
-                0, new Intent("mockIntent"), PendingIntent.FLAG_ONE_SHOT);
-        try {
-            mLocationManager.addProximityAlert(0, 0, 100, -1, mockPendingIntent);
-            fail("LocationManager.addProximityAlert did not throw SecurityException as expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Helper method to verify that calling getLastKnownLocation with given
-     * provider throws SecurityException.
-     * 
-     * @param provider the String provider name.
-     */
-    private void checkGetLastKnownLocation(String provider) {
-        if (!isKnownLocationProvider(provider)) {
-            // skip this test if the provider is unknown
-            return;
-        }
-
-        try {
-            mLocationManager.getLastKnownLocation(provider);
-            fail("LocationManager.getLastKnownLocation did not" +
-                    " throw SecurityException as expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that getting the last known GPS location requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @SmallTest
-    public void testGetLastKnownLocationGps() {
-        checkGetLastKnownLocation(LocationManager.GPS_PROVIDER);
-    }
-
-    /**
-     * Verify that getting the last known network location requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @SmallTest
-    public void testGetLastKnownLocationNetwork() {
-        checkGetLastKnownLocation(LocationManager.NETWORK_PROVIDER);
-    }
-
-    /**
-     * Helper method to verify that calling getProvider with given provider
-     * throws SecurityException.
-     * 
-     * @param provider the String provider name.
-     */
-    private void checkGetProvider(String provider) {
-        if (!isKnownLocationProvider(provider)) {
-            // skip this test if the provider is unknown
-            return;
-        }
-
-        try {
-            mLocationManager.getProvider(provider);
-            fail("LocationManager.getProvider did not throw SecurityException as expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that getting the GPS provider requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @SmallTest
-    public void testGetProviderGps() {
-        checkGetProvider(LocationManager.GPS_PROVIDER);
-    }
-
-    /**
-     * Verify that getting the network provider requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}.
-     */
-    // TODO: remove from small test suite until network provider can be enabled
-    // on test devices
-    // @SmallTest
-    public void testGetProviderNetwork() {
-        checkGetProvider(LocationManager.NETWORK_PROVIDER);
-    }
-
-    /**
-     * Helper method to verify that calling
-     * {@link LocationManager#isProviderEnabled(String)} with given
-     * provider completes without an exception. (Note that under the conditions
-     * of these tests, that method threw SecurityException on OS levels before
-     * {@link android.os.Build.VERSION_CODES#LOLLIPOP}. See the method's javadoc for
-     * details.)
-     *
-     * @param provider the String provider name.
-     */
-    private void checkIsProviderEnabled(String provider) {
-        if (!isKnownLocationProvider(provider)) {
-            // skip this test if the provider is unknown
-            return;
-        }
-        mLocationManager.isProviderEnabled(provider);
-    }
-
-    /**
-     * Verify that checking IsProviderEnabled for GPS requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @SmallTest
-    public void testIsProviderEnabledGps() {
-        checkIsProviderEnabled(LocationManager.GPS_PROVIDER);
-    }
-
-    /**
-     * Verify that checking IsProviderEnabled for network requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
-     */
-    @SmallTest
-    public void testIsProviderEnabledNetwork() {
-        checkIsProviderEnabled(LocationManager.NETWORK_PROVIDER);
-    }
-
-    /**
-     * Verify that checking addTestProvider for network requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_MOCK_LOCATION}.
-     */
-    @SmallTest
-    public void testAddTestProvider() {
-        final int TEST_POWER_REQUIREMENT_VALE = 0;
-        final int TEST_ACCURACY_VALUE = 1;
-
-        try {
-            mLocationManager.addTestProvider(TEST_PROVIDER_NAME, true, true, true, true,
-                    true, true, true, TEST_POWER_REQUIREMENT_VALE, TEST_ACCURACY_VALUE);
-            fail("LocationManager.addTestProvider did not throw SecurityException as expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that checking removeTestProvider for network requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_MOCK_LOCATION}.
-     */
-    @SmallTest
-    public void testRemoveTestProvider() {
-        try {
-            mLocationManager.removeTestProvider(TEST_PROVIDER_NAME);
-            fail("LocationManager.removeTestProvider did not throw SecurityException as"
-                    + " expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that checking setTestProviderLocation for network requires
-     * permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_MOCK_LOCATION}.
-     */
-    @SmallTest
-    public void testSetTestProviderLocation() {
-        Location location = new Location(TEST_PROVIDER_NAME);
-        location.makeComplete();
-
-        try {
-            mLocationManager.setTestProviderLocation(TEST_PROVIDER_NAME, location);
-            fail("LocationManager.setTestProviderLocation did not throw SecurityException as"
-                    + " expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that checking setTestProviderEnabled requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_MOCK_LOCATION}.
-     */
-    @SmallTest
-    public void testSetTestProviderEnabled() {
-        try {
-            mLocationManager.setTestProviderEnabled(TEST_PROVIDER_NAME, true);
-            fail("LocationManager.setTestProviderEnabled did not throw SecurityException as"
-                    + " expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    /**
-     * Verify that checking clearTestProviderEnabled requires permissions.
-     * <p>
-     * Requires Permission:
-     * {@link android.Manifest.permission#ACCESS_MOCK_LOCATION}.
-     */
-    @SmallTest
-    public void testClearTestProviderEnabled() {
-        try {
-            mLocationManager.clearTestProviderEnabled(TEST_PROVIDER_NAME);
-            fail("LocationManager.setTestProviderEnabled did not throw SecurityException as"
-                    + " expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-
-    private static class MockLocationListener implements LocationListener {
-        public void onLocationChanged(Location location) {
-            // ignore
-        }
-
-        public void onProviderDisabled(String provider) {
-            // ignore
-        }
-
-        public void onProviderEnabled(String provider) {
-            // ignore
-        }
-
-        public void onStatusChanged(String provider, int status, Bundle extras) {
-            // ignore
-        }
-    }
-}
diff --git a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
index 9e09a7b..954c61e 100644
--- a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
@@ -402,6 +402,12 @@
                 case "runtime": {
                     protectionLevel |= PermissionInfo.PROTECTION_FLAG_RUNTIME_ONLY;
                 } break;
+                case "telephony": {
+                    protectionLevel |= PermissionInfo.PROTECTION_FLAG_TELEPHONY;
+                } break;
+                case "wifi": {
+                    protectionLevel |= PermissionInfo.PROTECTION_FLAG_WIFI;
+                } break;
             }
         }
         return protectionLevel;
diff --git a/tests/tests/print/Android.mk b/tests/tests/print/Android.mk
deleted file mode 100644
index f45aed1..0000000
--- a/tests/tests/print/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include $(call all-subdir-makefiles)
diff --git a/tests/tests/print/ExternalPrintService/Android.bp b/tests/tests/print/ExternalPrintService/Android.bp
new file mode 100644
index 0000000..c610d00
--- /dev/null
+++ b/tests/tests/print/ExternalPrintService/Android.bp
@@ -0,0 +1,29 @@
+//
+// 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.
+//
+
+android_test_helper_app {
+    name: "CtsExternalPrintService",
+    defaults: ["cts_defaults"],
+    sdk_version: "current",
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    srcs: ["src/**/*.java"],
+    static_libs: ["junit"],
+}
diff --git a/tests/tests/print/ExternalPrintService/Android.mk b/tests/tests/print/ExternalPrintService/Android.mk
deleted file mode 100644
index 4cee3b7..0000000
--- a/tests/tests/print/ExternalPrintService/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SDK_VERSION := current
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := junit
-
-LOCAL_PACKAGE_NAME := CtsExternalPrintService
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/provider/AndroidManifest.xml b/tests/tests/provider/AndroidManifest.xml
index 9417e3f..512a02f 100644
--- a/tests/tests/provider/AndroidManifest.xml
+++ b/tests/tests/provider/AndroidManifest.xml
@@ -26,8 +26,6 @@
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />
     <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
     <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
-    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
-    <uses-permission android:name="android.permission.READ_CALENDAR" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_SETTINGS" />
@@ -54,17 +52,6 @@
             </intent-filter>
         </activity>
 
-        <service android:name="android.provider.cts.contacts.account.MockAccountService"
-                 process="android.provider.cts"
-                 android:exported="true">
-            <intent-filter>
-                <action android:name="android.accounts.AccountAuthenticator"/>
-            </intent-filter>
-
-            <meta-data android:name="android.accounts.AccountAuthenticator"
-                       android:resource="@xml/contactprovider_authenticator"/>
-        </service>
-
         <service android:name=".MockInputMethodService"
                  android:label="UserDictionaryInputMethodTestService"
                  android:permission="android.permission.BIND_INPUT_METHOD">
@@ -75,14 +62,6 @@
                        android:resource="@xml/method" />
         </service>
 
-        <provider
-            android:name=".contacts.DummyGalProvider"
-            android:authorities="android.provider.cts.contacts.dgp"
-            android:exported="true"
-            android:readPermission="android.permission.BIND_DIRECTORY_SEARCH" >
-            <meta-data android:name="android.content.ContactDirectory" android:value="true" />
-        </provider>
-
         <provider android:name="android.provider.cts.MockFontProvider"
                   android:authorities="android.provider.fonts.cts.font"
                   android:exported="false"
@@ -143,10 +122,5 @@
         <meta-data android:name="listener"
             android:value="com.android.cts.runner.CtsTestRunListener" />
     </instrumentation>
-
-    <instrumentation android:name="android.provider.cts.CalendarTest$CalendarEmmaTestRunner"
-                     android:targetPackage="android.provider.cts"
-                     android:label="Augmented CTS tests of Calendar provider"/>
-
 </manifest>
 
diff --git a/tests/tests/provider/src/android/provider/cts/settings/Settings_SystemTest.java b/tests/tests/provider/src/android/provider/cts/settings/Settings_SystemTest.java
index 338d9f8..24b2845 100644
--- a/tests/tests/provider/src/android/provider/cts/settings/Settings_SystemTest.java
+++ b/tests/tests/provider/src/android/provider/cts/settings/Settings_SystemTest.java
@@ -39,10 +39,10 @@
 
 @RunWith(AndroidJUnit4.class)
 public class Settings_SystemTest {
-    private static final String INT_FIELD = Settings.System.SCREEN_BRIGHTNESS;
-    private static final String LONG_FIELD = Settings.System.SCREEN_OFF_TIMEOUT;
-    private static final String FLOAT_FIELD = Settings.System.FONT_SCALE;
-    private static final String STRING_FIELD = Settings.System.NEXT_ALARM_FORMATTED;
+    private static final String INT_FIELD = System.END_BUTTON_BEHAVIOR;
+    private static final String LONG_FIELD = System.SCREEN_OFF_TIMEOUT;
+    private static final String FLOAT_FIELD = System.FONT_SCALE;
+    private static final String STRING_FIELD = System.NEXT_ALARM_FORMATTED;
 
     @BeforeClass
     public static void setUp() throws Exception {
@@ -79,6 +79,12 @@
         System.getConfiguration(cr, cfg);
         float store = cfg.fontScale;
 
+        //store all original values
+        final Float originalFloatValue = System.getFloat(cr, FLOAT_FIELD);
+        final Integer originalIntValue = System.getInt(cr, INT_FIELD);
+        final Long originalLongValue = System.getLong(cr, LONG_FIELD);
+        final String originalStringValue = System.getString(cr, STRING_FIELD);
+
         try {
             assertNotNull(c);
             c.close();
@@ -86,7 +92,7 @@
             String stringValue = "cts";
 
             // insert 4 rows, and update 1 rows
-            assertTrue(System.putInt(cr, INT_FIELD, 10));
+            assertTrue(System.putInt(cr, INT_FIELD, 2));
             assertTrue(System.putLong(cr, LONG_FIELD, 20l));
             assertTrue(System.putFloat(cr, FLOAT_FIELD, 30.0f));
             assertTrue(System.putString(cr, STRING_FIELD, stringValue));
@@ -96,7 +102,7 @@
             c.close();
 
             // get these rows to assert
-            assertEquals(10, System.getInt(cr, INT_FIELD));
+            assertEquals(2, System.getInt(cr, INT_FIELD));
             assertEquals(20l, System.getLong(cr, LONG_FIELD));
             assertEquals(30.0f, System.getFloat(cr, FLOAT_FIELD), 0.001);
 
@@ -116,6 +122,12 @@
             // TODO should clean up more better
             c.close();
 
+            //Restore all original values into system
+            assertTrue(System.putInt(cr, INT_FIELD, originalIntValue));
+            assertTrue(System.putString(cr, STRING_FIELD, originalStringValue));
+            assertTrue(System.putLong(cr, LONG_FIELD, originalLongValue));
+            assertTrue(System.putFloat(cr, FLOAT_FIELD, originalFloatValue));
+
             // restore the fontScale
             try {
                 // Delay helps ActivityManager in completing its previous font-change processing.
diff --git a/tests/tests/selinux/selinuxTargetSdk25/src/android/security/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxTargetSdk25/src/android/security/SELinuxTargetSdkTest.java
index df02df2..dddd3d9 100644
--- a/tests/tests/selinux/selinuxTargetSdk25/src/android/security/SELinuxTargetSdkTest.java
+++ b/tests/tests/selinux/selinuxTargetSdk25/src/android/security/SELinuxTargetSdkTest.java
@@ -29,6 +29,13 @@
     }
 
     /**
+     * Verify that net.dns properties may not be read
+     */
+    public void testNoDns() throws IOException {
+        noDns();
+    }
+
+    /**
      * Verify that selinux context is the expected domain based on
      * targetSdkVersion = 25
      */
diff --git a/tests/tests/syncmanager/AndroidTest.xml b/tests/tests/syncmanager/AndroidTest.xml
index 4302325..5c8605d 100644
--- a/tests/tests/syncmanager/AndroidTest.xml
+++ b/tests/tests/syncmanager/AndroidTest.xml
@@ -20,6 +20,7 @@
     <!-- Instant apps can't have a sync adapter. -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
 
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <!-- Disable keyguard -->
diff --git a/tests/tests/telecom/Android.bp b/tests/tests/telecom/Android.bp
index 11cac38..5544eea 100644
--- a/tests/tests/telecom/Android.bp
+++ b/tests/tests/telecom/Android.bp
@@ -34,6 +34,8 @@
         "ThirdPtyInCallServiceTestApp/**/I*.aidl",
         "CallRedirectionServiceTestApp/**/*.java",
         "CallRedirectionServiceTestApp/**/I*.aidl",
+        "Api29InCallServiceTestApp/**/*.java",
+        "Api29InCallServiceTestApp/**/I*.aidl",
     ],
     exclude_srcs: [
         "src/android/telecom/cts/SelfManagedConnection.java",
diff --git a/tests/tests/telecom/AndroidTest.xml b/tests/tests/telecom/AndroidTest.xml
index 4dce7f5..2ecc8a1 100644
--- a/tests/tests/telecom/AndroidTest.xml
+++ b/tests/tests/telecom/AndroidTest.xml
@@ -27,6 +27,7 @@
         <option name="test-file-name" value="CallRedirectionServiceTestApp.apk" />
         <option name="test-file-name" value="CtsTelecomTestCases.apk" />
         <option name="test-file-name" value="ThirdPtyInCallServiceTestApp.apk" />
+        <option name="test-file-name" value="Api29InCallServiceTestApp.apk" />
         <option name="test-file-name" value="CallScreeningServiceTestApp.apk" />
     </target_preparer>
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
diff --git a/tests/tests/telecom/Api29InCallServiceTestApp/Android.bp b/tests/tests/telecom/Api29InCallServiceTestApp/Android.bp
new file mode 100644
index 0000000..5bd3351
--- /dev/null
+++ b/tests/tests/telecom/Api29InCallServiceTestApp/Android.bp
@@ -0,0 +1,33 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test_helper_app {
+    name: "Api29InCallServiceTestApp",
+    defaults: ["cts_defaults"],
+    srcs: [
+        "src/**/*.java",
+        "aidl/**/I*.aidl",
+    ],
+    static_libs: [
+        "compatibility-device-util-axt",
+        "ctstestrunner-axt",
+        "androidx.test.rules",
+        "CtsTelecomMockLib",
+    ],
+    sdk_version: "test_current",
+    test_suites: [
+        "cts",
+        "vts",
+    ],
+}
diff --git a/tests/tests/telecom/Api29InCallServiceTestApp/AndroidManifest.xml b/tests/tests/telecom/Api29InCallServiceTestApp/AndroidManifest.xml
new file mode 100644
index 0000000..bd8bb78
--- /dev/null
+++ b/tests/tests/telecom/Api29InCallServiceTestApp/AndroidManifest.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.telecom.cts.api29incallservice"
+          android:versionCode="1"
+          android:versionName="1.0" >
+
+    <!-- sdk 15 is the max for read call log -->
+    <uses-sdk android:minSdkVersion="15"
+              android:targetSdkVersion="29" />
+
+    <uses-permission android:name="android.permission.READ_CALL_LOG"/>
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+    <uses-permission android:name="android.permission.CALL_COMPANION_APP" />
+
+    <application android:label="Api29CTSInCallService">
+        <service android:name=".CtsApi29InCallService"
+                 android:permission="android.permission.BIND_INCALL_SERVICE"
+                 android:launchMode="singleInstance"
+                 android:exported="true">
+            <!--  indicates it's a non-UI service, required by non-Ui InCallService -->
+            <intent-filter>
+                <action android:name="android.telecom.InCallService"/>
+            </intent-filter>
+        </service>
+        <service android:name=".CtsApi29InCallServiceControl"
+                 android:launchMode="singleInstance">
+            <intent-filter>
+                <action
+                    android:name="android.telecom.cts.api29incallservice.ACTION_API29_CONTROL"/>
+            </intent-filter>
+        </service>
+    </application>
+
+</manifest>
diff --git a/tests/tests/telecom/Api29InCallServiceTestApp/aidl/android/telecom/cts/api29incallservice/ICtsApi29InCallServiceControl.aidl b/tests/tests/telecom/Api29InCallServiceTestApp/aidl/android/telecom/cts/api29incallservice/ICtsApi29InCallServiceControl.aidl
new file mode 100644
index 0000000..1c96bdf
--- /dev/null
+++ b/tests/tests/telecom/Api29InCallServiceTestApp/aidl/android/telecom/cts/api29incallservice/ICtsApi29InCallServiceControl.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telecom.cts.api29incallservice;
+
+interface ICtsApi29InCallServiceControl {
+    int getCallState(String callId);
+
+    int getLocalCallCount();
+
+    int getHistoricalCallCount();
+}
diff --git a/tests/tests/telecom/Api29InCallServiceTestApp/src/android/telecom/cts/api29incallservice/CtsApi29InCallService.java b/tests/tests/telecom/Api29InCallServiceTestApp/src/android/telecom/cts/api29incallservice/CtsApi29InCallService.java
new file mode 100644
index 0000000..31da35e
--- /dev/null
+++ b/tests/tests/telecom/Api29InCallServiceTestApp/src/android/telecom/cts/api29incallservice/CtsApi29InCallService.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telecom.cts.api29incallservice;
+
+import android.telecom.Call;
+import android.telecom.cts.MockInCallService;
+import android.util.Log;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class CtsApi29InCallService extends MockInCallService {
+
+    public static final String PACKAGE_NAME = CtsApi29InCallService.class.getPackage().getName();
+    private static final String TAG = CtsApi29InCallService.class.getSimpleName();
+    protected static final int TIMEOUT = 10000;
+
+    static Set<Call> sCalls = new HashSet<>();
+    static int sHistoricalCallCount = 0;
+
+    @Override
+    public void onCallAdded(Call call) {
+        Log.i(TAG, "onCallAdded");
+        super.onCallAdded(call);
+        if (!sCalls.contains(call)) {
+            sHistoricalCallCount++;
+        }
+        sCalls.add(call);
+    }
+
+    @Override
+    public void onCallRemoved(Call call) {
+        Log.i(TAG, "onCallRemoved");
+        super.onCallRemoved(call);
+        sCalls.remove(call);
+    }
+
+    public static int getLocalCallCount() {
+        synchronized (sLock) {
+            return sCalls.size();
+        }
+    }
+}
diff --git a/tests/tests/telecom/Api29InCallServiceTestApp/src/android/telecom/cts/api29incallservice/CtsApi29InCallServiceControl.java b/tests/tests/telecom/Api29InCallServiceTestApp/src/android/telecom/cts/api29incallservice/CtsApi29InCallServiceControl.java
new file mode 100644
index 0000000..b135606
--- /dev/null
+++ b/tests/tests/telecom/Api29InCallServiceTestApp/src/android/telecom/cts/api29incallservice/CtsApi29InCallServiceControl.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telecom.cts.api29incallservice;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.telecom.Call;
+import android.util.Log;
+
+public class CtsApi29InCallServiceControl extends Service {
+
+    private static final String TAG = CtsApi29InCallServiceControl.class.getSimpleName();
+    public static final String CONTROL_INTERFACE_ACTION =
+            "android.telecom.cts.api29incallservice.ACTION_API29_CONTROL";
+
+    private final IBinder mCtsCompanionAppControl = new ICtsApi29InCallServiceControl.Stub() {
+
+        @Override
+        public int getCallState(String callId) {
+            return CtsApi29InCallService.sCalls.stream()
+                    .filter(c -> c.getDetails().getTelecomCallId().equals(callId))
+                    .findFirst().map(Call::getState).orElse(-1);
+        }
+
+        @Override
+        public int getLocalCallCount() {
+            return CtsApi29InCallService.getLocalCallCount();
+        }
+
+        @Override
+        public int getHistoricalCallCount() {
+            return CtsApi29InCallService.sHistoricalCallCount;
+        }
+    };
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        if (CONTROL_INTERFACE_ACTION.equals(intent.getAction())) {
+            Log.d(TAG, "onBind: return control interface.");
+            return mCtsCompanionAppControl;
+        }
+        Log.d(TAG, "onBind: invalid intent.");
+        return null;
+    }
+
+}
diff --git a/tests/tests/telecom/src/android/telecom/cts/BackgroundCallAudioTest.java b/tests/tests/telecom/src/android/telecom/cts/BackgroundCallAudioTest.java
index cc78485..0a9dadc 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BackgroundCallAudioTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BackgroundCallAudioTest.java
@@ -1,9 +1,15 @@
 package android.telecom.cts;
 
 import static android.telecom.cts.TestUtils.TEST_PHONE_ACCOUNT_HANDLE;
+import static android.telecom.cts.TestUtils.waitOnAllHandlers;
 
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
 import android.media.AudioManager;
 import android.os.Bundle;
+import android.os.IBinder;
 import android.telecom.Call;
 import android.telecom.Call.Details;
 import android.telecom.CallScreeningService.CallResponse;
@@ -12,17 +18,23 @@
 import android.telecom.TelecomManager;
 import android.telecom.VideoProfile;
 import android.telecom.cts.MockCallScreeningService.CallScreeningServiceCallbacks;
+import android.telecom.cts.api29incallservice.CtsApi29InCallService;
+import android.telecom.cts.api29incallservice.CtsApi29InCallServiceControl;
+import android.telecom.cts.api29incallservice.ICtsApi29InCallServiceControl;
 import android.text.TextUtils;
+import android.util.Log;
 
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
 public class BackgroundCallAudioTest extends BaseTelecomTestWithMockServices {
-    private static final boolean ENABLED = false; // TODO: change to true once tests pass
+    private static final String LOG_TAG = BackgroundCallAudioTest.class.getSimpleName();
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        mShouldTestTelecom &= ENABLED;
         if (mShouldTestTelecom) {
             mPreviousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
             TestUtils.setDefaultDialer(getInstrumentation(), TestUtils.PACKAGE);
@@ -51,6 +63,11 @@
 
         final MockConnection connection = verifyConnectionForIncomingCall();
 
+        if (!mInCallCallbacks.lock.tryAcquire(TestUtils.WAIT_FOR_CALL_ADDED_TIMEOUT_S,
+                TimeUnit.SECONDS)) {
+            fail("No call added to InCallService.");
+        }
+
         Call call = mInCallCallbacks.getService().getLastCall();
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
         assertConnectionState(connection, Connection.STATE_ACTIVE);
@@ -70,6 +87,11 @@
 
         final MockConnection connection = verifyConnectionForIncomingCall();
 
+        if (!mInCallCallbacks.lock.tryAcquire(TestUtils.WAIT_FOR_CALL_ADDED_TIMEOUT_S,
+                TimeUnit.SECONDS)) {
+            fail("No call added to InCallService.");
+        }
+
         Call call = mInCallCallbacks.getService().getLastCall();
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
         assertConnectionState(connection, Connection.STATE_ACTIVE);
@@ -79,7 +101,7 @@
 
         call.disconnect();
         assertCallState(call, Call.STATE_DISCONNECTED);
-        assertEquals(DisconnectCause.REJECTED, connection.getDisconnectCause().getCode());
+        assertEquals(DisconnectCause.REJECTED, call.getDetails().getDisconnectCause().getCode());
     }
 
     public void testAudioProcessingFromCallScreeningMissed() throws Exception {
@@ -91,6 +113,11 @@
 
         final MockConnection connection = verifyConnectionForIncomingCall();
 
+        if (!mInCallCallbacks.lock.tryAcquire(TestUtils.WAIT_FOR_CALL_ADDED_TIMEOUT_S,
+                TimeUnit.SECONDS)) {
+            fail("No call added to InCallService.");
+        }
+
         Call call = mInCallCallbacks.getService().getLastCall();
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
         assertConnectionState(connection, Connection.STATE_ACTIVE);
@@ -118,6 +145,7 @@
         call.enterBackgroundAudioProcessing();
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
 
+        waitOnAllHandlers(getInstrumentation());
         AudioManager audioManager = mContext.getSystemService(AudioManager.class);
         assertEquals(0 /* TODO: put new mode here */, audioManager.getMode());
         assertConnectionState(connection, Connection.STATE_ACTIVE);
@@ -143,6 +171,7 @@
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
         assertConnectionState(connection, Connection.STATE_ACTIVE);
 
+        waitOnAllHandlers(getInstrumentation());
         AudioManager audioManager = mContext.getSystemService(AudioManager.class);
         assertEquals(0 /* TODO: put new mode here */, audioManager.getMode());
 
@@ -167,18 +196,21 @@
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
         assertConnectionState(connection, Connection.STATE_ACTIVE);
 
+        waitOnAllHandlers(getInstrumentation());
         AudioManager audioManager = mContext.getSystemService(AudioManager.class);
         assertEquals(0 /* TODO: put new mode here */, audioManager.getMode());
 
         connection.setDisconnected(new DisconnectCause(DisconnectCause.REMOTE));
         assertCallState(call, Call.STATE_DISCONNECTED);
         assertEquals(DisconnectCause.REMOTE, call.getDetails().getDisconnectCause().getCode());
+        connection.destroy();
     }
 
     public void testManualAudioCallScreenAccept() {
         if (!mShouldTestTelecom) {
             return;
         }
+
         addAndVerifyNewIncomingCall(createTestNumber(), null);
         final MockConnection connection = verifyConnectionForIncomingCall();
 
@@ -189,11 +221,13 @@
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
         assertConnectionState(connection, Connection.STATE_ACTIVE);
 
+        waitOnAllHandlers(getInstrumentation());
         AudioManager audioManager = mContext.getSystemService(AudioManager.class);
         assertEquals(0 /* TODO: put new mode here */, audioManager.getMode());
 
         call.exitBackgroundAudioProcessing(false);
         assertCallState(call, Call.STATE_ACTIVE);
+        waitOnAllHandlers(getInstrumentation());
         assertEquals(AudioManager.MODE_IN_CALL, audioManager.getMode());
     }
 
@@ -201,6 +235,7 @@
         if (!mShouldTestTelecom) {
             return;
         }
+
         addAndVerifyNewIncomingCall(createTestNumber(), null);
         final MockConnection connection = verifyConnectionForIncomingCall();
 
@@ -211,12 +246,13 @@
         assertCallState(call, Call.STATE_AUDIO_PROCESSING);
         assertConnectionState(connection, Connection.STATE_ACTIVE);
 
+        waitOnAllHandlers(getInstrumentation());
         AudioManager audioManager = mContext.getSystemService(AudioManager.class);
         assertEquals(0 /* TODO: put new mode here */, audioManager.getMode());
 
         call.disconnect();
         assertCallState(call, Call.STATE_DISCONNECTED);
-        assertEquals(DisconnectCause.REJECTED, connection.getDisconnectCause().getCode());
+        assertEquals(DisconnectCause.REJECTED, call.getDetails().getDisconnectCause().getCode());
     }
 
     public void testEnterAudioProcessingWithoutPermission() {
@@ -224,6 +260,11 @@
             return;
         }
 
+        if (true) {
+            // TODO: enable test
+            return;
+        }
+
         placeAndVerifyCall();
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -241,16 +282,61 @@
         }
     }
 
+    public void testLowerApiLevelCompatibility() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
+        ICtsApi29InCallServiceControl controlInterface = setUpControl();
+
+        setupIncomingCallWithCallScreening();
+
+        final MockConnection connection = verifyConnectionForIncomingCall();
+
+        if (!mInCallCallbacks.lock.tryAcquire(TestUtils.WAIT_FOR_CALL_ADDED_TIMEOUT_S,
+                TimeUnit.SECONDS)) {
+            fail("No call added to InCallService.");
+        }
+
+        Call call = mInCallCallbacks.getService().getLastCall();
+        assertCallState(call, Call.STATE_AUDIO_PROCESSING);
+        assertConnectionState(connection, Connection.STATE_ACTIVE);
+        // Make sure that the dummy app never got any calls
+        assertEquals(0, controlInterface.getHistoricalCallCount());
+
+        call.exitBackgroundAudioProcessing(true);
+        assertCallState(call, Call.STATE_SIMULATED_RINGING);
+        waitOnAllHandlers(getInstrumentation());
+        assertConnectionState(connection, Connection.STATE_ACTIVE);
+        // Make sure that the dummy app sees a ringing call.
+        assertEquals(Call.STATE_RINGING,
+                controlInterface.getCallState(call.getDetails().getTelecomCallId()));
+
+        call.answer(VideoProfile.STATE_AUDIO_ONLY);
+        assertCallState(call, Call.STATE_ACTIVE);
+        waitOnAllHandlers(getInstrumentation());
+        assertConnectionState(connection, Connection.STATE_ACTIVE);
+        // Make sure that the dummy app sees an active call.
+        assertEquals(Call.STATE_ACTIVE,
+                controlInterface.getCallState(call.getDetails().getTelecomCallId()));
+
+        TestUtils.executeShellCommand(getInstrumentation(),
+                "telecom add-or-remove-call-companion-app " + CtsApi29InCallService.PACKAGE_NAME
+                        + " 0");
+    }
+
     private void verifySimulateRingAndUserPickup(Call call, Connection connection) {
         AudioManager audioManager = mContext.getSystemService(AudioManager.class);
 
         call.exitBackgroundAudioProcessing(true);
         assertCallState(call, Call.STATE_SIMULATED_RINGING);
+        waitOnAllHandlers(getInstrumentation());
         assertEquals(AudioManager.MODE_RINGTONE, audioManager.getMode());
         assertConnectionState(connection, Connection.STATE_ACTIVE);
 
         call.answer(VideoProfile.STATE_AUDIO_ONLY);
         assertCallState(call, Call.STATE_ACTIVE);
+        waitOnAllHandlers(getInstrumentation());
         assertEquals(AudioManager.MODE_IN_CALL, audioManager.getMode());
         assertConnectionState(connection, Connection.STATE_ACTIVE);
     }
@@ -260,13 +346,14 @@
 
         call.exitBackgroundAudioProcessing(true);
         assertCallState(call, Call.STATE_SIMULATED_RINGING);
+        waitOnAllHandlers(getInstrumentation());
         assertEquals(AudioManager.MODE_RINGTONE, audioManager.getMode());
         assertConnectionState(connection, Connection.STATE_ACTIVE);
 
         call.disconnect();
         assertCallState(call, Call.STATE_DISCONNECTED);
         assertConnectionState(connection, Connection.STATE_DISCONNECTED);
-        assertEquals(DisconnectCause.MISSED, connection.getDisconnectCause().getCode());
+        assertEquals(DisconnectCause.MISSED, call.getDetails().getDisconnectCause().getCode());
     }
 
     private void setupIncomingCallWithCallScreening() throws Exception {
@@ -292,4 +379,34 @@
 
     }
 
+    private ICtsApi29InCallServiceControl setUpControl() throws Exception {
+        TestUtils.executeShellCommand(getInstrumentation(),
+                "telecom add-or-remove-call-companion-app " + CtsApi29InCallService.PACKAGE_NAME
+                        + " 1");
+
+        Intent bindIntent = new Intent(CtsApi29InCallServiceControl.CONTROL_INTERFACE_ACTION);
+        ComponentName controlComponentName =
+                ComponentName.createRelative(
+                        CtsApi29InCallServiceControl.class.getPackage().getName(),
+                        CtsApi29InCallServiceControl.class.getName());
+
+        bindIntent.setComponent(controlComponentName);
+        LinkedBlockingQueue<ICtsApi29InCallServiceControl> result = new LinkedBlockingQueue<>(1);
+
+        boolean success = mContext.bindService(bindIntent, new ServiceConnection() {
+            @Override
+            public void onServiceConnected(ComponentName name, IBinder service) {
+                Log.i(LOG_TAG, "Service Connected: " + name);
+                result.offer(ICtsApi29InCallServiceControl.Stub.asInterface(service));
+            }
+
+            @Override
+            public void onServiceDisconnected(ComponentName name) {
+            }
+        }, Context.BIND_AUTO_CREATE);
+        if (!success) {
+            fail("Failed to get control interface -- bind error");
+        }
+        return result.poll(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+    }
 }
\ No newline at end of file
diff --git a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
index 3a70017..41b9399 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
@@ -37,6 +37,7 @@
 import android.telecom.PhoneAccountHandle;
 import android.telecom.StatusHints;
 import android.telecom.TelecomManager;
+import android.telephony.TelephonyManager;
 
 import java.util.Arrays;
 import java.util.List;
@@ -759,16 +760,26 @@
     }
 
     /**
-     * Tests whether the CallLogManager logs the features of a call(HD call and Wifi call)
+     * Tests whether the CallLogManager logs the features of a call(HD call, Wifi call, VoLTE)
      * correctly.
      */
-    public void testLogHdAndWifi() throws Exception {
+    public void testLogFeatures() throws Exception {
         if (!mShouldTestTelecom) {
             return;
         }
 
         // Register content observer on call log and get latch
         CountDownLatch callLogEntryLatch = getCallLogEntryLatch();
+
+        Bundle testBundle = new Bundle();
+        testBundle.putInt(TelecomManager.EXTRA_CALL_NETWORK_TYPE,
+                          TelephonyManager.NETWORK_TYPE_LTE);
+        mConnection.putExtras(testBundle);
+        // Wait for the 2nd invocation; setExtras is called in the setup method.
+        mOnExtrasChangedCounter.waitForCount(2, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+
+        Bundle extra = mCall.getDetails().getExtras();
+
         mCall.disconnect();
 
         // Wait on the call log latch.
@@ -776,10 +787,12 @@
 
         // Verify the contents of the call log
         Cursor callsCursor = mContext.getContentResolver().query(CallLog.Calls.CONTENT_URI, null,
-                "features", null, null);
-        int features = callsCursor.getColumnIndex(CallLog.Calls.FEATURES);
+                null, null, "_id DESC");
+        callsCursor.moveToFirst();
+        int features = callsCursor.getInt(callsCursor.getColumnIndex("features"));
         assertEquals(CallLog.Calls.FEATURES_HD_CALL,
                 features & CallLog.Calls.FEATURES_HD_CALL);
         assertEquals(CallLog.Calls.FEATURES_WIFI, features & CallLog.Calls.FEATURES_WIFI);
+        assertEquals(CallLog.Calls.FEATURES_VOLTE, features & CallLog.Calls.FEATURES_VOLTE);
     }
 }
diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
index 214ac6a..b82a84e 100644
--- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
+++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java
@@ -339,8 +339,12 @@
         }
     }
 
-    public static void waitOnAllHandlers(Instrumentation instrumentation) throws Exception {
-        executeShellCommand(instrumentation, COMMAND_WAIT_ON_HANDLERS);
+    public static void waitOnAllHandlers(Instrumentation instrumentation) {
+        try {
+            executeShellCommand(instrumentation, COMMAND_WAIT_ON_HANDLERS);
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
     }
 
     public static void waitOnLocalMainLooper(long timeoutMs) {
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java b/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java
index e97eafa..2540b23 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java
@@ -16,24 +16,54 @@
 
 package android.telephony.cts;
 
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
+
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.os.PersistableBundle;
 import android.service.carrier.CarrierIdentifier;
 import android.service.carrier.CarrierService;
+import android.telephony.TelephonyManager;
 import android.test.ServiceTestCase;
+import android.util.Log;
 
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class CarrierServiceTest extends ServiceTestCase<CarrierServiceTest.TestCarrierService> {
+    private static final String TAG = CarrierServiceTest.class.getSimpleName();
+
+    private static boolean sHasCellular;
+
     public CarrierServiceTest() { super(TestCarrierService.class); }
 
+    @BeforeClass
+    public static void setUpTests() {
+        sHasCellular = hasCellular();
+        if (!sHasCellular) {
+            Log.e(TAG, "No cellular support, all tests will be skipped.");
+        }
+    }
+
+    private static boolean hasCellular() {
+        PackageManager packageManager = getInstrumentation().getContext().getPackageManager();
+        TelephonyManager telephonyManager =
+                getInstrumentation().getContext().getSystemService(TelephonyManager.class);
+        return packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
+                && telephonyManager.getPhoneCount() > 0;
+    }
+
     @Test
     public void testNotifyCarrierNetworkChange_true() {
+        if (!sHasCellular) return;
+
         notifyCarrierNetworkChange(true);
     }
 
     @Test
     public void testNotifyCarrierNetworkChange_false() {
+        if (!sHasCellular) return;
+
         notifyCarrierNetworkChange(false);
     }
 
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/CellInfoTest.java b/tests/tests/telephony/current/src/android/telephony/cts/CellInfoTest.java
index 27f8e82..50a2b50 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/CellInfoTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/CellInfoTest.java
@@ -24,6 +24,9 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import android.Manifest;
+import android.Manifest.permission;
+import android.app.UiAutomation;
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.Parcel;
@@ -42,7 +45,6 @@
 import android.telephony.CellInfoNr;
 import android.telephony.CellInfoTdscdma;
 import android.telephony.CellInfoWcdma;
-import android.telephony.CellSignalStrength;
 import android.telephony.CellSignalStrengthCdma;
 import android.telephony.CellSignalStrengthGsm;
 import android.telephony.CellSignalStrengthLte;
@@ -55,6 +57,8 @@
 import android.util.Log;
 import android.util.Pair;
 
+import androidx.test.InstrumentationRegistry;
+
 import org.junit.Before;
 import org.junit.Test;
 
@@ -219,29 +223,6 @@
     }
 
     /**
-     * Test to ensure that {@link CellInfo#getCellIdentity()} return a {@link CellIdentityNr}
-     * object.
-     */
-    @Test
-    public void testCellIdentityNr_Override() throws Throwable {
-        if (!mPm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) return;
-        android.telephony.cts.TestUtils.assertSyntheticMethodOverloadExists(CellInfoNr.class,
-                "getCellIdentity", null, CellIdentity.class, CellIdentityNr.class, true);
-    }
-
-    /**
-     * Test to ensure that {@link CellInfoNr#getCellSignalStrength()} return a
-     * {@link CellSignalStrengthNr} object.
-     */
-    @Test
-    public void testCellCellSignalStrength_Override() throws Throwable {
-        if (!mPm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) return;
-        android.telephony.cts.TestUtils.assertSyntheticMethodOverloadExists(CellInfoNr.class,
-                "getCellSignalStrength", null, CellSignalStrength.class,
-                CellSignalStrengthNr.class, true);
-    }
-
-    /**
      * Test to ensure that the PhoneStateListener receives callbacks every time that new CellInfo
      * is received and not otherwise.
      */
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 d736119..f19d80b 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
@@ -451,6 +451,8 @@
                 (tm) -> tm.getDeviceId(mTelephonyManager.getSlotIndex()));
         mTelephonyManager.getDeviceSoftwareVersion();
         ShellIdentityUtils.invokeMethodWithShellPermissions(mTelephonyManager,
+                (tm) -> tm.getDeviceSoftwareVersion(mTelephonyManager.getSlotIndex()));
+        ShellIdentityUtils.invokeMethodWithShellPermissions(mTelephonyManager,
                 (tm) -> tm.getImei());
         ShellIdentityUtils.invokeMethodWithShellPermissions(mTelephonyManager,
                 (tm) -> tm.getImei(mTelephonyManager.getSlotIndex()));
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyRegistryManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyRegistryManagerTest.java
index a6a2c4f..6c7ff51 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyRegistryManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyRegistryManagerTest.java
@@ -3,7 +3,7 @@
 import static org.junit.Assert.fail;
 
 import android.content.Context;
-import android.os.telephony.TelephonyRegistryManager;
+import android.telephony.TelephonyRegistryManager;
 import androidx.test.InstrumentationRegistry;
 import org.junit.Before;
 import org.junit.Test;
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TestUtils.java b/tests/tests/telephony/current/src/android/telephony/cts/TestUtils.java
deleted file mode 100644
index 24c5718..0000000
--- a/tests/tests/telephony/current/src/android/telephony/cts/TestUtils.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.telephony.cts;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-
-public class TestUtils {
-    public static void assertSyntheticMethodOverloadExists(
-            Class<?> clazz, String methodName, Class[] parameterTypes,
-            Class<?> originalReturnType, Class<?> syntheticReturnType,
-            boolean requireIdenticalExceptions) throws Exception {
-
-        if (parameterTypes == null) {
-            parameterTypes = new Class[0];
-        }
-        String fullMethodName = clazz + "." + methodName;
-
-        // Assert we find the original, non-synthetic version using getDeclaredMethod().
-        Method declaredMethod = clazz.getDeclaredMethod(methodName, parameterTypes);
-        assertEquals(originalReturnType, declaredMethod.getReturnType());
-
-        // Assert both versions of the method are returned from getDeclaredMethods().
-        Method original = null;
-        Method synthetic = null;
-        for (Method method : clazz.getDeclaredMethods()) {
-            if (methodMatches(methodName, parameterTypes, method)) {
-                if (method.getReturnType().equals(syntheticReturnType)) {
-                    synthetic = method;
-                } else if (method.getReturnType().equals(originalReturnType)) {
-                    original = method;
-                }
-            }
-        }
-        assertNotNull("Unable to find original signature: " + fullMethodName
-                + ", returning " + originalReturnType, original);
-        assertNotNull("Unable to find synthetic signature: " + fullMethodName
-                + ", returning " + syntheticReturnType, synthetic);
-
-        // Check modifiers are as expected.
-        assertFalse(original.isSynthetic());
-        assertFalse(original.isBridge());
-        assertTrue(synthetic.isSynthetic());
-        assertTrue(synthetic.isBridge());
-
-        int originalModifiers = original.getModifiers();
-        int syntheticModifiers = synthetic.getModifiers();
-
-        // These masks aren't in the public API but are defined in the dex spec.
-        int syntheticMask = 0x00001000;
-        int bridgeMask = 0x00000040;
-        int mask = syntheticMask | bridgeMask;
-        assertEquals("Method modifiers for " + fullMethodName
-                        + " are expected to be identical except for SYNTHETIC and BRIDGE."
-                        + " original=" + Modifier.toString(originalModifiers)
-                        + ", synthetic=" + Modifier.toString(syntheticModifiers),
-                originalModifiers | mask,
-                syntheticModifiers | mask);
-
-        // Exceptions are not required at method resolution time but we check they're the same in
-        // most cases for completeness.
-        if (requireIdenticalExceptions) {
-            assertArrayEquals("Exceptions for " + fullMethodName + " must be compatible",
-                    original.getExceptionTypes(), synthetic.getExceptionTypes());
-        }
-
-        // Android doesn't support runtime type annotations so nothing to do for them.
-
-        // Type parameters are *not* copied because they're not needed at method resolution time.
-        assertEquals(0, synthetic.getTypeParameters().length);
-
-        // Check method annotations.
-        Annotation[] annotations = original.getDeclaredAnnotations();
-        assertArrayEquals("Annotations differ between original and synthetic versions of "
-                + fullMethodName, annotations, synthetic.getDeclaredAnnotations());
-        Annotation[][] parameterAnnotations = original.getParameterAnnotations();
-        // Check parameter annotations.
-        assertArrayEquals("Annotations differ between original and synthetic versions of "
-                + fullMethodName, parameterAnnotations, synthetic.getParameterAnnotations());
-    }
-
-    private static boolean methodMatches(String methodName, Class[] parameterTypes, Method method) {
-        return method.getName().equals(methodName)
-                && Arrays.equals(parameterTypes, method.getParameterTypes());
-    }
-}
diff --git a/tests/tests/transition/AndroidTest.xml b/tests/tests/transition/AndroidTest.xml
index 043ac02..536338e 100644
--- a/tests/tests/transition/AndroidTest.xml
+++ b/tests/tests/transition/AndroidTest.xml
@@ -20,6 +20,7 @@
          respect to transition tests, so don't run these in instant apps. -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsTransitionTestCases.apk" />
diff --git a/tests/tests/uiautomation/AndroidTest.xml b/tests/tests/uiautomation/AndroidTest.xml
index e05dc4b..d5b2c92 100644
--- a/tests/tests/uiautomation/AndroidTest.xml
+++ b/tests/tests/uiautomation/AndroidTest.xml
@@ -18,6 +18,7 @@
     <option name="config-descriptor:metadata" key="component" value="framework" />
     <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsUiAutomationTestCases.apk" />
diff --git a/tests/tests/util/src/android/util/cts/HalfTest.java b/tests/tests/util/src/android/util/cts/HalfTest.java
index d79669b..4afe422 100644
--- a/tests/tests/util/src/android/util/cts/HalfTest.java
+++ b/tests/tests/util/src/android/util/cts/HalfTest.java
@@ -64,6 +64,22 @@
         // Denormals (flushed to +/-0)
         assertShortEquals(POSITIVE_ZERO, toHalf(5.96046e-9f));
         assertShortEquals(NEGATIVE_ZERO, toHalf(-5.96046e-9f));
+        // Test for values that overflow the mantissa bits into exp bits
+        assertShortEquals(0x1000, toHalf(Float.intBitsToFloat(0x39fff000)));
+        assertShortEquals(0x0400, toHalf(Float.intBitsToFloat(0x387fe000)));
+        // Floats with absolute value above +/-65519 are rounded to +/-inf
+        // when using round-to-even
+        assertShortEquals(0x7bff, toHalf(65519.0f));
+        assertShortEquals(0x7bff, toHalf(65519.9f));
+        assertShortEquals(POSITIVE_INFINITY, toHalf(65520.0f));
+        assertShortEquals(NEGATIVE_INFINITY, toHalf(-65520.0f));
+        // Check if numbers are rounded to nearest even when they
+        // cannot be accurately represented by Half
+        assertShortEquals(0x6800, toHalf(2049.0f));
+        assertShortEquals(0x6c00, toHalf(4098.0f));
+        assertShortEquals(0x7000, toHalf(8196.0f));
+        assertShortEquals(0x7400, toHalf(16392.0f));
+        assertShortEquals(0x7800, toHalf(32784.0f));
     }
 
     @Test
diff --git a/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java
index 2d6804e..2918931 100644
--- a/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java
@@ -148,10 +148,10 @@
 
         AttributeSet attrs = getAttributeSet(android.widget.cts.R.layout.radiogroup_1);
         TypedArray a = mContext.obtainStyledAttributes(attrs,
-                android.R.styleable.ViewGroup_MarginLayout);
+                android.R.styleable.ViewGroup_Layout);
         layoutParams.setBaseAttributes(a,
-                android.R.styleable.ViewGroup_MarginLayout_layout_width,
-                android.R.styleable.ViewGroup_MarginLayout_layout_height);
+                android.R.styleable.ViewGroup_Layout_layout_width,
+                android.R.styleable.ViewGroup_Layout_layout_height);
         // check the attributes from the layout file
         assertEquals(RadioGroup.LayoutParams.MATCH_PARENT, layoutParams.width);
         assertEquals(RadioGroup.LayoutParams.MATCH_PARENT, layoutParams.height);
diff --git a/tests/tests/wrap/nowrap/AndroidTest.xml b/tests/tests/wrap/nowrap/AndroidTest.xml
index 4fa089e..40baa14 100644
--- a/tests/tests/wrap/nowrap/AndroidTest.xml
+++ b/tests/tests/wrap/nowrap/AndroidTest.xml
@@ -19,6 +19,7 @@
     <option name="not-shardable" value="true" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsWrapNoWrapTestCases.apk" />
diff --git a/tests/tests/wrap/wrap_debug_malloc_debug/AndroidTest.xml b/tests/tests/wrap/wrap_debug_malloc_debug/AndroidTest.xml
index f1f42a1..ebba361 100644
--- a/tests/tests/wrap/wrap_debug_malloc_debug/AndroidTest.xml
+++ b/tests/tests/wrap/wrap_debug_malloc_debug/AndroidTest.xml
@@ -19,6 +19,7 @@
     <option name="not-shardable" value="true" />
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsWrapWrapDebugMallocDebugTestCases.apk" />
diff --git a/tests/tvprovider/AndroidTest.xml b/tests/tvprovider/AndroidTest.xml
index 47f5d52..18a59ab 100644
--- a/tests/tvprovider/AndroidTest.xml
+++ b/tests/tvprovider/AndroidTest.xml
@@ -20,6 +20,7 @@
     <!-- Instant apps for TV is not supported. -->
     <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsTvProviderTestCases.apk" />