Merge "Update test host used for TLS host verification."
diff --git a/hostsidetests/gputools/Android.bp b/hostsidetests/gputools/Android.bp
new file mode 100644
index 0000000..dc8ac4f
--- /dev/null
+++ b/hostsidetests/gputools/Android.bp
@@ -0,0 +1,26 @@
+// 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.
+
+java_test_host {
+    name: "CtsGpuToolsHostTestCases",
+    srcs: ["src/**/*.java"],
+    // tag this module as a cts test artifact
+    test_suites: ["cts"],
+    libs: [
+        "cts-tradefed",
+        "tradefed",
+        "compatibility-host-util",
+    ],
+    static_libs: ["platform-test-annotations-host"],
+}
diff --git a/hostsidetests/gputools/Android.mk b/hostsidetests/gputools/Android.mk
deleted file mode 100644
index b2946be..0000000
--- a/hostsidetests/gputools/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_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE_TAGS := tests
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_MODULE := CtsGpuToolsHostTestCases
-
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
-
-LOCAL_STATIC_JAVA_LIBRARIES := platform-test-annotations-host
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/gputools/apps/Android.bp b/hostsidetests/gputools/apps/Android.bp
new file mode 100644
index 0000000..123fcbe
--- /dev/null
+++ b/hostsidetests/gputools/apps/Android.bp
@@ -0,0 +1,71 @@
+// 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_library {
+    name: "libctsgputools_jni",
+    gtest: false,
+    srcs: [
+        "jni/CtsGpuToolsJniOnLoad.cpp",
+        "jni/android_gputools_cts_RootlessGpuDebug.cpp",
+    ],
+    cflags: [
+        "-std=c++14",
+        "-Wall",
+        "-Werror",
+    ],
+    shared_libs: [
+        "libandroid",
+        "libvulkan",
+        "liblog",
+    ],
+    stl: "c++_shared",
+    sdk_version: "current",
+}
+
+android_test_helper_app {
+    name: "CtsGpuToolsRootlessGpuDebugApp-DEBUG",
+    defaults: ["cts_support_defaults"],
+    srcs: ["src/**/*.java"],
+    sdk_version: "current",
+    // tag this module as a cts test artifact
+    test_suites: ["cts"],
+    compile_multilib: "both",
+    jni_libs: ["libctsgputools_jni"],
+    aaptflags: [
+        "--rename-manifest-package",
+        "android.rootlessgpudebug.DEBUG.app",
+        "--debug-mode",
+    ],
+    use_embedded_native_libs: false,
+    stl: "c++_shared",
+}
+
+android_test_helper_app {
+    name: "CtsGpuToolsRootlessGpuDebugApp-RELEASE",
+    defaults: ["cts_support_defaults"],
+    srcs: ["src/**/*.java"],
+    sdk_version: "current",
+    // tag this module as a cts test artifact
+    test_suites: ["cts"],
+    compile_multilib: "both",
+    jni_libs: [
+        "libctsgputools_jni",
+        "libVkLayer_nullLayerC",
+    ],
+    aaptflags: [
+        "--rename-manifest-package android.rootlessgpudebug.RELEASE.app",
+    ],
+    use_embedded_native_libs: false,
+    stl: "c++_shared",
+}
diff --git a/hostsidetests/gputools/apps/Android.mk b/hostsidetests/gputools/apps/Android.mk
deleted file mode 100644
index b3f58bb..0000000
--- a/hostsidetests/gputools/apps/Android.mk
+++ /dev/null
@@ -1,74 +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 := libctsgputools_jni
-LOCAL_SRC_FILES := \
-    jni/CtsGpuToolsJniOnLoad.cpp \
-    jni/android_gputools_cts_RootlessGpuDebug.cpp
-LOCAL_CFLAGS += -std=c++14 -Wall -Werror
-LOCAL_SHARED_LIBRARIES := libandroid libvulkan liblog
-LOCAL_NDK_STL_VARIANT := c++_static
-LOCAL_SDK_VERSION := current
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_MODULE_TAGS := tests
-LOCAL_PACKAGE_NAME := CtsGpuToolsRootlessGpuDebugApp-DEBUG
-LOCAL_SDK_VERSION := current
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_MULTILIB := both
-
-LOCAL_JNI_SHARED_LIBRARIES := \
-libctsgputools_jni
-
-LOCAL_AAPT_FLAGS := \
---rename-manifest-package android.rootlessgpudebug.DEBUG.app \
---debug-mode
-
-LOCAL_USE_EMBEDDED_NATIVE_LIBS := false
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
-
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_MODULE_TAGS := tests
-LOCAL_PACKAGE_NAME := CtsGpuToolsRootlessGpuDebugApp-RELEASE
-LOCAL_SDK_VERSION := current
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_MULTILIB := both
-
-LOCAL_JNI_SHARED_LIBRARIES := \
-libctsgputools_jni \
-libVkLayer_nullLayerC
-
-LOCAL_AAPT_FLAGS := \
---rename-manifest-package android.rootlessgpudebug.RELEASE.app
-
-LOCAL_USE_EMBEDDED_NATIVE_LIBS := false
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/gputools/layers/Android.bp b/hostsidetests/gputools/layers/Android.bp
new file mode 100644
index 0000000..cb6873a
--- /dev/null
+++ b/hostsidetests/gputools/layers/Android.bp
@@ -0,0 +1,89 @@
+// 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_library {
+    name: "libVkLayer_nullLayerA",
+    gtest: false,
+    srcs: ["jni/nullLayer.cpp"],
+    cflags: [
+        "-std=c++14",
+        "-Wall",
+        "-Werror",
+        "-fvisibility=hidden",
+        "-DLAYERNAME=A",
+    ],
+    shared_libs: [
+        "libandroid",
+        "libvulkan",
+        "liblog",
+    ],
+    stl: "c++_shared",
+    sdk_version: "current",
+}
+
+cc_test_library {
+    name: "libVkLayer_nullLayerB",
+    gtest: false,
+    srcs: ["jni/nullLayer.cpp"],
+    cflags: [
+        "-std=c++14",
+        "-Wall",
+        "-Werror",
+        "-fvisibility=hidden",
+        "-DLAYERNAME=B",
+    ],
+    shared_libs: [
+        "libandroid",
+        "libvulkan",
+        "liblog",
+    ],
+    stl: "c++_shared",
+    sdk_version: "current",
+}
+
+cc_test_library {
+    name: "libVkLayer_nullLayerC",
+    gtest: false,
+    srcs: ["jni/nullLayer.cpp"],
+    cflags: [
+        "-std=c++14",
+        "-Wall",
+        "-Werror",
+        "-fvisibility=hidden",
+        "-DLAYERNAME=C",
+    ],
+    shared_libs: [
+        "libandroid",
+        "libvulkan",
+        "liblog",
+    ],
+    stl: "c++_shared",
+    sdk_version: "current",
+}
+
+android_test_helper_app {
+    name: "CtsGpuToolsRootlessGpuDebugApp-LAYERS",
+    defaults: ["cts_support_defaults"],
+    sdk_version: "current",
+    // tag this module as a cts test artifact
+    test_suites: ["cts"],
+    compile_multilib: "both",
+    jni_libs: [
+        "libVkLayer_nullLayerA",
+        "libVkLayer_nullLayerB",
+        "libVkLayer_nullLayerC",
+    ],
+    use_embedded_native_libs: false,
+    stl: "c++_shared",
+}
diff --git a/hostsidetests/gputools/layers/Android.mk b/hostsidetests/gputools/layers/Android.mk
deleted file mode 100644
index eaa68ef..0000000
--- a/hostsidetests/gputools/layers/Android.mk
+++ /dev/null
@@ -1,73 +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 := libVkLayer_nullLayerA
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := jni/nullLayer.cpp
-LOCAL_CFLAGS += -std=c++14 -Wall -Werror -fvisibility=hidden -DLAYERNAME="A"
-LOCAL_SHARED_LIBRARIES := libandroid libvulkan liblog
-LOCAL_NDK_STL_VARIANT := c++_static
-LOCAL_SDK_VERSION := current
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libVkLayer_nullLayerB
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := jni/nullLayer.cpp
-LOCAL_CFLAGS += -std=c++14 -Wall -Werror -fvisibility=hidden -DLAYERNAME="B"
-LOCAL_SHARED_LIBRARIES := libandroid libvulkan liblog
-LOCAL_NDK_STL_VARIANT := c++_static
-LOCAL_SDK_VERSION := current
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libVkLayer_nullLayerC
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := jni/nullLayer.cpp
-LOCAL_CFLAGS += -std=c++14 -Wall -Werror -fvisibility=hidden -DLAYERNAME="C"
-LOCAL_SHARED_LIBRARIES := libandroid libvulkan liblog
-LOCAL_NDK_STL_VARIANT := c++_static
-LOCAL_SDK_VERSION := current
-include $(BUILD_SHARED_LIBRARY)
-
-
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_PACKAGE_NAME := CtsGpuToolsRootlessGpuDebugApp-LAYERS
-LOCAL_SDK_VERSION := current
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_MULTILIB := both
-
-LOCAL_JNI_SHARED_LIBRARIES := \
-libVkLayer_nullLayerA \
-libVkLayer_nullLayerB \
-libVkLayer_nullLayerC
-
-LOCAL_USE_EMBEDDED_NATIVE_LIBS := false
-
-include $(BUILD_CTS_SUPPORT_PACKAGE)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
index 6fc9a1b..0fee0ec 100644
--- a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
+++ b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
@@ -120,7 +120,7 @@
             RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(mTestPackageName, RUNNER,
                     device.getIDevice());
             // set a max deadline limit to avoid hanging forever
-            runner.setMaxTimeToOutputResponse(2, TimeUnit.MINUTES);
+            runner.setMaxTimeToOutputResponse(5, TimeUnit.MINUTES);
 
             AttachAgent aa = new AttachAgent(device, mTestPackageName, mTestApk);
             aa.prepare();
diff --git a/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java b/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java
index b2c65d5..e86809b 100644
--- a/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java
+++ b/hostsidetests/tzdata/src/com/android/cts/tzdata/TzDataCheckTest.java
@@ -137,14 +137,13 @@
     }
 
     /**
-     * Test the real base files exist in the expected locations - tzcdatacheck relies on some of
-     * them via a command line argument hardcoded in system/core/rootdir/init.rc.
+     * Test the base file used by tzdatacheck exists in the expected location - tzcdatacheck relies
+     * on this file to determine the version of tzdata on device. The path is passed to tzdatacheck
+     * via a command line argument hardcoded in system/core/rootdir/init.rc.
      */
     public void testExpectedBaseFilesExist() throws Exception {
-        String baseTzFilesDir = "/apex/com.android.runtime/etc/tz/";
+        String baseTzFilesDir = "/apex/com.android.tzdata/etc/tz/";
         assertDeviceFileExists(baseTzFilesDir + "tz_version");
-        assertDeviceFileExists(baseTzFilesDir + "tzdata");
-        assertDeviceFileExists(baseTzFilesDir + "tzlookup.xml");
     }
 
     public void testTooFewArgs() throws Exception {
diff --git a/tests/framework/base/activitymanager/app/AndroidManifest.xml b/tests/framework/base/activitymanager/app/AndroidManifest.xml
index 2b91190..b445091 100755
--- a/tests/framework/base/activitymanager/app/AndroidManifest.xml
+++ b/tests/framework/base/activitymanager/app/AndroidManifest.xml
@@ -140,7 +140,6 @@
         />
         <activity android:name=".LaunchIntoPinnedStackPipActivity"
                   android:resizeableActivity="false"
-                  android:supportsPictureInPicture="true"
                   androidprv:alwaysFocusable="true"
                   android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
                   android:exported="true"
diff --git a/tests/signature/TEST_MAPPING b/tests/signature/TEST_MAPPING
index 5e8cc07..1d8741c 100644
--- a/tests/signature/TEST_MAPPING
+++ b/tests/signature/TEST_MAPPING
@@ -46,6 +46,9 @@
       "name": "CtsHiddenApiKillswitchWildcardTestCases"
     },
     {
+      "name": "CtsSystemApiAnnotationTestCases"
+    },
+    {
       "name": "CtsHiddenApiBlacklistApi28TestCases"
     },
     {
diff --git a/tests/signature/api-check/Android.bp b/tests/signature/api-check/Android.bp
index e66d8fe..ceb82a4 100644
--- a/tests/signature/api-check/Android.bp
+++ b/tests/signature/api-check/Android.bp
@@ -31,3 +31,56 @@
         "repackaged.android.test.runner",
     ],
 }
+
+// Defaults for signature api checks.
+java_defaults {
+    name: "signature-api-check-defaults",
+    defaults: ["cts_defaults"],
+    srcs: [
+        "src/**/*.java",
+    ],
+    static_libs: [
+        "cts-api-signature-test",
+    ],
+    jni_libs: [
+        "libclassdescriptors",
+    ],
+    sdk_version: "test_current",
+    compile_multilib: "both",
+}
+
+// Defaults for hiddenapi killswitch checks.
+java_defaults {
+    name: "hiddenapi-killswitch-check-defaults",
+    defaults: ["cts_defaults"],
+
+    compile_multilib: "both",
+    jni_libs: [
+        "libcts_dexchecker",
+        "libclassdescriptors",
+    ],
+    stl: "c++_static",
+
+    // Tag this module as a cts test artifact
+    sdk_version: "test_current",
+    static_libs: ["cts-api-signature-test"],
+}
+
+// Access the hiddenapi-flags.csv file produced by the build.
+hiddenapi_flags {
+    name: "cts-hiddenapi-flags-csv",
+    filename: "hiddenapi-flags.csv",
+}
+
+// Defaults for hiddenapi blacklist checks.
+java_defaults {
+    name: "hiddenapi-blacklist-check-defaults",
+    defaults: ["signature-api-check-defaults"],
+    java_resources: [
+        ":cts-hiddenapi-flags-csv",
+    ],
+    jni_libs: [
+        "libcts_dexchecker",
+    ],
+}
+
diff --git a/tests/signature/api-check/Android.mk b/tests/signature/api-check/Android.mk
index d5b0be2..337f5b9 100644
--- a/tests/signature/api-check/Android.mk
+++ b/tests/signature/api-check/Android.mk
@@ -12,18 +12,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH := $(call my-dir)
-
-# hidden API lists
-# ===================================
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := cts-hiddenapi_flags-csv
-LOCAL_MODULE_STEM := hiddenapi_flags.csv
-LOCAL_MODULE_CLASS := ETC
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-include $(BUILD_SYSTEM)/base_rules.mk
-$(eval $(call copy-one-file,$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS),$(LOCAL_BUILT_MODULE)))
-
-
+LOCAL_PATH:= $(call my-dir)
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/signature/api-check/android-test-base-28-api/Android.bp b/tests/signature/api-check/android-test-base-28-api/Android.bp
new file mode 100644
index 0000000..565aad3
--- /dev/null
+++ b/tests/signature/api-check/android-test-base-28-api/Android.bp
@@ -0,0 +1,31 @@
+// 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.
+
+android_test {
+    name: "CtsAndroidTestBase28ApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-android-test-base-current-txt",
+    ],
+    min_sdk_version: "27",
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/android-test-base-28-api/Android.mk b/tests/signature/api-check/android-test-base-28-api/Android.mk
deleted file mode 100644
index 4196207..0000000
--- a/tests/signature/api-check/android-test-base-28-api/Android.mk
+++ /dev/null
@@ -1,27 +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_PACKAGE_NAME := CtsAndroidTestBase28ApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    android-test-base-current.txt \
-
-LOCAL_MIN_SDK_VERSION := 27
-LOCAL_SDK_VERSION := 28
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/android-test-base-current-api/Android.bp b/tests/signature/api-check/android-test-base-current-api/Android.bp
new file mode 100644
index 0000000..8ddb74f
--- /dev/null
+++ b/tests/signature/api-check/android-test-base-current-api/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.
+
+android_test {
+    name: "CtsAndroidTestBaseCurrentApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-android-test-base-current-txt",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/android-test-base-current-api/Android.mk b/tests/signature/api-check/android-test-base-current-api/Android.mk
deleted file mode 100644
index 07dc14a..0000000
--- a/tests/signature/api-check/android-test-base-current-api/Android.mk
+++ /dev/null
@@ -1,24 +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_PACKAGE_NAME := CtsAndroidTestBaseCurrentApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    android-test-base-current.txt \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/android-test-mock-current-api/Android.bp b/tests/signature/api-check/android-test-mock-current-api/Android.bp
new file mode 100644
index 0000000..e836409
--- /dev/null
+++ b/tests/signature/api-check/android-test-mock-current-api/Android.bp
@@ -0,0 +1,30 @@
+// 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.
+
+android_test {
+    name: "CtsAndroidTestMockCurrentApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-android-test-mock-current-txt",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/android-test-mock-current-api/Android.mk b/tests/signature/api-check/android-test-mock-current-api/Android.mk
deleted file mode 100644
index 8124ff2..0000000
--- a/tests/signature/api-check/android-test-mock-current-api/Android.mk
+++ /dev/null
@@ -1,24 +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_PACKAGE_NAME := CtsAndroidTestMockCurrentApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    android-test-mock-current.txt \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/android-test-runner-current-api/Android.bp b/tests/signature/api-check/android-test-runner-current-api/Android.bp
new file mode 100644
index 0000000..2a6dd7d
--- /dev/null
+++ b/tests/signature/api-check/android-test-runner-current-api/Android.bp
@@ -0,0 +1,32 @@
+// 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.
+
+android_test {
+    name: "CtsAndroidTestRunnerCurrentApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-android-test-base-current-txt",
+        ":cts-android-test-mock-current-txt",
+        ":cts-android-test-runner-current-txt",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/android-test-runner-current-api/Android.mk b/tests/signature/api-check/android-test-runner-current-api/Android.mk
deleted file mode 100644
index b91130e..0000000
--- a/tests/signature/api-check/android-test-runner-current-api/Android.mk
+++ /dev/null
@@ -1,26 +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_PACKAGE_NAME := CtsAndroidTestRunnerCurrentApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    android-test-base-current.txt \
-    android-test-mock-current.txt \
-    android-test-runner-current.txt \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/apache-http-legacy-27-api/Android.bp b/tests/signature/api-check/apache-http-legacy-27-api/Android.bp
new file mode 100644
index 0000000..0c53a34
--- /dev/null
+++ b/tests/signature/api-check/apache-http-legacy-27-api/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.
+
+android_test {
+    name: "CtsApacheHttpLegacy27ApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-current-txt",
+        ":cts-apache-http-legacy-current-txt",
+    ],
+    min_sdk_version: "27",
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/apache-http-legacy-27-api/Android.mk b/tests/signature/api-check/apache-http-legacy-27-api/Android.mk
deleted file mode 100644
index eee5888..0000000
--- a/tests/signature/api-check/apache-http-legacy-27-api/Android.mk
+++ /dev/null
@@ -1,27 +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_PACKAGE_NAME := CtsApacheHttpLegacy27ApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    current.txt \
-    apache-http-legacy-current.txt \
-
-LOCAL_MIN_SDK_VERSION := 27
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/apache-http-legacy-current-api/Android.bp b/tests/signature/api-check/apache-http-legacy-current-api/Android.bp
new file mode 100644
index 0000000..e589ab3
--- /dev/null
+++ b/tests/signature/api-check/apache-http-legacy-current-api/Android.bp
@@ -0,0 +1,30 @@
+// 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.
+
+android_test {
+    name: "CtsApacheHttpLegacyCurrentApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-apache-http-legacy-current-txt",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/apache-http-legacy-current-api/Android.mk b/tests/signature/api-check/apache-http-legacy-current-api/Android.mk
deleted file mode 100644
index e57798c..0000000
--- a/tests/signature/api-check/apache-http-legacy-current-api/Android.mk
+++ /dev/null
@@ -1,24 +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_PACKAGE_NAME := CtsApacheHttpLegacyCurrentApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    apache-http-legacy-current.txt \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/apache-http-legacy-uses-library-api/Android.bp b/tests/signature/api-check/apache-http-legacy-uses-library-api/Android.bp
new file mode 100644
index 0000000..794a952
--- /dev/null
+++ b/tests/signature/api-check/apache-http-legacy-uses-library-api/Android.bp
@@ -0,0 +1,31 @@
+// 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 {
+    name: "CtsApacheHttpLegacyUsesLibraryApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-current-txt",
+        ":cts-apache-http-legacy-current-txt",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/apache-http-legacy-uses-library-api/Android.mk b/tests/signature/api-check/apache-http-legacy-uses-library-api/Android.mk
deleted file mode 100644
index 36e55b0..0000000
--- a/tests/signature/api-check/apache-http-legacy-uses-library-api/Android.mk
+++ /dev/null
@@ -1,25 +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_PACKAGE_NAME := CtsApacheHttpLegacyUsesLibraryApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    current.txt \
-    apache-http-legacy-current.txt \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/build_hidden_apk.mk b/tests/signature/api-check/build_hidden_apk.mk
deleted file mode 100644
index 64c66a9..0000000
--- a/tests/signature/api-check/build_hidden_apk.mk
+++ /dev/null
@@ -1,74 +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.
-
-# Specify the following variables before including:
-#
-#     LOCAL_PACKAGE_NAME
-#         the name of the package
-#
-#     LOCAL_SIGNATURE_API_FILES
-#         the list of api files needed
-
-# don't include this package in any target
-LOCAL_MODULE_TAGS := tests
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_STATIC_JAVA_LIBRARIES += cts-api-signature-test
-
-LOCAL_JNI_SHARED_LIBRARIES += libclassdescriptors
-LOCAL_MULTILIB := both
-
-LOCAL_ADDITIONAL_DEPENDENCIES += \
-    $(addprefix $(COMPATIBILITY_TESTCASES_OUT_cts)/,$(LOCAL_SIGNATURE_API_FILES))
-
-# Add dependencies needed to build/run the test with atest.
-#
-# This is a temporary workaround as described in b/123393637. It adds the dependencies that
-# atest requires for each of the modules specified in the LOCAL_SIGNATURE_API_FILES. The
-# mapping from module name to the dependency is slightly complicated due to inconsistencies
-# in the mapping for the different file types, i.e. .api, .csv and .zip. Those
-# inconsistencies will be resolved by build improvement work mentioned in b/123393637.
-#
-# Converts:
-#     hiddenapi_flags.csv -> $(TARGET_OUT_TESTCASES)/cts-hiddenapi_flags-csv/hiddenapi_flags.csv
-
-# Construct module name directory from file name, matches behavior in the
-# build_xml_api_file function in ../api/Android.mk plus some extra rules for handling slight
-# inconsistencies with that behavior for the ..all.zip files used by some signature tests.
-#   Replace . with -
-#   Prefix every entry with cts-
-#
-cts_signature_module_deps := $(LOCAL_SIGNATURE_API_FILES)
-cts_signature_module_deps := $(subst .,-,$(cts_signature_module_deps))
-cts_signature_module_deps := $(addprefix cts-,$(cts_signature_module_deps))
-
-LOCAL_REQUIRED_MODULES := $(cts_signature_module_deps)
-
-LOCAL_DEX_PREOPT := false
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_USE_EMBEDDED_NATIVE_LIBS := false
-
-ifneq (,$(wildcard $(LOCAL_PATH)/src))
-  LOCAL_SRC_FILES := $(call all-java-files-under, src)
-endif
-
-include $(BUILD_CTS_PACKAGE)
-
-LOCAL_SIGNATURE_API_FILES :=
-cts_signature_module_deps :=
diff --git a/tests/signature/api-check/build_signature_apk.mk b/tests/signature/api-check/build_signature_apk.mk
index 4b002cc..98ff55f 100644
--- a/tests/signature/api-check/build_signature_apk.mk
+++ b/tests/signature/api-check/build_signature_apk.mk
@@ -33,40 +33,26 @@
 LOCAL_JNI_SHARED_LIBRARIES += libclassdescriptors
 LOCAL_MULTILIB := both
 
-LOCAL_ADDITIONAL_DEPENDENCIES += \
-    $(addprefix $(COMPATIBILITY_TESTCASES_OUT_cts)/,$(LOCAL_SIGNATURE_API_FILES))
-
 # Add dependencies needed to build/run the test with atest.
 #
-# This is a temporary workaround as described in b/123393637. It adds the dependencies that
-# atest requires for each of the modules specified in the LOCAL_SIGNATURE_API_FILES. The
-# mapping from module name to the dependency is slightly complicated due to inconsistencies
-# in the mapping for the different file types, i.e. .api, .csv and .zip. Those
-# inconsistencies will be resolved by build improvement work mentioned in b/123393637.
-#
 # Converts:
-#     current.api -> $(TARGET_OUT_TESTCASES)/cts-current-api/current.api
-#     hiddenapi_flags.csv -> $(TARGET_OUT_TESTCASES)/cts-hiddenapi_flags-csv/hiddenapi_flags.csv
-#     system-all.api.zip -> $(TARGET_OUT_TESTCASES)/cts-system-all.api/system-all.api.zip
+#     current.api -> $(SOONG_OUT_DIR)/.intermediates/cts/tests/signature/api/cts-current-txt/gen/current.txt
 
-# Construct module name directory from file name, matches behavior in the
-# build_xml_api_file function in ../api/Android.mk plus some extra rules for handling slight
-# inconsistencies with that behavior for the ..all.zip files used by some signature tests.
+# Construct module name directory from file name, matches location of output of genrules
+# in ../api/Android.bp.
 #   Replace . with -
 #   Prefix every entry with cts-
-#   Replace -all-api-zip with -all.api to handle ...all.zip files
 #
 cts_signature_module_deps := $(LOCAL_SIGNATURE_API_FILES)
 cts_signature_module_deps := $(subst .,-,$(cts_signature_module_deps))
 cts_signature_module_deps := $(addprefix cts-,$(cts_signature_module_deps))
-cts_signature_module_deps := $(subst -all-txt-zip,-all.txt,$(cts_signature_module_deps))
 
 # Construct path to the generated files and add them as java resources.
-cts_signature_module_resources := $(addprefix $(PRODUCT_OUT)/obj/ETC/,$(cts_signature_module_deps))
-cts_signature_module_resources := $(addsuffix _intermediates/,$(cts_signature_module_resources))
+cts_signature_module_resources := $(addprefix $(SOONG_OUT_DIR)/.intermediates/cts/tests/signature/api/,$(cts_signature_module_deps))
+cts_signature_module_resources := $(addsuffix /gen/,$(cts_signature_module_resources))
 cts_signature_module_resources := $(join $(cts_signature_module_resources),$(LOCAL_SIGNATURE_API_FILES))
 
-LOCAL_JAVA_RESOURCE_FILES := $(cts_signature_module_resources)
+LOCAL_JAVA_RESOURCE_FILES += $(cts_signature_module_resources)
 
 LOCAL_DEX_PREOPT := false
 LOCAL_PROGUARD_ENABLED := disabled
diff --git a/tests/signature/api-check/current-api/Android.bp b/tests/signature/api-check/current-api/Android.bp
new file mode 100644
index 0000000..1ca5d11
--- /dev/null
+++ b/tests/signature/api-check/current-api/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.
+
+android_test {
+    name: "CtsCurrentApiSignatureTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    java_resources: [
+        ":cts-current-txt",
+        ":cts-android-test-base-current-txt",
+        ":cts-android-test-mock-current-txt",
+        ":cts-android-test-runner-current-txt",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/current-api/Android.mk b/tests/signature/api-check/current-api/Android.mk
deleted file mode 100644
index bf698ea..0000000
--- a/tests/signature/api-check/current-api/Android.mk
+++ /dev/null
@@ -1,27 +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_PACKAGE_NAME := CtsCurrentApiSignatureTestCases
-
-LOCAL_SIGNATURE_API_FILES := \
-    current.txt \
-    android-test-base-current.txt \
-    android-test-mock-current.txt \
-    android-test-runner-current.txt \
-
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/hidden-api-blacklist-27-api/Android.bp b/tests/signature/api-check/hidden-api-blacklist-27-api/Android.bp
new file mode 100644
index 0000000..7750b14
--- /dev/null
+++ b/tests/signature/api-check/hidden-api-blacklist-27-api/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.
+
+android_test {
+    name: "CtsHiddenApiBlacklistApi27TestCases",
+    defaults: [
+        "hiddenapi-blacklist-check-defaults",
+    ],
+    min_sdk_version: "27",
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/hidden-api-blacklist-27-api/Android.mk b/tests/signature/api-check/hidden-api-blacklist-27-api/Android.mk
deleted file mode 100644
index 3f5cb36..0000000
--- a/tests/signature/api-check/hidden-api-blacklist-27-api/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)
-LOCAL_PACKAGE_NAME := CtsHiddenApiBlacklistApi27TestCases
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SIGNATURE_API_FILES := hiddenapi_flags.csv
-LOCAL_JNI_SHARED_LIBRARIES := libcts_dexchecker
-LOCAL_MIN_SDK_VERSION := 27
-include $(LOCAL_PATH)/../build_hidden_apk.mk
diff --git a/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidManifest.xml b/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidManifest.xml
index cd3949e..144d631 100644
--- a/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidManifest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.hiddenapi_blacklist_api_27">
+          package="android.signature.cts.api.hiddenapi_blacklist_api_27"
+          android:targetSandboxVersion="2">
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
     <uses-sdk android:minSdkVersion="27" android:targetSdkVersion="27" />
diff --git a/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidTest.xml b/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidTest.xml
index e19f874..d168b2d 100644
--- a/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-27-api/AndroidTest.xml
@@ -16,15 +16,8 @@
 <configuration description="Config for CTS Hidden API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
-        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
-        <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
-    </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="hiddenapi_flags.csv->/data/local/tmp/signature-test/hiddenapi_flags.csv" />
-    </target_preparer>
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsHiddenApiBlacklistApi27TestCases.apk" />
@@ -33,7 +26,7 @@
         <option name="package" value="android.signature.cts.api.hiddenapi_blacklist_api_27" />
         <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
         <option name="class" value="android.signature.cts.api.api27.HiddenApiTest" />
-        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi_flags.csv" />
+        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
         <option name="instrumentation-arg" key="hiddenapi-test-flags" value="blacklist" />
         <option name="runtime-hint" value="30s" />
     </test>
diff --git a/tests/signature/api-check/hidden-api-blacklist-28-api/Android.bp b/tests/signature/api-check/hidden-api-blacklist-28-api/Android.bp
new file mode 100644
index 0000000..44ec9ba
--- /dev/null
+++ b/tests/signature/api-check/hidden-api-blacklist-28-api/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.
+
+android_test {
+    name: "CtsHiddenApiBlacklistApi28TestCases",
+    defaults: [
+        "hiddenapi-blacklist-check-defaults",
+    ],
+    min_sdk_version: "27",
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/hidden-api-blacklist-28-api/Android.mk b/tests/signature/api-check/hidden-api-blacklist-28-api/Android.mk
deleted file mode 100644
index 2c6f8f6..0000000
--- a/tests/signature/api-check/hidden-api-blacklist-28-api/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)
-LOCAL_PACKAGE_NAME := CtsHiddenApiBlacklistApi28TestCases
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SIGNATURE_API_FILES := hiddenapi_flags.csv
-LOCAL_JNI_SHARED_LIBRARIES := libcts_dexchecker
-LOCAL_MIN_SDK_VERSION := 27
-include $(LOCAL_PATH)/../build_hidden_apk.mk
diff --git a/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidManifest.xml b/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidManifest.xml
index cb1c4bc..919cd00 100644
--- a/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidManifest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.hiddenapi_blacklist_api_28">
+          package="android.signature.cts.api.hiddenapi_blacklist_api_28"
+          android:targetSandboxVersion="2">
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
     <uses-sdk android:minSdkVersion="27" android:targetSdkVersion="28" />
diff --git a/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidTest.xml b/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidTest.xml
index 3c407b3..6285971 100644
--- a/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-28-api/AndroidTest.xml
@@ -16,15 +16,8 @@
 <configuration description="Config for CTS Hidden API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
-        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
-        <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
-    </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="hiddenapi_flags.csv->/data/local/tmp/signature-test/hiddenapi_flags.csv" />
-    </target_preparer>
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsHiddenApiBlacklistApi28TestCases.apk" />
@@ -33,7 +26,7 @@
         <option name="package" value="android.signature.cts.api.hiddenapi_blacklist_api_28" />
         <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
         <option name="class" value="android.signature.cts.api.api28.HiddenApiTest" />
-        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi_flags.csv" />
+        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
         <option name="instrumentation-arg" key="hiddenapi-test-flags" value="blacklist,greylist-max-o" />
         <option name="runtime-hint" value="30s" />
     </test>
diff --git a/tests/signature/api-check/hidden-api-blacklist-current-api/Android.bp b/tests/signature/api-check/hidden-api-blacklist-current-api/Android.bp
new file mode 100644
index 0000000..ea419f2
--- /dev/null
+++ b/tests/signature/api-check/hidden-api-blacklist-current-api/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.
+
+android_test {
+    name: "CtsHiddenApiBlacklistCurrentApiTestCases",
+    defaults: [
+        "hiddenapi-blacklist-check-defaults",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/hidden-api-blacklist-current-api/Android.mk b/tests/signature/api-check/hidden-api-blacklist-current-api/Android.mk
deleted file mode 100644
index 26f8035..0000000
--- a/tests/signature/api-check/hidden-api-blacklist-current-api/Android.mk
+++ /dev/null
@@ -1,22 +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_PACKAGE_NAME := CtsHiddenApiBlacklistCurrentApiTestCases
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SIGNATURE_API_FILES := hiddenapi_flags.csv
-LOCAL_JNI_SHARED_LIBRARIES := libcts_dexchecker
-include $(LOCAL_PATH)/../build_hidden_apk.mk
diff --git a/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidManifest.xml b/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidManifest.xml
index 4c1528b..a17daac 100644
--- a/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidManifest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.hiddenapi_blacklist_current">
+          package="android.signature.cts.api.hiddenapi_blacklist_current"
+          android:targetSandboxVersion="2">
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
diff --git a/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidTest.xml b/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidTest.xml
index 904f2f1..3fb352d 100644
--- a/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-current-api/AndroidTest.xml
@@ -16,15 +16,8 @@
 <configuration description="Config for CTS Hidden API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
-        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
-        <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
-    </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="hiddenapi_flags.csv->/data/local/tmp/signature-test/hiddenapi_flags.csv" />
-    </target_preparer>
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsHiddenApiBlacklistCurrentApiTestCases.apk" />
@@ -33,7 +26,7 @@
         <option name="package" value="android.signature.cts.api.hiddenapi_blacklist_current" />
         <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
         <option name="class" value="android.signature.cts.api.current.HiddenApiTest" />
-        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi_flags.csv" />
+        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
         <option name="instrumentation-arg" key="hiddenapi-test-flags" value="blacklist,greylist-max-o,greylist-max-p" />
         <option name="runtime-hint" value="30s" />
     </test>
diff --git a/tests/signature/api-check/hidden-api-blacklist-debug-class/Android.bp b/tests/signature/api-check/hidden-api-blacklist-debug-class/Android.bp
new file mode 100644
index 0000000..150ba8c
--- /dev/null
+++ b/tests/signature/api-check/hidden-api-blacklist-debug-class/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.
+
+android_test {
+    name: "CtsHiddenApiBlacklistDebugClassTestCases",
+    defaults: [
+        "hiddenapi-blacklist-check-defaults",
+    ],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/hidden-api-blacklist-debug-class/Android.mk b/tests/signature/api-check/hidden-api-blacklist-debug-class/Android.mk
deleted file mode 100644
index 85bb0a1..0000000
--- a/tests/signature/api-check/hidden-api-blacklist-debug-class/Android.mk
+++ /dev/null
@@ -1,22 +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_PACKAGE_NAME := CtsHiddenApiBlacklistDebugClassTestCases
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_SIGNATURE_API_FILES := hiddenapi_flags.csv
-LOCAL_JNI_SHARED_LIBRARIES := libcts_dexchecker
-include $(LOCAL_PATH)/../build_hidden_apk.mk
diff --git a/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidManifest.xml b/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidManifest.xml
index e0e9a3e..8646c80 100644
--- a/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidManifest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.hiddenapi_blacklist_debug_class">
+          package="android.signature.cts.api.hiddenapi_blacklist_debug_class"
+          android:targetSandboxVersion="2">
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
diff --git a/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidTest.xml b/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidTest.xml
index 9209d59..9c49d41 100644
--- a/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-blacklist-debug-class/AndroidTest.xml
@@ -16,15 +16,8 @@
 <configuration description="Config for CTS Hidden API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
-        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
-        <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
-    </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="hiddenapi_flags.csv->/data/local/tmp/signature-test/hiddenapi_flags.csv" />
-    </target_preparer>
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsHiddenApiBlacklistDebugClassTestCases.apk" />
@@ -33,7 +26,7 @@
         <option name="package" value="android.signature.cts.api.hiddenapi_blacklist_debug_class" />
         <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
         <option name="class" value="android.signature.cts.api.DebugClassHiddenApiTest" />
-        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi_flags.csv" />
+        <option name="instrumentation-arg" key="hiddenapi-files" value="hiddenapi-flags.csv" />
         <option name="instrumentation-arg" key="hiddenapi-test-flags" value="blacklist,greylist-max-o,greylist-max-p" />
         <option name="runtime-hint" value="30s" />
     </test>
diff --git a/tests/signature/api-check/hidden-api-killswitch-debug-class/Android.bp b/tests/signature/api-check/hidden-api-killswitch-debug-class/Android.bp
new file mode 100644
index 0000000..cb86794
--- /dev/null
+++ b/tests/signature/api-check/hidden-api-killswitch-debug-class/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.
+
+android_test {
+    name: "CtsHiddenApiKillswitchDebugClassTestCases",
+    defaults: ["hiddenapi-killswitch-check-defaults"],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/hidden-api-killswitch-debug-class/Android.mk b/tests/signature/api-check/hidden-api-killswitch-debug-class/Android.mk
deleted file mode 100644
index 003eb7f..0000000
--- a/tests/signature/api-check/hidden-api-killswitch-debug-class/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_PACKAGE_NAME := CtsHiddenApiKillswitchDebugClassTestCases
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_MULTILIB := both
-LOCAL_JNI_SHARED_LIBRARIES := libcts_dexchecker libclassdescriptors
-LOCAL_NDK_STL_VARIANT := c++_static
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := cts-api-signature-test
-
-LOCAL_USE_EMBEDDED_NATIVE_LIBS := false
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidManifest.xml b/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidManifest.xml
index 5435b61..b502561 100644
--- a/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidManifest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-debug-class/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.killswitch_debug_class">
+          package="android.signature.cts.api.killswitch_debug_class"
+          android:targetSandboxVersion="2">
 
     <application android:debuggable="true"
                  android:extractNativeLibs="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 7f144c0..68c3e5c 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
@@ -16,7 +16,7 @@
 <configuration description="Config for CTS Hidden API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="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" />
diff --git a/tests/signature/api-check/hidden-api-killswitch-whitelist/Android.bp b/tests/signature/api-check/hidden-api-killswitch-whitelist/Android.bp
new file mode 100644
index 0000000..2c1e8f4
--- /dev/null
+++ b/tests/signature/api-check/hidden-api-killswitch-whitelist/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.
+
+android_test {
+    name: "CtsHiddenApiKillswitchWhitelistTestCases",
+    defaults: ["hiddenapi-killswitch-check-defaults"],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/hidden-api-killswitch-whitelist/Android.mk b/tests/signature/api-check/hidden-api-killswitch-whitelist/Android.mk
deleted file mode 100644
index 5dca9c1..0000000
--- a/tests/signature/api-check/hidden-api-killswitch-whitelist/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_PACKAGE_NAME := CtsHiddenApiKillswitchWhitelistTestCases
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_MULTILIB := both
-LOCAL_JNI_SHARED_LIBRARIES := libcts_dexchecker libclassdescriptors
-LOCAL_NDK_STL_VARIANT := c++_static
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := cts-api-signature-test
-
-LOCAL_USE_EMBEDDED_NATIVE_LIBS := false
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidManifest.xml b/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidManifest.xml
index 35b3e0cb..54f61f9 100644
--- a/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidManifest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.killswitch_whitelist">
+          package="android.signature.cts.api.killswitch_whitelist"
+          android:targetSandboxVersion="2">
 
     <application android:debuggable="true"
                  android:extractNativeLibs="true"
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 b34d6ba..e25bb65 100644
--- a/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-whitelist/AndroidTest.xml
@@ -16,7 +16,7 @@
 <configuration description="Config for CTS Hidden API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <!-- Whitelist all APIs before running the test, then reset this afterwards. The test
diff --git a/tests/signature/api-check/hidden-api-killswitch-wildcard/Android.bp b/tests/signature/api-check/hidden-api-killswitch-wildcard/Android.bp
new file mode 100644
index 0000000..785199e
--- /dev/null
+++ b/tests/signature/api-check/hidden-api-killswitch-wildcard/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.
+
+android_test {
+    name: "CtsHiddenApiKillswitchWildcardTestCases",
+    defaults: ["hiddenapi-killswitch-check-defaults"],
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/hidden-api-killswitch-wildcard/Android.mk b/tests/signature/api-check/hidden-api-killswitch-wildcard/Android.mk
deleted file mode 100644
index ab0eef9..0000000
--- a/tests/signature/api-check/hidden-api-killswitch-wildcard/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_PACKAGE_NAME := CtsHiddenApiKillswitchWildcardTestCases
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_MULTILIB := both
-LOCAL_JNI_SHARED_LIBRARIES := libcts_dexchecker libclassdescriptors
-LOCAL_NDK_STL_VARIANT := c++_static
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := cts-api-signature-test
-
-LOCAL_USE_EMBEDDED_NATIVE_LIBS := false
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidManifest.xml b/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidManifest.xml
index c13d4bb..3747831 100644
--- a/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidManifest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.killswitch_wildcard">
+          package="android.signature.cts.api.killswitch_wildcard"
+          android:targetSandboxVersion="2">
 
     <application android:debuggable="true"
                  android:extractNativeLibs="true"
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 ef41dcc..0363684 100644
--- a/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidTest.xml
+++ b/tests/signature/api-check/hidden-api-killswitch-wildcard/AndroidTest.xml
@@ -16,7 +16,7 @@
 <configuration description="Config for CTS Hidden API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
     <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
         <!-- Enable the killswitch before running the test, then disable it afterwards. The test
diff --git a/tests/signature/api-check/shared-libs-api/Android.mk b/tests/signature/api-check/shared-libs-api/Android.mk
index acc9570..d4d36fb 100644
--- a/tests/signature/api-check/shared-libs-api/Android.mk
+++ b/tests/signature/api-check/shared-libs-api/Android.mk
@@ -31,7 +31,6 @@
 LOCAL_MODULE_STEM := shared-libs-all.txt.zip
 LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_PATH = $(TARGET_OUT_DATA_ETC)
-LOCAL_COMPATIBILITY_SUITE := arcts cts vts general-tests
 include $(BUILD_SYSTEM)/base_rules.mk
 $(LOCAL_BUILT_MODULE): $(SOONG_ZIP)
 $(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBS_FILES := $(all_shared_libs_files)
@@ -41,6 +40,8 @@
 	$(hide) rm -f $@
 	$(hide) $(SOONG_ZIP) -o $@ -P out -C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_SHARED_LIBS_FILES))
 
+all_shared_libs_zip_file := $(LOCAL_BUILT_MODULE)
+
 include $(CLEAR_VARS)
 
 LOCAL_MODULE_TAGS := optional
@@ -62,9 +63,7 @@
 
 LOCAL_PACKAGE_NAME := CtsSharedLibsApiSignatureTestCases
 
-LOCAL_SIGNATURE_API_FILES := \
-    shared-libs-all.txt.zip \
-    $(all_shared_libs_modules)
+LOCAL_JAVA_RESOURCE_FILES := $(all_shared_libs_zip_file)
 
 LOCAL_STATIC_JAVA_LIBRARIES := cts-api-signature-multilib-test
 
@@ -73,4 +72,4 @@
 LOCAL_JAVA_SDK_LIBRARIES :=
 all_shared_libs_files :=
 all_shared_libs_modules :=
-
+all_shared_libs_zip_file :=
diff --git a/tests/signature/api-check/shared-libs-api/AndroidManifest.xml b/tests/signature/api-check/shared-libs-api/AndroidManifest.xml
index 5bdec66..00ddd9a 100644
--- a/tests/signature/api-check/shared-libs-api/AndroidManifest.xml
+++ b/tests/signature/api-check/shared-libs-api/AndroidManifest.xml
@@ -16,7 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.signature.cts.api.shared_libs">
+          package="android.signature.cts.api.shared_libs"
+          android:targetSandboxVersion="2">
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
diff --git a/tests/signature/api-check/shared-libs-api/AndroidTest.xml b/tests/signature/api-check/shared-libs-api/AndroidTest.xml
index 8bd097d..09a9168 100644
--- a/tests/signature/api-check/shared-libs-api/AndroidTest.xml
+++ b/tests/signature/api-check/shared-libs-api/AndroidTest.xml
@@ -16,15 +16,8 @@
 <configuration description="Config for CTS Shared Libraries API Signature test cases">
     <option name="test-suite-tag" value="cts" />
     <option name="config-descriptor:metadata" key="component" value="systems" />
-    <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
     <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
-    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
-        <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
-        <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
-    </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="shared-libs-all.txt.zip->/data/local/tmp/signature-test/shared-libs-all.txt.zip" />
-    </target_preparer>
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsSharedLibsApiSignatureTestCases.apk" />
diff --git a/tests/signature/api-check/shared-libs-api/src/android/signature/cts/api/SignatureMultiLibsTest.java b/tests/signature/api-check/shared-libs-api/src/android/signature/cts/api/SignatureMultiLibsTest.java
index 485ab6c..5499119 100644
--- a/tests/signature/api-check/shared-libs-api/src/android/signature/cts/api/SignatureMultiLibsTest.java
+++ b/tests/signature/api-check/shared-libs-api/src/android/signature/cts/api/SignatureMultiLibsTest.java
@@ -46,7 +46,7 @@
 
             ApiDocumentParser apiDocumentParser = new ApiDocumentParser(TAG);
 
-            parseApiFilesAsStream(apiDocumentParser, expectedApiFiles)
+            parseApiResourcesAsStream(apiDocumentParser, expectedApiFiles)
                     .forEach(complianceChecker::checkSignatureCompliance);
 
             // After done parsing all expected API files, perform any deferred checks.
diff --git a/tests/signature/api-check/src/java/android/signature/cts/api/AbstractApiTest.java b/tests/signature/api-check/src/java/android/signature/cts/api/AbstractApiTest.java
index fc8d996..7e8c6d6 100644
--- a/tests/signature/api-check/src/java/android/signature/cts/api/AbstractApiTest.java
+++ b/tests/signature/api-check/src/java/android/signature/cts/api/AbstractApiTest.java
@@ -41,8 +41,6 @@
 import repackaged.android.test.InstrumentationTestCase;
 import repackaged.android.test.InstrumentationTestRunner;
 
-import static android.signature.cts.CurrentApi.API_FILE_DIRECTORY;
-
 /**
  */
 public class AbstractApiTest extends InstrumentationTestCase {
@@ -112,34 +110,6 @@
         return argument.split(",");
     }
 
-    Stream<Object> readFileOptimized(File file) {
-        try {
-            if (file.getName().endsWith(".zip")) {
-                @SuppressWarnings("resource")
-                ZipFile zip = new ZipFile(file);
-                return zip.stream().map(entry -> {
-                    try {
-                        return zip.getInputStream(entry);
-                    } catch (IOException e) {
-                        throw new RuntimeException(e);
-                    }
-                });
-            } else {
-                try (FileChannel fileChannel = (FileChannel) Files.newByteChannel(file.toPath(),
-                        EnumSet.of(StandardOpenOption.READ))) {
-                    ByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0,
-                            fileChannel.size());
-                    if (mappedByteBuffer == null) {
-                        throw new IllegalStateException("Could not map " + file);
-                    }
-                    return Stream.of(mappedByteBuffer);
-                }
-            }
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     private Stream<VirtualPath> readResource(String resourceName) {
         try {
             ResourcePath resourcePath =
@@ -156,7 +126,7 @@
         }
     }
 
-    private Path extractResourceToFile(String resourceName, InputStream is) throws IOException {
+    Path extractResourceToFile(String resourceName, InputStream is) throws IOException {
         Path tempDirectory = Files.createTempDirectory("signature");
         Path file = tempDirectory.resolve(resourceName);
         Log.i(TAG, "extractResourceToFile: extracting " + resourceName + " to " + file);
@@ -165,7 +135,6 @@
         return file;
     }
 
-
     /**
      * Given a path in the local file system (possibly of a zip file) flatten it into a stream of
      * virtual paths.
@@ -186,7 +155,7 @@
             ApiDocumentParser apiDocumentParser, String[] apiResources) {
         return Stream.of(apiResources)
                 .flatMap(this::readResource)
-                .flatMap(stream -> apiDocumentParser.parseAsStream(stream));
+                .flatMap(apiDocumentParser::parseAsStream);
     }
 
     /**
@@ -200,13 +169,4 @@
         ZipFile zip = new ZipFile(path.toFile());
         return zip.stream().map(entry -> VirtualPath.get(zip, entry));
     }
-
-    Stream<JDiffClassDescription> parseApiFilesAsStream(
-            ApiDocumentParser apiDocumentParser, String[] apiFiles) {
-        LocalFilePath apiFileDirectory = VirtualPath.get(API_FILE_DIRECTORY);
-        return Stream.of(apiFiles)
-                .map(apiFileDirectory::resolve)
-                .flatMap(this::flattenPaths)
-                .flatMap(apiDocumentParser::parseAsStream);
-    }
 }
diff --git a/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java b/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java
index 8efa483..32ab3e9 100644
--- a/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java
+++ b/tests/signature/api-check/src/java/android/signature/cts/api/HiddenApiTest.java
@@ -16,8 +16,6 @@
 
 package android.signature.cts.api;
 
-import static android.signature.cts.CurrentApi.API_FILE_DIRECTORY;
-
 import android.os.Bundle;
 import android.signature.cts.DexApiDocumentParser;
 import android.signature.cts.DexField;
@@ -25,8 +23,15 @@
 import android.signature.cts.DexMemberChecker;
 import android.signature.cts.DexMethod;
 import android.signature.cts.FailureType;
+import android.signature.cts.VirtualPath;
 
-import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.EnumSet;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
 
@@ -39,7 +44,7 @@
     private String[] hiddenapiTestFlags;
 
     @Override
-    protected void initializeFromArgs(Bundle instrumentationArgs) throws Exception {
+    protected void initializeFromArgs(Bundle instrumentationArgs) {
         hiddenapiFiles = getCommaSeparatedList(instrumentationArgs, "hiddenapi-files");
         hiddenapiTestFlags = getCommaSeparatedList(instrumentationArgs, "hiddenapi-test-flags");
     }
@@ -136,7 +141,7 @@
                     }
                 }
             };
-            parseDexApiFilesAsStream(hiddenapiFiles)
+            parseDexApiResourcesAsStream(hiddenapiFiles)
                     .filter(memberFilter)
                     .forEach(dexMember -> {
                         if (shouldTestMember(dexMember)) {
@@ -147,14 +152,13 @@
         });
     }
 
-    private Stream<DexMember> parseDexApiFilesAsStream(String[] apiFiles) {
+    private Stream<DexMember> parseDexApiResourcesAsStream(String[] apiFiles) {
         DexApiDocumentParser dexApiDocumentParser = new DexApiDocumentParser();
         // To allow parallelization with a DexMember output type, we need two
         // pipes.
         Stream<Stream<DexMember>> inputsAsStreams = Stream.of(apiFiles).parallel()
-                .map(name -> new File(API_FILE_DIRECTORY + "/" + name))
-                .flatMap(file -> readFileOptimized(file))
-                .map(obj -> dexApiDocumentParser.parseAsStream(obj));
+                .flatMap(this::readResourceOptimized)
+                .map(dexApiDocumentParser::parseAsStream);
         // The flatMap inherently serializes the pipe. The number of inputs is
         // still small here, so reduce by concatenating (note the caveats of
         // concats).
@@ -166,6 +170,31 @@
         });
     }
 
+    private Stream<Object> readResourceOptimized(String resourceName) {
+        try {
+            VirtualPath.ResourcePath resourcePath =
+                    VirtualPath.get(getClass().getClassLoader(), resourceName);
+            // Extract to a temporary file and read from there. Accessing it via an InputStream
+            // directly is too slow because the file has to be read serially and that results in
+            // the tests taking too long. Saving it as a file allows it to be mapped as a
+            // ByteBuffer and processed in parallel.
+            Path file = extractResourceToFile(resourceName, resourcePath.newInputStream());
+
+            // Map the file into a ByteBuffer, see http://b/123986482 for some background.
+            try (FileChannel fileChannel = (FileChannel) Files.newByteChannel(file,
+                    EnumSet.of(StandardOpenOption.READ))) {
+                ByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0,
+                        fileChannel.size());
+                if (mappedByteBuffer == null) {
+                    throw new IllegalStateException("Could not map " + file);
+                }
+                return Stream.of(mappedByteBuffer);
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
     private boolean shouldTestMember(DexMember member) {
         for (String testFlag : hiddenapiTestFlags) {
             for (String memberFlag : member.getHiddenapiFlags()) {
diff --git a/tests/signature/api-check/system-annotation/Android.bp b/tests/signature/api-check/system-annotation/Android.bp
new file mode 100644
index 0000000..b423593
--- /dev/null
+++ b/tests/signature/api-check/system-annotation/Android.bp
@@ -0,0 +1,37 @@
+// 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.
+
+android_test {
+    name: "CtsSystemApiAnnotationTestCases",
+    defaults: [
+        "signature-api-check-defaults",
+    ],
+    static_libs: [
+        "compatibility-device-util-axt",
+    ],
+    java_resources: [
+        ":cts-system-current-txt",
+        ":cts-system-removed-txt",
+        ":cts-car-system-current-txt",
+        ":cts-car-system-removed-txt",
+    ],
+    min_sdk_version: "27",
+
+    use_embedded_native_libs: false,
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/tests/signature/api-check/system-annotation/Android.mk b/tests/signature/api-check/system-annotation/Android.mk
deleted file mode 100644
index 888e05a..0000000
--- a/tests/signature/api-check/system-annotation/Android.mk
+++ /dev/null
@@ -1,29 +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_PACKAGE_NAME := CtsSystemApiAnnotationTestCases
-LOCAL_SRC_FILES := $(call all-java-files-under,src)
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util-axt
-LOCAL_SIGNATURE_API_FILES := \
-    system-current.txt \
-    system-removed.txt \
-    car-system-current.txt \
-    car-system-removed.txt \
-
-LOCAL_MIN_SDK_VERSION := 27
-include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/system-api/Android.mk b/tests/signature/api-check/system-api/Android.mk
index d699b83..7605f85 100644
--- a/tests/signature/api-check/system-api/Android.mk
+++ b/tests/signature/api-check/system-api/Android.mk
@@ -14,7 +14,7 @@
 
 LOCAL_PATH := $(call my-dir)
 
-all_system_api_modules := system-current.txt system-removed.txt
+all_system_api_modules :=
 $(foreach ver,$(PLATFORM_SYSTEMSDK_VERSIONS),\
   $(if $(call math_is_number,$(ver)),\
     $(eval all_system_api_modules += system-$(ver).txt)\
@@ -37,18 +37,23 @@
 	$(hide) rm -f $@
 	$(hide) $(SOONG_ZIP) -o $@ -P out -C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_SYSTEM_API_FILES))
 
+all_system_api_zip_file := $(LOCAL_BUILT_MODULE)
+
 include $(CLEAR_VARS)
 
 LOCAL_PACKAGE_NAME := CtsSystemApiSignatureTestCases
 
+LOCAL_JAVA_RESOURCE_FILES := $(all_system_api_zip_file)
+
 LOCAL_SIGNATURE_API_FILES := \
     current.txt \
     android-test-mock-current.txt \
     android-test-runner-current.txt \
-    $(all_sytem_api_modules) \
-    system-all.txt.zip
+    system-current.txt \
+    system-removed.txt \
 
 include $(LOCAL_PATH)/../build_signature_apk.mk
 
 all_system_api_files :=
 all_system_api_modules :=
+all_system_api_zip_file :=
diff --git a/tests/signature/api-check/system-api/AndroidTest.xml b/tests/signature/api-check/system-api/AndroidTest.xml
index 54c2bd0a..3368b77 100644
--- a/tests/signature/api-check/system-api/AndroidTest.xml
+++ b/tests/signature/api-check/system-api/AndroidTest.xml
@@ -27,7 +27,7 @@
         <option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
         <option name="class" value="android.signature.cts.api.system.SignatureTest" />
         <option name="instrumentation-arg" key="base-api-files" value="current.txt" />
-        <option name="instrumentation-arg" key="expected-api-files" value="system-all.txt.zip" />
+        <option name="instrumentation-arg" key="expected-api-files" value="system-current.txt,system-removed.txt,system-all.txt.zip" />
         <option name="instrumentation-arg" key="unexpected-api-files" value="android-test-mock-current.txt,android-test-runner-current.txt" />
         <option name="runtime-hint" value="30s" />
     </test>
diff --git a/tests/signature/api/Android.bp b/tests/signature/api/Android.bp
new file mode 100644
index 0000000..8c3e12a
--- /dev/null
+++ b/tests/signature/api/Android.bp
@@ -0,0 +1,126 @@
+// 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.
+
+default_visibility = [
+    "//cts/tests/signature/api-check:__subpackages__",
+    "//cts/tests/signature/intent-check",
+]
+
+genrule {
+    name: "cts-current-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":frameworks-base-api-current.txt",
+    ],
+    out: [
+        "current.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-system-current-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":frameworks-base-api-system-current.txt",
+    ],
+    out: [
+        "system-current.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-system-removed-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":frameworks-base-api-system-removed.txt",
+    ],
+    out: [
+        "system-removed.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-android-test-base-current-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":android-test-base-current.txt",
+    ],
+    out: [
+        "android-test-base-current.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-android-test-mock-current-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":android-test-mock-current.txt",
+    ],
+    out: [
+        "android-test-mock-current.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-android-test-runner-current-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":android-test-runner-current.txt",
+    ],
+    out: [
+        "android-test-runner-current.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-apache-http-legacy-current-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":apache-http-legacy-current.txt",
+    ],
+    out: [
+        "apache-http-legacy-current.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-car-system-current-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":car-api-system-current.txt",
+    ],
+    out: [
+        "car-system-current.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
+
+genrule {
+    name: "cts-car-system-removed-txt",
+    visibility: default_visibility,
+    srcs: [
+        ":car-api-system-removed.txt",
+    ],
+    out: [
+        "car-system-removed.txt",
+    ],
+    cmd: "cp $(in) $(out)",
+}
diff --git a/tests/signature/api/Android.mk b/tests/signature/api/Android.mk
index c3aca10..96afc10 100644
--- a/tests/signature/api/Android.mk
+++ b/tests/signature/api/Android.mk
@@ -26,22 +26,10 @@
 LOCAL_COMPATIBILITY_SUITE := arcts cts vts general-tests
 include $(BUILD_SYSTEM)/base_rules.mk
 $$(LOCAL_BUILT_MODULE): $(2) | $(APICHECK)
-#	@echo "Convert API file $$< -> $$@"
-#	@mkdir -p $$(dir $$@)
-#	$(hide) $(APICHECK_COMMAND) -convert2xmlnostrip $$< $$@
 	@echo "Copying API file $$< -> $$@"
 	$$(copy-file-to-target)
 endef
 
-$(eval $(call copy_api_txt_file,current.txt,frameworks/base/api/current.txt))
-$(eval $(call copy_api_txt_file,system-current.txt,frameworks/base/api/system-current.txt))
-$(eval $(call copy_api_txt_file,system-removed.txt,frameworks/base/api/system-removed.txt))
-$(eval $(call copy_api_txt_file,apache-http-legacy-current.txt,external/apache-http/api/current.txt))
-$(eval $(call copy_api_txt_file,android-test-base-current.txt,frameworks/base/test-base/api/current.txt))
-$(eval $(call copy_api_txt_file,android-test-mock-current.txt,frameworks/base/test-mock/api/current.txt))
-$(eval $(call copy_api_txt_file,android-test-runner-current.txt,frameworks/base/test-runner/api/current.txt))
-$(eval $(call copy_api_txt_file,car-system-current.txt,packages/services/Car/car-lib/api/system-current.txt))
-$(eval $(call copy_api_txt_file,car-system-removed.txt,packages/services/Car/car-lib/api/system-removed.txt))
 $(foreach ver,$(PLATFORM_SYSTEMSDK_VERSIONS),\
   $(if $(call math_is_number,$(ver)),\
     $(eval $(call copy_api_txt_file,system-$(ver).txt,prebuilts/sdk/$(ver)/system/api/android.txt))\
diff --git a/tests/signature/intent-check/Android.bp b/tests/signature/intent-check/Android.bp
new file mode 100644
index 0000000..299e2b7
--- /dev/null
+++ b/tests/signature/intent-check/Android.bp
@@ -0,0 +1,42 @@
+// 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.
+
+android_test {
+    name: "CtsIntentSignatureTestCases",
+    defaults: ["cts_defaults"],
+
+    srcs: ["src/**/*.java"],
+    java_resources: [
+        ":cts-current-txt",
+        ":cts-system-current-txt",
+        ":cts-system-removed-txt",
+    ],
+
+    // Tag this module as a cts test artifact
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+
+    sdk_version: "test_current",
+
+    static_libs: [
+        "compatibility-device-util-axt",
+        "androidx.test.rules",
+        "cts-signature-common",
+    ],
+
+    host_required: ["cts-dynamic-config"],
+}
diff --git a/tests/signature/intent-check/Android.mk b/tests/signature/intent-check/Android.mk
deleted file mode 100644
index 98e19ff..0000000
--- a/tests/signature/intent-check/Android.mk
+++ /dev/null
@@ -1,42 +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)
-
-# don't include this package in any target
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsIntentSignatureTestCases
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    compatibility-device-util-axt \
-    androidx.test.rules \
-    cts-signature-common \
-
-LOCAL_HOST_REQUIRED_MODULES := cts-dynamic-config
-
-LOCAL_REQUIRED_MODULES := \
-    cts-current-txt \
-    cts-system-current-txt \
-    cts-system-removed-txt
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/signature/intent-check/AndroidTest.xml b/tests/signature/intent-check/AndroidTest.xml
index ff4250a..40968ec 100644
--- a/tests/signature/intent-check/AndroidTest.xml
+++ b/tests/signature/intent-check/AndroidTest.xml
@@ -34,15 +34,6 @@
         <option name="run-command" value="mkdir -p /data/local/tmp/signature-test" />
         <option name="teardown-command" value="rm -rf /data/local/tmp/signature-test" />
     </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="current.txt->/data/local/tmp/signature-test/current.txt" />
-    </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="system-current.txt->/data/local/tmp/signature-test/system-current.txt" />
-    </target_preparer>
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
-        <option name="push" value="system-removed.txt->/data/local/tmp/signature-test/system-removed.txt" />
-    </target_preparer>
     <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="CtsIntentSignatureTestCases.apk" />
diff --git a/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
index 6ee8434..0195dc4 100644
--- a/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
+++ b/tests/signature/intent-check/src/android/signature/cts/intent/IntentTest.java
@@ -18,7 +18,6 @@
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.signature.cts.ApiDocumentParser;
-import android.signature.cts.CurrentApi;
 import android.signature.cts.JDiffClassDescription.JDiffField;
 import android.signature.cts.VirtualPath;
 import android.util.Log;
@@ -28,6 +27,7 @@
 
 import com.android.compatibility.common.util.DynamicConfigDeviceSide;
 
+import java.io.IOException;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -48,18 +48,15 @@
 @RunWith(AndroidJUnit4.class)
 public class IntentTest {
 
-    private static final String CURRENT_API_FILE =
-            CurrentApi.API_FILE_DIRECTORY + "/current.txt";
+    private static final String CURRENT_API_RESOURCE = "current.txt";
 
-    private static final String SYSTEM_CURRENT_API_FILE =
-            CurrentApi.API_FILE_DIRECTORY + "/system-current.txt";
+    private static final String SYSTEM_CURRENT_API_RESOURCE = "system-current.txt";
 
-    private static final String SYSTEM_REMOVED_API_FILE =
-            CurrentApi.API_FILE_DIRECTORY + "/system-removed.txt";
+    private static final String SYSTEM_REMOVED_API_RESOURCE = "system-removed.txt";
 
     private static final String TAG = IntentTest.class.getSimpleName();
 
-    private static final File SIGNATURE_TEST_PACKGES =
+    private static final File SIGNATURE_TEST_PACKAGES =
             new File("/data/local/tmp/signature-test-packages");
     private static final String ANDROID_INTENT_PREFIX = "android.intent.action";
     private static final String ACTION_LINE_PREFIX = "          Action: ";
@@ -116,21 +113,23 @@
         Assert.assertTrue(errors.toString(), errors.isEmpty());
     }
 
-    private Set<String> lookupPlatformIntents() {
+    private Set<String> lookupPlatformIntents() throws IOException {
         Set<String> intents = new HashSet<>();
-        intents.addAll(parse(CURRENT_API_FILE));
-        intents.addAll(parse(SYSTEM_CURRENT_API_FILE));
-        intents.addAll(parse(SYSTEM_REMOVED_API_FILE));
+        intents.addAll(parse(CURRENT_API_RESOURCE));
+        intents.addAll(parse(SYSTEM_CURRENT_API_RESOURCE));
+        intents.addAll(parse(SYSTEM_REMOVED_API_RESOURCE));
         return intents;
     }
 
-    private static Set<String> parse(String apiFileName) {
+    private static Set<String> parse(String apiResourceName) throws IOException {
 
         Set<String> androidIntents = new HashSet<>();
 
         ApiDocumentParser apiDocumentParser = new ApiDocumentParser(TAG);
 
-        apiDocumentParser.parseAsStream(VirtualPath.get(apiFileName)).forEach(
+        VirtualPath.ResourcePath virtualPath =
+                VirtualPath.get(IntentTest.class.getClassLoader(), apiResourceName);
+        apiDocumentParser.parseAsStream(virtualPath).forEach(
                 classDescription -> {
                     for (JDiffField diffField : classDescription.getFieldList()) {
                         String fieldValue = diffField.getValueString();
@@ -156,7 +155,7 @@
 
     private static Set<String> lookupActiveIntents(String packageName) {
         HashSet<String> activeIntents = new HashSet<>();
-        File dumpsysPackage = new File(SIGNATURE_TEST_PACKGES, packageName + ".txt");
+        File dumpsysPackage = new File(SIGNATURE_TEST_PACKAGES, packageName + ".txt");
         if (!dumpsysPackage.exists() || dumpsysPackage.length() == 0) {
           throw new RuntimeException("Missing package info: " + dumpsysPackage.getAbsolutePath());
         }
diff --git a/tests/tests/binder_ndk/Android.bp b/tests/tests/binder_ndk/Android.bp
new file mode 100644
index 0000000..fe5bf2a
--- /dev/null
+++ b/tests/tests/binder_ndk/Android.bp
@@ -0,0 +1,39 @@
+// 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 {
+    name: "CtsNdkBinderTestCases",
+    defaults: ["cts_defaults"],
+    compile_multilib: "both",
+    test_suites: [
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+    static_libs: [
+        "ctstestrunner-axt",
+        "libbinder_ndk_test_interface-java",
+        "nativetesthelper",
+    ],
+    jni_libs: [
+        "libbinder_ndk_test",
+        "libbinder_ndk_test_utilities",
+        "libbinder_ndk_test_interface-ndk",
+        "libbinder_ndk_test_interface_old",
+        "libbinder_ndk_test_interface_new",
+    ],
+    stl: "c++_shared",
+    srcs: ["src/**/*.java"],
+    sdk_version: "current",
+}
diff --git a/tests/tests/binder_ndk/Android.mk b/tests/tests/binder_ndk/Android.mk
deleted file mode 100644
index 4851346..0000000
--- a/tests/tests/binder_ndk/Android.mk
+++ /dev/null
@@ -1,50 +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_PACKAGE_NAME := CtsNdkBinderTestCases
-
-# Don't include this package in any target.
-LOCAL_MODULE_TAGS := optional
-
-# Include both the 32 and 64 bit versions
-LOCAL_MULTILIB := both
-
-# When built, explicitly put it in the data partition.
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    ctstestrunner-axt \
-    libbinder_ndk_test_interface-java \
-    nativetesthelper
-
-LOCAL_JNI_SHARED_LIBRARIES := \
-    libbinder_ndk_test \
-    libbinder_ndk_test_utilities \
-    libbinder_ndk_test_interface-ndk \
-    libbinder_ndk_test_interface_old \
-    libbinder_ndk_test_interface_new \
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_SDK_VERSION := current
-LOCAL_NDK_STL_VARIANT := c++_shared
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/binder_ndk/libbinder_ndk_test/Android.bp b/tests/tests/binder_ndk/libbinder_ndk_test/Android.bp
index 761e020..a7a3981 100644
--- a/tests/tests/binder_ndk/libbinder_ndk_test/Android.bp
+++ b/tests/tests/binder_ndk/libbinder_ndk_test/Android.bp
@@ -31,62 +31,56 @@
 
 cc_defaults {
     name: "libbinder_ndk_test_defaults",
-
     cflags: [
         "-Wall",
         "-Werror",
     ],
-
     shared_libs: [
         "liblog",
         "libbinder_ndk",
     ],
     whole_static_libs: ["libnativetesthelper_jni"],
-
     sdk_version: "current",
-    stl: "c++_static",
+    stl: "c++_shared",
+    gtest: false,
 }
 
-cc_library_shared {
+cc_test_library {
     name: "libbinder_ndk_test_utilities",
     defaults: ["libbinder_ndk_test_defaults"],
     srcs: ["utilities.cpp"],
 }
 
-cc_library_shared {
+cc_test_library {
     name: "libbinder_ndk_test_interface_new",
     defaults: ["libbinder_ndk_test_defaults"],
     srcs: [
         "android_binder_cts_NativeService.cpp",
     ],
-
     // Using the up-to-date version of the interface
-
     shared_libs: [
         "libbinder_ndk_test_interface-ndk",
         "libbinder_ndk_test_utilities",
     ],
 }
 
-cc_library_shared {
+cc_test_library {
     name: "libbinder_ndk_test_interface_old",
     defaults: ["libbinder_ndk_test_defaults"],
     srcs: [
         "android_binder_cts_NativeService.cpp",
     ],
     cflags: ["-DUSING_VERSION_1"],
-
     // Using the frozen version 1 of the interface
     static_libs: [
         "libbinder_ndk_test_interface-V1-ndk",
     ],
-
     shared_libs: [
         "libbinder_ndk_test_utilities",
     ],
 }
 
-cc_library_shared {
+cc_test_library {
     name: "libbinder_ndk_test",
     defaults: ["libbinder_ndk_test_defaults"],
     srcs: [
@@ -96,7 +90,6 @@
         "test_parcel.cpp",
         "test_status.cpp",
     ],
-
     shared_libs: [
         "libbinder_ndk_test_interface-ndk",
         "libbinder_ndk_test_utilities",
diff --git a/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java b/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java
index 0efa97e..0111871 100644
--- a/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java
+++ b/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java
@@ -471,7 +471,7 @@
         // {@link TelephonyManager#iccOpenLogicalChannel} sends a Manage Channel (open) APDU
         // followed by a Select APDU with the given AID and p2 values. See Open Mobile API
         // Specification v3.2 Section 6.2.7.h and TS 102 221 for details.
-        int p2 = 0;
+        int p2 = 0x0C; // '0C' for no data returned (TS 102 221 Section 11.1.1.2)
         response = mTelephonyManager.iccOpenLogicalChannel("", p2);
         verifyValidIccOpenLogicalChannelResponse(response);
         mTelephonyManager.iccCloseLogicalChannel(response.getChannel());
diff --git a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
index f901e9c..1bafaa04 100644
--- a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
+++ b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
@@ -49,7 +49,7 @@
 public class SQLiteDatabaseTest extends AndroidTestCase {
 
     private static final String TAG = "SQLiteDatabaseTest";
-    private static final String EXPECTED_MAJOR_MINOR_VERSION = "3.22";
+    private static final String EXPECTED_MAJOR_MINOR_VERSION = "3.28";
     private static final int EXPECTED_MIN_PATCH_LEVEL = 0;
 
     private SQLiteDatabase mDatabase;
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableScaleTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableScaleTest.java
deleted file mode 100644
index 29afaaf..0000000
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/VectorDrawableScaleTest.java
+++ /dev/null
@@ -1,106 +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 android.graphics.drawable.cts;
-
-import android.app.Activity;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Rect;
-import android.graphics.cts.R;
-import android.view.PixelCopy;
-import android.widget.ImageView;
-
-import androidx.test.filters.MediumTest;
-import androidx.test.rule.ActivityTestRule;
-
-import com.android.compatibility.common.util.SynchronousPixelCopy;
-import com.android.compatibility.common.util.WidgetTestUtils;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-@MediumTest
-public class VectorDrawableScaleTest {
-    private static final boolean DBG_SCREENSHOT = false;
-    @Rule
-    public final ActivityTestRule<DrawableStubActivity> mActivityRule =
-            new ActivityTestRule<>(DrawableStubActivity.class);
-
-    private Activity mActivity = null;
-    private Resources mResources = null;
-
-    public VectorDrawableScaleTest() throws Throwable {
-    }
-
-    @Before
-    public void setup() {
-        mActivity = mActivityRule.getActivity();
-        mResources = mActivity.getResources();
-    }
-
-    @Test
-    public void testVectorDrawableInImageView() throws Throwable {
-        mActivityRule.runOnUiThread(() -> {
-            mActivity.setContentView(R.layout.vector_drawable_scale_layout);
-        });
-
-        Bitmap screenShot = null;
-        WidgetTestUtils.runOnMainAndDrawSync(mActivityRule,
-                mActivity.findViewById(R.id.scaletest),
-                () -> setupImageViews());
-        final Rect srcRect = new Rect();
-        mActivityRule.runOnUiThread(() -> {
-            mActivity.findViewById(R.id.imageview1).getGlobalVisibleRect(srcRect);
-        });
-
-        screenShot = takeScreenshot(srcRect);
-        if (DBG_SCREENSHOT) {
-            String outputFolder = mActivity.getExternalFilesDir(null).getAbsolutePath();
-            DrawableTestUtils.saveVectorDrawableIntoPNG(screenShot, outputFolder, "scale");
-        }
-
-        Bitmap golden = BitmapFactory.decodeResource(mResources,
-                R.drawable.vector_drawable_scale_golden);
-        DrawableTestUtils.compareImages("vectorDrawableScale", screenShot, golden,
-                DrawableTestUtils.PIXEL_ERROR_THRESHOLD,
-                DrawableTestUtils.PIXEL_ERROR_COUNT_THRESHOLD,
-                DrawableTestUtils.PIXEL_ERROR_TOLERANCE);
-    }
-
-    // Setup 2 imageviews, one big and one small. The purpose of this test is to make sure that the
-    // imageview with smaller scale will not affect the appearance in the imageview with larger
-    // scale.
-    private void setupImageViews() {
-        ImageView imageView = (ImageView) mActivity.findViewById(R.id.imageview1);
-        imageView.setImageResource(R.drawable.vector_icon_create);
-        imageView = (ImageView) mActivity.findViewById(R.id.imageview2);
-        imageView.setImageResource(R.drawable.vector_icon_create);
-    }
-
-    // Copy the source rectangle from the screen into the returned bitmap.
-    private Bitmap takeScreenshot(Rect srcRect) {
-        SynchronousPixelCopy copy = new SynchronousPixelCopy();
-        Bitmap dest = Bitmap.createBitmap(
-                srcRect.width(), srcRect.height(), Bitmap.Config.ARGB_8888);
-        int copyResult = copy.request(mActivity.getWindow(), srcRect, dest);
-        Assert.assertEquals(PixelCopy.SUCCESS, copyResult);
-        return dest;
-    }
-}
diff --git a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
index 8c9bf6e..e9deec9 100644
--- a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -35,6 +35,7 @@
 
 import static com.android.compatibility.common.util.SystemUtil.runShellCommand;
 
+import android.annotation.NonNull;
 import android.app.Instrumentation;
 import android.app.PendingIntent;
 import android.app.UiAutomation;
@@ -59,6 +60,7 @@
 import android.net.cts.util.CtsNetUtils;
 import android.net.util.KeepaliveUtils;
 import android.net.wifi.WifiManager;
+import android.os.Build;
 import android.os.Looper;
 import android.os.MessageQueue;
 import android.os.SystemClock;
@@ -99,6 +101,7 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -113,6 +116,8 @@
     private static final int CONNECT_TIMEOUT_MS = 2000;
     private static final int KEEPALIVE_CALLBACK_TIMEOUT_MS = 2000;
     private static final int KEEPALIVE_SOCKET_TIMEOUT_MS = 5000;
+    private static final int INTERVAL_KEEPALIVE_RETRY_MS = 500;
+    private static final int MAX_KEEPALIVE_RETRY_COUNT = 3;
     private static final int MIN_KEEPALIVE_INTERVAL = 10;
     private static final int NETWORK_CHANGE_METEREDNESS_TIMEOUT = 5000;
     private static final int NUM_TRIES_MULTIPATH_PREF_CHECK = 20;
@@ -120,6 +125,10 @@
     // device could have only one interface: data, wifi.
     private static final int MIN_NUM_NETWORK_TYPES = 1;
 
+    // Minimum supported keepalive counts for wifi and cellular.
+    public static final int MIN_SUPPORTED_CELLULAR_KEEPALIVE_COUNT = 1;
+    public static final int MIN_SUPPORTED_WIFI_KEEPALIVE_COUNT = 3;
+
     private Context mContext;
     private Instrumentation mInstrumentation;
     private ConnectivityManager mCm;
@@ -839,8 +848,7 @@
         return s;
     }
 
-    private int getSupportedKeepalivesFromRes() throws Exception {
-        final Network network = ensureWifiConnected();
+    private int getSupportedKeepalivesForNet(@NonNull Network network) throws Exception {
         final NetworkCapabilities nc = mCm.getNetworkCapabilities(network);
 
         // Get number of supported concurrent keepalives for testing network.
@@ -914,34 +922,46 @@
      * keepalives is set to 0.
      */
     @AppModeFull(reason = "Cannot get WifiManager in instant app mode")
-    public void testKeepaliveUnsupported() throws Exception {
-        if (getSupportedKeepalivesFromRes() != 0) return;
+    public void testKeepaliveWifiUnsupported() throws Exception {
+        if (!mPackageManager.hasSystemFeature(FEATURE_WIFI)) {
+            Log.i(TAG, "testKeepaliveUnsupported cannot execute unless device"
+                    + " supports WiFi");
+            return;
+        }
+
+        final Network network = ensureWifiConnected();
+        if (getSupportedKeepalivesForNet(network) != 0) return;
 
         adoptShellPermissionIdentity();
 
-        assertEquals(0, createConcurrentSocketKeepalives(1, 0));
-        assertEquals(0, createConcurrentSocketKeepalives(0, 1));
+        assertEquals(0, createConcurrentSocketKeepalives(network, 1, 0));
+        assertEquals(0, createConcurrentSocketKeepalives(network, 0, 1));
 
         dropShellPermissionIdentity();
     }
 
     @AppModeFull(reason = "Cannot get WifiManager in instant app mode")
     public void testCreateTcpKeepalive() throws Exception {
+        if (!mPackageManager.hasSystemFeature(FEATURE_WIFI)) {
+            Log.i(TAG, "testCreateTcpKeepalive cannot execute unless device supports WiFi");
+            return;
+        }
+
         adoptShellPermissionIdentity();
 
-        if (getSupportedKeepalivesFromRes() == 0) return;
+        final Network network = ensureWifiConnected();
+        if (getSupportedKeepalivesForNet(network) == 0) return;
         // If kernel < 4.8 then it doesn't support TCP keepalive, but it might still support
         // NAT-T keepalive. If keepalive limits from resource overlay is not zero, TCP keepalive
         // needs to be supported except if the kernel doesn't support it.
         if (!isTcpKeepaliveSupportedByKernel()) {
             // Sanity check to ensure the callback result is expected.
-            assertEquals(0, createConcurrentSocketKeepalives(0, 1));
+            assertEquals(0, createConcurrentSocketKeepalives(network, 0, 1));
             Log.i(TAG, "testCreateTcpKeepalive is skipped for kernel "
                     + VintfRuntimeInfo.getKernelVersion());
             return;
         }
 
-        final Network network = ensureWifiConnected();
         final byte[] requestBytes = CtsNetUtils.HTTP_REQUEST.getBytes("UTF-8");
         // So far only ipv4 tcp keepalive offload is supported.
         // TODO: add test case for ipv6 tcp keepalive offload when it is supported.
@@ -1007,80 +1027,102 @@
         }
     }
 
-    /**
-     * Creates concurrent keepalives until the specified counts of each type of keepalives are
-     * reached or the expected error callbacks are received for each type of keepalives.
-     *
-     * @return the total number of keepalives created.
-     */
-    private int createConcurrentSocketKeepalives(int nattCount, int tcpCount) throws Exception {
-        final Network network = ensureWifiConnected();
-
+    private ArrayList<SocketKeepalive> createConcurrentKeepalivesOfType(
+            int requestCount, @NonNull TestSocketKeepaliveCallback callback,
+            Supplier<SocketKeepalive> kaFactory) {
         final ArrayList<SocketKeepalive> kalist = new ArrayList<>();
-        final TestSocketKeepaliveCallback callback = new TestSocketKeepaliveCallback();
-        final Executor executor = mContext.getMainExecutor();
 
-        // Create concurrent TCP keepalives.
-        for (int i = 0; i < tcpCount; i++) {
-            // Assert that TCP connections can be established on wifi. The file descriptor of tcp
-            // sockets will be duplicated and kept valid in service side if the keepalives are
-            // successfully started.
-            try (Socket tcpSocket = getConnectedSocket(network, TEST_HOST, HTTP_PORT,
-                        0 /* Unused */, AF_INET)) {
-                final SocketKeepalive ka = mCm.createSocketKeepalive(network, tcpSocket, executor,
-                        callback);
-                ka.start(MIN_KEEPALIVE_INTERVAL);
-                TestSocketKeepaliveCallback.CallbackValue cv = callback.pollCallback();
-                assertNotNull(cv);
-                if (cv.callbackType == TestSocketKeepaliveCallback.CallbackType.ON_ERROR) {
-                    if (i == 0 && cv.error == SocketKeepalive.ERROR_UNSUPPORTED) {
-                        // Unsupported.
-                        break;
-                    } else if (i != 0 && cv.error == SocketKeepalive.ERROR_INSUFFICIENT_RESOURCES) {
-                        // Limit reached.
-                        break;
-                    }
-                }
-                if (cv.callbackType == TestSocketKeepaliveCallback.CallbackType.ON_STARTED) {
-                    kalist.add(ka);
-                } else {
-                    fail("Unexpected error when creating " + (i + 1) + " TCP keepalives: " + cv);
-                }
-            }
-        }
+        int remainingRetries = MAX_KEEPALIVE_RETRY_COUNT;
 
-        // Assert that a Nat-T socket can be created.
-        final IpSecManager mIpSec = (IpSecManager) mContext.getSystemService(Context.IPSEC_SERVICE);
-        final UdpEncapsulationSocket nattSocket = mIpSec.openUdpEncapsulationSocket();
-
-        final InetAddress srcAddr = getFirstV4Address(network);
-        final InetAddress dstAddr = getAddrByName(TEST_HOST, AF_INET);
-        assertNotNull(srcAddr);
-        assertNotNull(dstAddr);
-
-        // Test concurrent Nat-T keepalives.
-        for (int i = 0; i < nattCount; i++) {
-            final SocketKeepalive ka = mCm.createSocketKeepalive(network, nattSocket,
-                    srcAddr, dstAddr, executor, callback);
+        // Test concurrent keepalives with the given supplier.
+        while (kalist.size() < requestCount) {
+            final SocketKeepalive ka = kaFactory.get();
             ka.start(MIN_KEEPALIVE_INTERVAL);
             TestSocketKeepaliveCallback.CallbackValue cv = callback.pollCallback();
             assertNotNull(cv);
             if (cv.callbackType == TestSocketKeepaliveCallback.CallbackType.ON_ERROR) {
-                if (i == 0 && cv.error == SocketKeepalive.ERROR_UNSUPPORTED) {
+                if (kalist.size() == 0 && cv.error == SocketKeepalive.ERROR_UNSUPPORTED) {
                     // Unsupported.
                     break;
-                } else if (i != 0 && cv.error == SocketKeepalive.ERROR_INSUFFICIENT_RESOURCES) {
-                    // Limit reached.
+                } else if (cv.error == SocketKeepalive.ERROR_INSUFFICIENT_RESOURCES) {
+                    // Limit reached or temporary unavailable due to stopped slot is not yet
+                    // released.
+                    if (remainingRetries > 0) {
+                        SystemClock.sleep(INTERVAL_KEEPALIVE_RETRY_MS);
+                        remainingRetries--;
+                        continue;
+                    }
                     break;
                 }
             }
             if (cv.callbackType == TestSocketKeepaliveCallback.CallbackType.ON_STARTED) {
                 kalist.add(ka);
             } else {
-                fail("Unexpected error when creating " + (i + 1) + " Nat-T keepalives: " + cv);
+                fail("Unexpected error when creating " + (kalist.size() + 1) + " "
+                        + ka.getClass().getSimpleName() + ": " + cv);
             }
         }
 
+        return kalist;
+    }
+
+    private @NonNull ArrayList<SocketKeepalive> createConcurrentNattSocketKeepalives(
+            @NonNull Network network, int requestCount,
+            @NonNull TestSocketKeepaliveCallback callback)  throws Exception {
+
+        final Executor executor = mContext.getMainExecutor();
+
+        // Initialize a real NaT-T socket.
+        final IpSecManager mIpSec = (IpSecManager) mContext.getSystemService(Context.IPSEC_SERVICE);
+        final UdpEncapsulationSocket nattSocket = mIpSec.openUdpEncapsulationSocket();
+        final InetAddress srcAddr = getFirstV4Address(network);
+        final InetAddress dstAddr = getAddrByName(TEST_HOST, AF_INET);
+        assertNotNull(srcAddr);
+        assertNotNull(dstAddr);
+
+        // Test concurrent Nat-T keepalives.
+        final ArrayList<SocketKeepalive> result = createConcurrentKeepalivesOfType(requestCount,
+                callback, () -> mCm.createSocketKeepalive(network, nattSocket,
+                        srcAddr, dstAddr, executor, callback));
+
+        nattSocket.close();
+        return result;
+    }
+
+    private @NonNull ArrayList<SocketKeepalive> createConcurrentTcpSocketKeepalives(
+            @NonNull Network network, int requestCount,
+            @NonNull TestSocketKeepaliveCallback callback) {
+        final Executor executor = mContext.getMainExecutor();
+
+        // Create concurrent TCP keepalives.
+        return createConcurrentKeepalivesOfType(requestCount, callback, () -> {
+            // Assert that TCP connections can be established. The file descriptor of tcp
+            // sockets will be duplicated and kept valid in service side if the keepalives are
+            // successfully started.
+            try (Socket tcpSocket = getConnectedSocket(network, TEST_HOST, HTTP_PORT,
+                    0 /* Unused */, AF_INET)) {
+                return mCm.createSocketKeepalive(network, tcpSocket, executor, callback);
+            } catch (Exception e) {
+                fail("Unexpected error when creating TCP socket: " + e);
+            }
+            return null;
+        });
+    }
+
+    /**
+     * Creates concurrent keepalives until the specified counts of each type of keepalives are
+     * reached or the expected error callbacks are received for each type of keepalives.
+     *
+     * @return the total number of keepalives created.
+     */
+    private int createConcurrentSocketKeepalives(
+            @NonNull Network network, int nattCount, int tcpCount) throws Exception {
+        final ArrayList<SocketKeepalive> kalist = new ArrayList<>();
+        final TestSocketKeepaliveCallback callback = new TestSocketKeepaliveCallback();
+
+        kalist.addAll(createConcurrentNattSocketKeepalives(network, nattCount, callback));
+        kalist.addAll(createConcurrentTcpSocketKeepalives(network, tcpCount, callback));
+
         final int ret = kalist.size();
 
         // Clean up.
@@ -1089,7 +1131,6 @@
             callback.expectStopped();
         }
         kalist.clear();
-        nattSocket.close();
 
         return ret;
     }
@@ -1099,8 +1140,15 @@
      * get leaked after iterations.
      */
     @AppModeFull(reason = "Cannot get WifiManager in instant app mode")
-    public void testSocketKeepaliveLimit() throws Exception {
-        final int supported = getSupportedKeepalivesFromRes();
+    public void testSocketKeepaliveLimitWifi() throws Exception {
+        if (!mPackageManager.hasSystemFeature(FEATURE_WIFI)) {
+            Log.i(TAG, "testSocketKeepaliveLimitWifi cannot execute unless device"
+                    + " supports WiFi");
+            return;
+        }
+
+        final Network network = ensureWifiConnected();
+        final int supported = getSupportedKeepalivesForNet(network);
         if (supported == 0) {
             return;
         }
@@ -1108,25 +1156,25 @@
         adoptShellPermissionIdentity();
 
         // Verifies that the supported keepalive slots meet MIN_SUPPORTED_KEEPALIVE_COUNT.
-        assertGreaterOrEqual(supported, KeepaliveUtils.MIN_SUPPORTED_KEEPALIVE_COUNT);
+        assertGreaterOrEqual(supported, MIN_SUPPORTED_WIFI_KEEPALIVE_COUNT);
 
         // Verifies that Nat-T keepalives can be established.
-        assertEquals(supported, createConcurrentSocketKeepalives(supported + 1, 0));
+        assertEquals(supported, createConcurrentSocketKeepalives(network, supported + 1, 0));
         // Verifies that keepalives don't get leaked in second round.
-        assertEquals(supported, createConcurrentSocketKeepalives(supported + 1, 0));
+        assertEquals(supported, createConcurrentSocketKeepalives(network, supported, 0));
 
         // If kernel < 4.8 then it doesn't support TCP keepalive, but it might still support
         // NAT-T keepalive. Test below cases only if TCP keepalive is supported by kernel.
         if (isTcpKeepaliveSupportedByKernel()) {
-            assertEquals(supported, createConcurrentSocketKeepalives(0, supported + 1));
+            assertEquals(supported, createConcurrentSocketKeepalives(network, 0, supported + 1));
 
             // Verifies that different types can be established at the same time.
-            assertEquals(supported, createConcurrentSocketKeepalives(
+            assertEquals(supported, createConcurrentSocketKeepalives(network,
                     supported / 2, supported - supported / 2));
 
             // Verifies that keepalives don't get leaked in second round.
-            assertEquals(supported, createConcurrentSocketKeepalives(0, supported + 1));
-            assertEquals(supported, createConcurrentSocketKeepalives(
+            assertEquals(supported, createConcurrentSocketKeepalives(network, 0, supported));
+            assertEquals(supported, createConcurrentSocketKeepalives(network,
                     supported / 2, supported - supported / 2));
         }
 
@@ -1134,11 +1182,53 @@
     }
 
     /**
+     * Verifies that the concurrent keepalive slots meet the minimum telephony requirement, and
+     * don't get leaked after iterations.
+     */
+    @AppModeFull(reason = "Cannot request network in instant app mode")
+    public void testSocketKeepaliveLimitTelephony() throws Exception {
+        if (!mPackageManager.hasSystemFeature(FEATURE_TELEPHONY)) {
+            Log.i(TAG, "testSocketKeepaliveLimitTelephony cannot execute unless device"
+                    + " supports telephony");
+            return;
+        }
+
+        final int firstSdk = Build.VERSION.FIRST_SDK_INT;
+        if (firstSdk < Build.VERSION_CODES.Q) {
+            Log.i(TAG, "testSocketKeepaliveLimitTelephony: skip test for devices launching"
+                    + " before Q: " + firstSdk);
+            return;
+        }
+
+        final Network network = mCtsNetUtils.connectToCell();
+        final int supported = getSupportedKeepalivesForNet(network);
+
+        adoptShellPermissionIdentity();
+
+        // Verifies that the supported keepalive slots meet minimum requirement.
+        assertGreaterOrEqual(supported, MIN_SUPPORTED_CELLULAR_KEEPALIVE_COUNT);
+
+        // Verifies that Nat-T keepalives can be established.
+        assertEquals(supported, createConcurrentSocketKeepalives(network, supported + 1, 0));
+        // Verifies that keepalives don't get leaked in second round.
+        assertEquals(supported, createConcurrentSocketKeepalives(network, supported, 0));
+
+        dropShellPermissionIdentity();
+    }
+
+    /**
      * Verifies that the keepalive slots are limited as customized for unprivileged requests.
      */
     @AppModeFull(reason = "Cannot get WifiManager in instant app mode")
     public void testSocketKeepaliveUnprivileged() throws Exception {
-        final int supported = getSupportedKeepalivesFromRes();
+        if (!mPackageManager.hasSystemFeature(FEATURE_WIFI)) {
+            Log.i(TAG, "testSocketKeepaliveUnprivileged cannot execute unless device"
+                    + " supports WiFi");
+            return;
+        }
+
+        final Network network = ensureWifiConnected();
+        final int supported = getSupportedKeepalivesForNet(network);
         if (supported == 0) {
             return;
         }
@@ -1154,7 +1244,8 @@
         assertGreaterOrEqual(supported, allowedUnprivilegedPerUid);
         final int expectedUnprivileged =
                 Math.min(allowedUnprivilegedPerUid, supported - reservedPrivilegedSlots);
-        assertEquals(expectedUnprivileged, createConcurrentSocketKeepalives(supported + 1, 0));
+        assertEquals(expectedUnprivileged,
+                createConcurrentSocketKeepalives(network, supported + 1, 0));
     }
 
     private static void assertGreaterOrEqual(long greater, long lesser) {
diff --git a/tests/tests/net/src/android/net/cts/DnsResolverTest.java b/tests/tests/net/src/android/net/cts/DnsResolverTest.java
index e16fce0..ef8badd 100644
--- a/tests/tests/net/src/android/net/cts/DnsResolverTest.java
+++ b/tests/tests/net/src/android/net/cts/DnsResolverTest.java
@@ -39,6 +39,7 @@
 import android.os.CancellationSignal;
 import android.os.Handler;
 import android.os.Looper;
+import android.platform.test.annotations.AppModeFull;
 import android.provider.Settings;
 import android.system.ErrnoException;
 import android.test.AndroidTestCase;
@@ -53,6 +54,7 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
 
+@AppModeFull(reason = "WRITE_SECURE_SETTINGS permission can't be granted to instant apps")
 public class DnsResolverTest extends AndroidTestCase {
     private static final String TAG = "DnsResolverTest";
     private static final char[] HEX_CHARS = {
@@ -78,12 +80,14 @@
     static final int TIMEOUT_MS = 12_000;
     static final int CANCEL_TIMEOUT_MS = 3_000;
     static final int CANCEL_RETRY_TIMES = 5;
+    static final int QUERY_TIMES = 10;
     static final int NXDOMAIN = 3;
     static final int PRIVATE_DNS_SETTING_TIMEOUT_MS = 2_000;
 
     private ContentResolver mCR;
     private ConnectivityManager mCM;
     private Executor mExecutor;
+    private Executor mExecutorInline;
     private DnsResolver mDns;
 
     private String mOldMode;
@@ -95,6 +99,7 @@
         mCM = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
         mDns = DnsResolver.getInstance();
         mExecutor = new Handler(Looper.getMainLooper())::post;
+        mExecutorInline = (Runnable r) -> r.run();
         mCR = getContext().getContentResolver();
         storePrivateDnsSetting();
     }
@@ -272,12 +277,44 @@
         }
     }
 
-    public void testRawQuery() throws InterruptedException {
+    public void testRawQuery() throws Exception {
+        doTestRawQuery(mExecutor);
+    }
+
+    public void testRawQueryInline() throws Exception {
+        doTestRawQuery(mExecutorInline);
+    }
+
+    public void testRawQueryBlob() throws Exception {
+        doTestRawQueryBlob(mExecutor);
+    }
+
+    public void testRawQueryBlobInline() throws Exception {
+        doTestRawQueryBlob(mExecutorInline);
+    }
+
+    public void testRawQueryRoot() throws Exception {
+        doTestRawQueryRoot(mExecutor);
+    }
+
+    public void testRawQueryRootInline() throws Exception {
+        doTestRawQueryRoot(mExecutorInline);
+    }
+
+    public void testRawQueryNXDomain() throws Exception {
+        doTestRawQueryNXDomain(mExecutor);
+    }
+
+    public void testRawQueryNXDomainInline() throws Exception {
+        doTestRawQueryNXDomain(mExecutorInline);
+    }
+
+    public void doTestRawQuery(Executor executor) throws InterruptedException {
         final String msg = "RawQuery " + TEST_DOMAIN;
         for (Network network : getTestableNetworks()) {
             final VerifyCancelCallback callback = new VerifyCancelCallback(msg);
             mDns.rawQuery(network, TEST_DOMAIN, CLASS_IN, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP,
-                    mExecutor, null, callback);
+                    executor, null, callback);
 
             assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
                     callback.waitForAnswer());
@@ -285,7 +322,7 @@
         }
     }
 
-    public void testRawQueryBlob() throws InterruptedException {
+    public void doTestRawQueryBlob(Executor executor) throws InterruptedException {
         final byte[] blob = new byte[]{
                 /* Header */
                 0x55, 0x66, /* Transaction ID */
@@ -303,7 +340,7 @@
         final String msg = "RawQuery blob " + byteArrayToHexString(blob);
         for (Network network : getTestableNetworks()) {
             final VerifyCancelCallback callback = new VerifyCancelCallback(msg);
-            mDns.rawQuery(network, blob, FLAG_NO_CACHE_LOOKUP, mExecutor, null, callback);
+            mDns.rawQuery(network, blob, FLAG_NO_CACHE_LOOKUP, executor, null, callback);
 
             assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
                     callback.waitForAnswer());
@@ -311,13 +348,13 @@
         }
     }
 
-    public void testRawQueryRoot() throws InterruptedException {
+    public void doTestRawQueryRoot(Executor executor) throws InterruptedException {
         final String dname = "";
         final String msg = "RawQuery empty dname(ROOT) ";
         for (Network network : getTestableNetworks()) {
             final VerifyCancelCallback callback = new VerifyCancelCallback(msg);
             mDns.rawQuery(network, dname, CLASS_IN, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP,
-                    mExecutor, null, callback);
+                    executor, null, callback);
 
             assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
                     callback.waitForAnswer());
@@ -326,13 +363,13 @@
         }
     }
 
-    public void testRawQueryNXDomain() throws InterruptedException {
+    public void doTestRawQueryNXDomain(Executor executor) throws InterruptedException {
         final String dname = "test1-nx.metric.gstatic.com";
         final String msg = "RawQuery " + dname;
         for (Network network : getTestableNetworks()) {
             final VerifyCancelCallback callback = new VerifyCancelCallback(msg);
             mDns.rawQuery(network, dname, CLASS_IN, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP,
-                    mExecutor, null, callback);
+                    executor, null, callback);
 
             assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
                     callback.waitForAnswer());
@@ -474,12 +511,44 @@
         }
     }
 
-    public void testQueryForInetAddress() throws InterruptedException {
+    public void testQueryForInetAddress() throws Exception {
+        doTestQueryForInetAddress(mExecutor);
+    }
+
+    public void testQueryForInetAddressInline() throws Exception {
+        doTestQueryForInetAddress(mExecutorInline);
+    }
+
+    public void testQueryForInetAddressIpv4() throws Exception {
+        doTestQueryForInetAddressIpv4(mExecutor);
+    }
+
+    public void testQueryForInetAddressIpv4Inline() throws Exception {
+        doTestQueryForInetAddressIpv4(mExecutorInline);
+    }
+
+    public void testQueryForInetAddressIpv6() throws Exception {
+        doTestQueryForInetAddressIpv6(mExecutor);
+    }
+
+    public void testQueryForInetAddressIpv6Inline() throws Exception {
+        doTestQueryForInetAddressIpv6(mExecutorInline);
+    }
+
+    public void testContinuousQueries() throws Exception {
+        doTestContinuousQueries(mExecutor);
+    }
+
+    public void testContinuousQueriesInline() throws Exception {
+        doTestContinuousQueries(mExecutorInline);
+    }
+
+    public void doTestQueryForInetAddress(Executor executor) throws InterruptedException {
         final String msg = "Test query for InetAddress " + TEST_DOMAIN;
         for (Network network : getTestableNetworks()) {
             final VerifyCancelInetAddressCallback callback =
                     new VerifyCancelInetAddressCallback(msg, null);
-            mDns.query(network, TEST_DOMAIN, FLAG_NO_CACHE_LOOKUP, mExecutor, null, callback);
+            mDns.query(network, TEST_DOMAIN, FLAG_NO_CACHE_LOOKUP, executor, null, callback);
 
             assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
                     callback.waitForAnswer());
@@ -516,13 +585,13 @@
         }
     }
 
-    public void testQueryForInetAddressIpv4() throws InterruptedException {
+    public void doTestQueryForInetAddressIpv4(Executor executor) throws InterruptedException {
         final String msg = "Test query for IPv4 InetAddress " + TEST_DOMAIN;
         for (Network network : getTestableNetworks()) {
             final VerifyCancelInetAddressCallback callback =
                     new VerifyCancelInetAddressCallback(msg, null);
             mDns.query(network, TEST_DOMAIN, TYPE_A, FLAG_NO_CACHE_LOOKUP,
-                    mExecutor, null, callback);
+                    executor, null, callback);
 
             assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
                     callback.waitForAnswer());
@@ -531,13 +600,13 @@
         }
     }
 
-    public void testQueryForInetAddressIpv6() throws InterruptedException {
+    public void doTestQueryForInetAddressIpv6(Executor executor) throws InterruptedException {
         final String msg = "Test query for IPv6 InetAddress " + TEST_DOMAIN;
         for (Network network : getTestableNetworks()) {
             final VerifyCancelInetAddressCallback callback =
                     new VerifyCancelInetAddressCallback(msg, null);
             mDns.query(network, TEST_DOMAIN, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP,
-                    mExecutor, null, callback);
+                    executor, null, callback);
 
             assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
                     callback.waitForAnswer());
@@ -630,4 +699,24 @@
             mCM.bindProcessToNetwork(null);
         }
     }
+
+    public void doTestContinuousQueries(Executor executor) throws InterruptedException {
+        final String msg = "Test continuous " + QUERY_TIMES + " queries " + TEST_DOMAIN;
+        for (Network network : getTestableNetworks()) {
+            for (int i = 0; i < QUERY_TIMES ; ++i) {
+                final VerifyCancelInetAddressCallback callback =
+                        new VerifyCancelInetAddressCallback(msg, null);
+                // query v6/v4 in turn
+                boolean queryV6 = (i % 2 == 0);
+                mDns.query(network, TEST_DOMAIN, queryV6 ? TYPE_AAAA : TYPE_A,
+                        FLAG_NO_CACHE_LOOKUP, executor, null, callback);
+
+                assertTrue(msg + " but no answer after " + TIMEOUT_MS + "ms.",
+                        callback.waitForAnswer());
+                assertTrue(msg + " returned 0 results", !callback.isAnswerEmpty());
+                assertTrue(msg + " returned " + (queryV6 ? "Ipv4" : "Ipv6") + " results",
+                        queryV6 ? !callback.hasIpv4Answer() : !callback.hasIpv6Answer());
+            }
+        }
+    }
 }
diff --git a/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java b/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
index 4d44f55..99e6e4b 100644
--- a/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/TelephonyManagerPermissionTest.java
@@ -319,6 +319,33 @@
         }
     }
 
+    /**
+    * Verify that getNetworkType and getDataNetworkType requires Permission.
+    * <p>
+    * Requires Permission:
+    * {@link android.Manifest.permission#READ_PHONE_STATE}.
+    */
+    @Test
+    public void testGetNetworkType() {
+        if (!mHasTelephony) {
+            return;
+        }
+
+        try {
+            mTelephonyManager.getNetworkType();
+            fail("getNetworkType did not throw a SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        }
+
+        try {
+            mTelephonyManager.getDataNetworkType();
+            fail("getDataNetworkType did not throw a SecurityException");
+        } catch (SecurityException e) {
+            // expected
+        }
+    }
+
     private static Context getContext() {
         return InstrumentationRegistry.getContext();
     }
diff --git a/tests/tests/graphics/res/drawable-nodpi/vector_drawable_scale_golden.png b/tests/tests/uirendering/res/drawable-nodpi/vector_drawable_scale_golden.png
similarity index 100%
rename from tests/tests/graphics/res/drawable-nodpi/vector_drawable_scale_golden.png
rename to tests/tests/uirendering/res/drawable-nodpi/vector_drawable_scale_golden.png
Binary files differ
diff --git a/tests/tests/uirendering/res/drawable/sunset1.jpg b/tests/tests/uirendering/res/drawable/sunset1.jpg
index 92851f3..3b30b36 100644
--- a/tests/tests/uirendering/res/drawable/sunset1.jpg
+++ b/tests/tests/uirendering/res/drawable/sunset1.jpg
Binary files differ
diff --git a/tests/tests/uirendering/res/drawable/vector_icon_create.xml b/tests/tests/uirendering/res/drawable/vector_icon_create.xml
new file mode 100644
index 0000000..7db4ad5
--- /dev/null
+++ b/tests/tests/uirendering/res/drawable/vector_icon_create.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:height="64dp"
+        android:width="64dp"
+        android:viewportHeight="24"
+        android:viewportWidth="24" >
+
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M3.0,17.25L3.0,21.0l3.75,0.0L17.813995,9.936001l-3.75-3.75L3.0,17.25zM20.707,7.0429993c0.391-0.391 0.391-1.023 0.0-1.414l-2.336-2.336c-0.391-0.391-1.023-0.391 -1.414,0.0l-1.832,1.832l3.75,3.75L20.707,7.0429993z" />
+
+</vector>
\ No newline at end of file
diff --git a/tests/tests/graphics/res/layout/vector_drawable_scale_layout.xml b/tests/tests/uirendering/res/layout/vector_drawable_scale_layout.xml
similarity index 100%
rename from tests/tests/graphics/res/layout/vector_drawable_scale_layout.xml
rename to tests/tests/uirendering/res/layout/vector_drawable_scale_layout.xml
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapcomparers/MSSIMComparer.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapcomparers/MSSIMComparer.java
index e65ff2d..c8a1ebd 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/bitmapcomparers/MSSIMComparer.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapcomparers/MSSIMComparer.java
@@ -40,6 +40,17 @@
         mThreshold = threshold;
     }
 
+    /**
+     * Compute the size of the window. The window defaults to WINDOW_SIZE, but
+     * must be contained within dimension.
+     */
+    private int computeWindowSize(int coordinateStart, int dimension) {
+        if (coordinateStart + WINDOW_SIZE <= dimension) {
+            return WINDOW_SIZE;
+        }
+        return dimension - coordinateStart;
+    }
+
     @Override
     public boolean verifySame(int[] ideal, int[] given, int offset, int stride, int width,
             int height) {
@@ -47,16 +58,20 @@
         int windows = 0;
 
         for (int currentWindowY = 0 ; currentWindowY < height ; currentWindowY += WINDOW_SIZE) {
+            int windowHeight = computeWindowSize(currentWindowY, height);
             for (int currentWindowX = 0 ; currentWindowX < width ; currentWindowX += WINDOW_SIZE) {
+                int windowWidth = computeWindowSize(currentWindowX, width);
                 int start = indexFromXAndY(currentWindowX, currentWindowY, stride, offset);
-                if (isWindowWhite(ideal, start, stride) && isWindowWhite(given, start, stride)) {
+                if (isWindowWhite(ideal, start, stride, windowWidth, windowHeight)
+                        && isWindowWhite(given, start, stride, windowWidth, windowHeight)) {
                     continue;
                 }
                 windows++;
-                double[] means = getMeans(ideal, given, start, stride);
+                double[] means = getMeans(ideal, given, start, stride, windowWidth, windowHeight);
                 double meanX = means[0];
                 double meanY = means[1];
-                double[] variances = getVariances(ideal, given, meanX, meanY, start, stride);
+                double[] variances = getVariances(ideal, given, meanX, meanY, start, stride,
+                        windowWidth, windowHeight);
                 double varX = variances[0];
                 double varY = variances[1];
                 double stdBoth = variances[2];
@@ -76,9 +91,10 @@
         return (SSIMTotal >= mThreshold);
     }
 
-    private boolean isWindowWhite(int[] colors, int start, int stride) {
-        for (int y = 0 ; y < WINDOW_SIZE ; y++) {
-            for (int x = 0 ; x < WINDOW_SIZE ; x++) {
+    private boolean isWindowWhite(int[] colors, int start, int stride,
+            int windowWidth, int windowHeight) {
+        for (int y = 0; y < windowHeight; y++) {
+            for (int x = 0; x < windowWidth; x++) {
                 if (colors[indexFromXAndY(x, y, stride, start)] != Color.WHITE) {
                     return false;
                 }
@@ -101,18 +117,19 @@
      * where the first double is the mean of the first set and the second double is the mean of the
      * second set.
      */
-    private double[] getMeans(int[] pixels0, int[] pixels1, int start, int stride) {
+    private double[] getMeans(int[] pixels0, int[] pixels1, int start, int stride,
+            int windowWidth, int windowHeight) {
         double avg0 = 0;
         double avg1 = 0;
-        for (int y = 0 ; y < WINDOW_SIZE ; y++) {
-            for (int x = 0 ; x < WINDOW_SIZE ; x++) {
+        for (int y = 0; y < windowHeight; y++) {
+            for (int x = 0; x < windowWidth; x++) {
                 int index = indexFromXAndY(x, y, stride, start);
                 avg0 += getIntensity(pixels0[index]);
                 avg1 += getIntensity(pixels1[index]);
             }
         }
-        avg0 /= WINDOW_SIZE * WINDOW_SIZE;
-        avg1 /= WINDOW_SIZE * WINDOW_SIZE;
+        avg0 /= windowWidth * windowHeight;
+        avg1 /= windowWidth * windowHeight;
         return new double[] {avg0, avg1};
     }
 
@@ -122,12 +139,12 @@
      * the second is the variance of the second set of pixels, and the third is the covariance.
      */
     private double[] getVariances(int[] pixels0, int[] pixels1, double mean0, double mean1,
-            int start, int stride) {
+            int start, int stride, int windowWidth, int windowHeight) {
         double var0 = 0;
         double var1 = 0;
         double varBoth = 0;
-        for (int y = 0 ; y < WINDOW_SIZE ; y++) {
-            for (int x = 0 ; x < WINDOW_SIZE ; x++) {
+        for (int y = 0; y < windowHeight; y++) {
+            for (int x = 0; x < windowWidth; x++) {
                 int index = indexFromXAndY(x, y, stride, start);
                 double v0 = getIntensity(pixels0[index]) - mean0;
                 double v1 = getIntensity(pixels1[index]) - mean1;
@@ -136,9 +153,9 @@
                 varBoth += v0 * v1;
             }
         }
-        var0 /= (WINDOW_SIZE * WINDOW_SIZE) - 1;
-        var1 /= (WINDOW_SIZE * WINDOW_SIZE) - 1;
-        varBoth /= (WINDOW_SIZE * WINDOW_SIZE) - 1;
+        var0 /= (windowWidth * windowHeight) - 1;
+        var1 /= (windowWidth * windowHeight) - 1;
+        varBoth /= (windowWidth * windowHeight) - 1;
         return new double[] {var0, var1, varBoth};
     }
 
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java
index b9816db..ac1fa0e 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java
@@ -20,16 +20,18 @@
 import android.graphics.BitmapFactory;
 import android.uirendering.cts.bitmapcomparers.BitmapComparer;
 import android.uirendering.cts.differencevisualizers.PassFailVisualizer;
-import android.uirendering.cts.testinfrastructure.ActivityTestBase;
 
 public class GoldenImageVerifier extends BitmapVerifier {
-    private BitmapComparer mBitmapComparer;
-    private int[] mGoldenBitmapArray;
+    private final BitmapComparer mBitmapComparer;
+    private final int[] mGoldenBitmapArray;
+    private final int mWidth;
+    private final int mHeight;
 
     public GoldenImageVerifier(Bitmap goldenBitmap, BitmapComparer bitmapComparer) {
-        mGoldenBitmapArray = new int[ActivityTestBase.TEST_WIDTH * ActivityTestBase.TEST_HEIGHT];
-        goldenBitmap.getPixels(mGoldenBitmapArray, 0, ActivityTestBase.TEST_WIDTH, 0, 0,
-                ActivityTestBase.TEST_WIDTH, ActivityTestBase.TEST_HEIGHT);
+        mWidth = goldenBitmap.getWidth();
+        mHeight = goldenBitmap.getHeight();
+        mGoldenBitmapArray = new int[mWidth * mHeight];
+        goldenBitmap.getPixels(mGoldenBitmapArray, 0, mWidth, 0, 0, mWidth, mHeight);
         mBitmapComparer = bitmapComparer;
     }
 
@@ -38,6 +40,15 @@
     }
 
     @Override
+    public boolean verify(Bitmap bitmap) {
+        // Clip to the size of the golden image.
+        if (bitmap.getWidth() > mWidth || bitmap.getHeight() > mHeight) {
+            bitmap = Bitmap.createBitmap(bitmap, 0, 0, mWidth, mHeight);
+        }
+        return super.verify(bitmap);
+    }
+
+    @Override
     public boolean verify(int[] bitmap, int offset, int stride, int width, int height) {
         boolean success = mBitmapComparer.verifySame(mGoldenBitmapArray, bitmap, offset, stride,
                 width, height);
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java
index f1acc16..3962f02 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java
@@ -97,7 +97,7 @@
                 .addCanvasClient("TorusClip", sTorusClipCanvasClient)
                 .addCanvasClient("TorusClipOut", sTorusClipOutCanvasClient)
                 .runWithVerifier(new GoldenImageVerifier(getActivity(),
-                        R.drawable.pathclippingtest_torus, new MSSIMComparer(0.95)));
+                        R.drawable.pathclippingtest_torus, new MSSIMComparer(0.65)));
     }
 
     @Test
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/VectorDrawableScaleTest.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/VectorDrawableScaleTest.java
new file mode 100644
index 0000000..2362a78
--- /dev/null
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/VectorDrawableScaleTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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 android.uirendering.cts.testclasses;
+
+import android.content.Context;
+import android.uirendering.cts.R;
+import android.uirendering.cts.bitmapcomparers.MSSIMComparer;
+import android.uirendering.cts.bitmapverifiers.GoldenImageVerifier;
+import android.uirendering.cts.testinfrastructure.ActivityTestBase;
+import android.view.View;
+import android.widget.ImageView;
+
+import androidx.test.filters.MediumTest;
+
+import org.junit.Test;
+
+@MediumTest
+public class VectorDrawableScaleTest extends ActivityTestBase {
+    @Test
+    public void testVectorDrawableInImageView() {
+        final Context context = getInstrumentation().getTargetContext();
+        createTest()
+                .addLayout(R.layout.vector_drawable_scale_layout, view-> {
+                    setupImageViews(view);
+                }, false /* not HW only*/)
+                .runWithVerifier(new GoldenImageVerifier(context,
+                      R.drawable.vector_drawable_scale_golden,
+                      new MSSIMComparer(.87f)));
+    }
+
+    // Setup 2 imageviews, one big and one small. The purpose of this test is to make sure that the
+    // imageview with smaller scale will not affect the appearance in the imageview with larger
+    // scale.
+    private static void setupImageViews(View view) {
+        ImageView imageView = (ImageView) view.findViewById(R.id.imageview1);
+        imageView.setImageResource(R.drawable.vector_icon_create);
+        imageView = (ImageView) view.findViewById(R.id.imageview2);
+        imageView.setImageResource(R.drawable.vector_icon_create);
+    }
+}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
old mode 100644
new mode 100755
index 14dd431..6d69945
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -1795,16 +1795,20 @@
         assertEquals(
                 mOnUiThread.getHeight(),
                 mOnUiThread.getContentHeight() * mOnUiThread.getScale(),
-                tolerance * mOnUiThread.getScale());
+                tolerance * Math.max(mOnUiThread.getScale(), 1.0f));
 
         // Make pageHeight bigger than the larger dimension of the device, so the page is taller
         // than viewport. Because when layout_height set to match_parent, getContentHeight() will
         // give maximum value between the actual web content height and the viewport height. When
         // viewport height is bigger, |extraSpace| below is not the extra space on the web page.
-        // Note that we are passing physical pixels rather than CSS pixels here, since screen
-        // density scale is generally greater than 1, it only makes the page content taller.
+        // Note that we are passing physical pixels rather than CSS pixels here, when screen density
+        // scale is lower than 1.0f, we need to scale it up.
         DisplayMetrics metrics = mOnUiThread.getDisplayMetrics();
-        final int pageHeight = Math.max(metrics.widthPixels, metrics.heightPixels);
+        final float scaleFactor = Math.max(1.0f, 1.0f / mOnUiThread.getScale());
+        final int pageHeight =
+                (int)(Math.ceil(Math.max(metrics.widthPixels, metrics.heightPixels)
+                * scaleFactor));
+
         // set the margin to 0
         final String p = "<p style=\"height:" + pageHeight
                 + "px;margin:0px auto;\">Get the height of HTML content.</p>";