diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-04-13 01:27:29 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-04-13 01:27:29 +0000 |
commit | 9b3d38b2c96ab3c875585cbceeb9afb7f8089377 (patch) | |
tree | 06efecd705910b060dc012ea88c81c102b15ee00 | |
parent | c478520196f9270d195e8f341bc287006e39f3e0 (diff) | |
parent | 89d5d9fee5adcf8bf90bbfb311080259aa64daeb (diff) | |
download | cts-android11-mainline-permission-release.tar.gz |
Snap for 7277907 from 89d5d9fee5adcf8bf90bbfb311080259aa64daeb to mainline-permission-releaseandroid-mainline-11.0.0_r42android11-mainline-permission-release
Change-Id: I1c137e402a393cb2b9775ce299166ba3b0e7c5ea
136 files changed, 594 insertions, 405 deletions
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 b960033c83f..8cce5cbc5c6 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.android.tradefed.testtype.junit4.BaseHostJUnit4Test; 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { 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 class StrictJavaPackagesTest extends BaseHostJUnit4Test { public void testSystemServerClasspath_nonDuplicateApexJarClasses() throws Exception { runWithTempDir(tmpDir -> { final Set<DeviceFile> sscpJarFiles = - pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH"); + pullJarsFromEnvVariable(tmpDir, "SYSTEMSERVERCLASSPATH"); checkClassDuplicatesNotInApexJars(sscpJarFiles); }); } @@ -253,8 +259,8 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { /** * 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { */ 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { } private interface TempDirRunnable { - public void runWithTempDir(File tempDir) throws Exception; + void runWithTempDir(File tempDir) throws Exception; } /** @@ -378,6 +380,7 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { } 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 @@ public class StrictJavaPackagesTest extends BaseHostJUnit4Test { @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 1ca478c5430..7cb1c1db1b1 100644 --- a/hostsidetests/backup/Android.bp +++ b/hostsidetests/backup/Android.bp @@ -21,7 +21,7 @@ java_test_host { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], libs: [ "cts-tradefed", diff --git a/hostsidetests/devicepolicy/Android.bp b/hostsidetests/devicepolicy/Android.bp index f8322998749..3ceb7ac7c66 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 @@ java_test_host { "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 fca141652cf..11dd9200c95 100644 --- a/hostsidetests/devicepolicy/app/AccountCheck/Android.bp +++ b/hostsidetests/devicepolicy/app/AccountCheck/Android.bp @@ -20,7 +20,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], srcs: ["src-owner/**/*.java"], resource_dirs: ["TestOnlyOwner/res"], @@ -42,7 +42,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], srcs: ["src-owner/**/*.java"], resource_dirs: ["NonTestOnlyOwner/res"], @@ -64,7 +64,7 @@ android_test_helper_app { "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 687819e632c..af26de8464e 100644 --- a/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.bp +++ b/hostsidetests/devicepolicy/app/AccountCheck/Auth/Android.bp @@ -20,7 +20,7 @@ android_test_helper_app { "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 25331088b6c..70ca5adb755 100644 --- a/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.bp +++ b/hostsidetests/devicepolicy/app/AccountCheck/Tester/Android.bp @@ -20,7 +20,7 @@ android_test_helper_app { "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 f10dcbb70a7..b9b11eba0ac 100644 --- a/hostsidetests/devicepolicy/app/AccountManagement/Android.bp +++ b/hostsidetests/devicepolicy/app/AccountManagement/Android.bp @@ -21,7 +21,7 @@ android_test_helper_app { "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 37cc0424d93..70a134678ef 100644 --- a/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.bp +++ b/hostsidetests/devicepolicy/app/AppRestrictionsTargetApp/Android.bp @@ -24,6 +24,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/Assistant/Android.bp b/hostsidetests/devicepolicy/app/Assistant/Android.bp index 8feee053fc6..d5a4df02665 100644 --- a/hostsidetests/devicepolicy/app/Assistant/Android.bp +++ b/hostsidetests/devicepolicy/app/Assistant/Android.bp @@ -24,7 +24,7 @@ android_test_helper_app { "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 664d89033de..defce6a4314 100644 --- a/hostsidetests/devicepolicy/app/AutofillApp/Android.bp +++ b/hostsidetests/devicepolicy/app/AutofillApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 e9b38d9d227..788c685fb81 100644 --- a/hostsidetests/devicepolicy/app/CertInstaller/Android.bp +++ b/hostsidetests/devicepolicy/app/CertInstaller/Android.bp @@ -35,6 +35,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp b/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp index 200a6d2a859..e07a1fa4525 100644 --- a/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp +++ b/hostsidetests/devicepolicy/app/ContactDirectoryProvider/Android.bp @@ -21,7 +21,7 @@ android_test_helper_app { "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 6880174f3e0..e1c3de62377 100644 --- a/hostsidetests/devicepolicy/app/ContentCaptureApp/Android.bp +++ b/hostsidetests/devicepolicy/app/ContentCaptureApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 cfe06d6433f..9bff693c789 100644 --- a/hostsidetests/devicepolicy/app/ContentCaptureService/Android.bp +++ b/hostsidetests/devicepolicy/app/ContentCaptureService/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 cc34b43388f..2de8d884ab2 100644 --- a/hostsidetests/devicepolicy/app/ContentSuggestionsApp/Android.bp +++ b/hostsidetests/devicepolicy/app/ContentSuggestionsApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 00940df33d3..504ef6ad8e4 100644 --- a/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.bp +++ b/hostsidetests/devicepolicy/app/CorpOwnedManagedProfile/Android.bp @@ -43,7 +43,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } @@ -73,7 +73,7 @@ android_test_helper_app { "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 a3e87668f09..868ad323154 100644 --- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsTest/Android.bp +++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsTest/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "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 aa79d3d68ae..2064632d3d7 100644 --- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsWithNoPermissionTest/Android.bp +++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileAppsWithNoPermissionTest/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "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 da26ceed3fb..676db50030e 100644 --- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledApp/Android.bp +++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledApp/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "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 19b788bc394..7e99e9124f1 100644 --- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledNoPermsApp/Android.bp +++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileEnabledNoPermsApp/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "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 acc77acbedd..f124fdfb1e3 100644 --- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileNotEnabledApp/Android.bp +++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileNotEnabledApp/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "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 5786981734f..5144726a999 100644 --- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileUserEnabledApp/Android.bp +++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/CrossProfileUserEnabledApp/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "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 7383a9e1255..f198140f34d 100644 --- a/hostsidetests/devicepolicy/app/CrossProfileTestApps/ModifyQuietModeEnabledApp/Android.bp +++ b/hostsidetests/devicepolicy/app/CrossProfileTestApps/ModifyQuietModeEnabledApp/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp b/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp index bf00089c9d6..50c05466e01 100644 --- a/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp +++ b/hostsidetests/devicepolicy/app/CustomizationApp/Android.bp @@ -20,7 +20,7 @@ android_test_helper_app { "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 14bea7dce1f..c6c51a49094 100644 --- a/hostsidetests/devicepolicy/app/DelegateApp/Android.bp +++ b/hostsidetests/devicepolicy/app/DelegateApp/Android.bp @@ -35,6 +35,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp b/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp index 4a587f7fb85..ef1728f3b84 100644 --- a/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp +++ b/hostsidetests/devicepolicy/app/DeviceAdmin/Android.bp @@ -32,7 +32,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "api23/AndroidManifest.xml", } @@ -59,7 +59,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "api24/AndroidManifest.xml", } @@ -84,7 +84,7 @@ android_test_helper_app { "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 aaacefa8eea..ceefa608db7 100644 --- a/hostsidetests/devicepolicy/app/DeviceAdminService/Android.bp +++ b/hostsidetests/devicepolicy/app/DeviceAdminService/Android.bp @@ -28,7 +28,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "package1/AndroidManifest.xml", } @@ -49,7 +49,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "package2/AndroidManifest.xml", } @@ -70,7 +70,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "package3/AndroidManifest.xml", } @@ -91,7 +91,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "package4/AndroidManifest.xml", } @@ -112,7 +112,7 @@ android_test_helper_app { "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 e32c4aeef73..55ad4b1e555 100644 --- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/Android.bp +++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/Android.bp @@ -36,7 +36,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "api23/AndroidManifest.xml", } @@ -66,7 +66,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "api25/AndroidManifest.xml", } @@ -96,7 +96,7 @@ android_test_helper_app { "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 48826afa741..47f635abb18 100644 --- a/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp +++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.bp @@ -45,6 +45,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/DummyApps/Android.bp b/hostsidetests/devicepolicy/app/DummyApps/Android.bp index 869a90861d5..2992f74e481 100644 --- a/hostsidetests/devicepolicy/app/DummyApps/Android.bp +++ b/hostsidetests/devicepolicy/app/DummyApps/Android.bp @@ -34,7 +34,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "dummyapp1/AndroidManifest.xml", } @@ -61,7 +61,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "dummyapp2/AndroidManifest.xml", } @@ -88,7 +88,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "dummyapp3/AndroidManifest.xml", } @@ -115,7 +115,7 @@ android_test_helper_app { "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 7955f42b102..53f5470d570 100644 --- a/hostsidetests/devicepolicy/app/DummyIme/Android.bp +++ b/hostsidetests/devicepolicy/app/DummyIme/Android.bp @@ -25,6 +25,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp b/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp index e0d39d35d97..8bbad848939 100644 --- a/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp +++ b/hostsidetests/devicepolicy/app/DummyLauncher/Android.bp @@ -24,6 +24,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp b/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp index 825bb12a918..e4216d591a3 100644 --- a/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp +++ b/hostsidetests/devicepolicy/app/HasLauncherActivityApp/Android.bp @@ -29,7 +29,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], sdk_version: "current", } @@ -50,7 +50,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "no_launcher_activity_AndroidManifest.xml", sdk_version: "current", @@ -72,7 +72,7 @@ android_test_helper_app { "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 d807701d6d9..c65008ad404 100644 --- a/hostsidetests/devicepolicy/app/IntentReceiver/Android.bp +++ b/hostsidetests/devicepolicy/app/IntentReceiver/Android.bp @@ -32,6 +32,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/IntentSender/Android.bp b/hostsidetests/devicepolicy/app/IntentSender/Android.bp index 8e6a7f0df5d..67e7a755e2c 100644 --- a/hostsidetests/devicepolicy/app/IntentSender/Android.bp +++ b/hostsidetests/devicepolicy/app/IntentSender/Android.bp @@ -32,6 +32,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/LauncherTests/Android.bp b/hostsidetests/devicepolicy/app/LauncherTests/Android.bp index 3aad240f73f..022c5fbf363 100644 --- a/hostsidetests/devicepolicy/app/LauncherTests/Android.bp +++ b/hostsidetests/devicepolicy/app/LauncherTests/Android.bp @@ -33,6 +33,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp b/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp index 32632677945..b1507f9a0ba 100644 --- a/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp +++ b/hostsidetests/devicepolicy/app/LauncherTestsSupport/Android.bp @@ -25,6 +25,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp b/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp index c5a56e15765..7e0867a67ce 100644 --- a/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp +++ b/hostsidetests/devicepolicy/app/ManagedProfile/Android.bp @@ -38,7 +38,7 @@ android_test_helper_app { "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 94f97845d7d..f944368d66f 100644 --- a/hostsidetests/devicepolicy/app/MeteredDataTestApp/Android.bp +++ b/hostsidetests/devicepolicy/app/MeteredDataTestApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 a10f627662d..e667c50a4a7 100644 --- a/hostsidetests/devicepolicy/app/NotificationSender/Android.bp +++ b/hostsidetests/devicepolicy/app/NotificationSender/Android.bp @@ -21,7 +21,7 @@ android_test_helper_app { "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 d0de5a7d35b..117353f06c1 100644 --- a/hostsidetests/devicepolicy/app/PackageInstaller/Android.bp +++ b/hostsidetests/devicepolicy/app/PackageInstaller/Android.bp @@ -33,6 +33,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp b/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp index 7c9fb379740..d4679d318bd 100644 --- a/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp +++ b/hostsidetests/devicepolicy/app/PasswordComplexity/Android.bp @@ -31,6 +31,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/PrintingApp/Android.bp b/hostsidetests/devicepolicy/app/PrintingApp/Android.bp index 8b54d280e30..51ebde4935b 100644 --- a/hostsidetests/devicepolicy/app/PrintingApp/Android.bp +++ b/hostsidetests/devicepolicy/app/PrintingApp/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp b/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp index 3895dab3286..65f1e8bed87 100644 --- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp +++ b/hostsidetests/devicepolicy/app/ProfileOwner/Android.bp @@ -33,6 +33,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp b/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp index d0ed2e78ef2..49893de2dcb 100644 --- a/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp +++ b/hostsidetests/devicepolicy/app/SeparateProfileChallenge/Android.bp @@ -34,6 +34,6 @@ android_test_helper_app { "vts10", "general-tests", "sts", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/SharingApps/Android.bp b/hostsidetests/devicepolicy/app/SharingApps/Android.bp index 0ba93e0e092..e44f3358e3e 100644 --- a/hostsidetests/devicepolicy/app/SharingApps/Android.bp +++ b/hostsidetests/devicepolicy/app/SharingApps/Android.bp @@ -34,7 +34,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], manifest: "sharingapp1/AndroidManifest.xml", } @@ -61,7 +61,7 @@ android_test_helper_app { "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 32a9c79a19f..cef49f6a73f 100644 --- a/hostsidetests/devicepolicy/app/SimpleApp/Android.bp +++ b/hostsidetests/devicepolicy/app/SimpleApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 76fd05d245b..3b8e4f95cf3 100644 --- a/hostsidetests/devicepolicy/app/SimplePreMApp/Android.bp +++ b/hostsidetests/devicepolicy/app/SimplePreMApp/Android.bp @@ -25,6 +25,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp b/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp index cc3538bb52b..dd8189ab411 100644 --- a/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp +++ b/hostsidetests/devicepolicy/app/SimpleSmsApp/Android.bp @@ -25,6 +25,6 @@ android_test { "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 6d278ccbf52..bbe0fbffad5 100644 --- a/hostsidetests/devicepolicy/app/SingleAdminApp/Android.bp +++ b/hostsidetests/devicepolicy/app/SingleAdminApp/Android.bp @@ -33,6 +33,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp b/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp index 7d3689a26f7..5f52a2cb9fc 100644 --- a/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp +++ b/hostsidetests/devicepolicy/app/TransferOwnerIncomingApp/Android.bp @@ -35,6 +35,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp b/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp index 5c62f0bb1ef..5fa314f3ab6 100644 --- a/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp +++ b/hostsidetests/devicepolicy/app/TransferOwnerOutgoingApp/Android.bp @@ -35,6 +35,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp b/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp index b6a608dddfe..8d2960ce349 100644 --- a/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp +++ b/hostsidetests/devicepolicy/app/WidgetProvider/Android.bp @@ -22,6 +22,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp index fa1b7936bba..d6c9e5f11a0 100644 --- a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp +++ b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.bp @@ -25,6 +25,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/hostsidetests/scopedstorage/device/AndroidTest.xml b/hostsidetests/scopedstorage/device/AndroidTest.xml index fb8d2bc13aa..7e6f8953ed5 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/res/cve_2020_0240.pac b/hostsidetests/securitybulletin/res/cve_2020_0240.pac new file mode 100644 index 00000000000..677120e4f23 --- /dev/null +++ b/hostsidetests/securitybulletin/res/cve_2020_0240.pac @@ -0,0 +1,27 @@ +/* + * 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. + */ + +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 de62221ca8e..00000000000 --- 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 index 084a1fe3d2c..d626fccdfe5 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 00000000000..61e5e9f032b --- /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 b02eeea126a..4cd94c9187f 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 @@ public class CVE_2020_0224 extends SecurityTestCase { @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 00000000000..352274e9c64 --- /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 1ec6d891e6b..797e58d76e0 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 @@ import static org.junit.Assert.*; @RunWith(DeviceJUnit4ClassRunner.class) public class Poc17_05 extends SecurityTestCase { - /** - * b/34277115 - */ - @Test - @SecurityTest(minPatchLevel = "2017-05") - public void testPocCVE_2017_0630() throws Exception { - if (containsDriver(getDevice(), "/sys/kernel/debug/tracing/printk_formats")) { - 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 5dc459059d9..d6430844e4a 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.MetricsReportLog; 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 @@ public class SecurityTestCase extends BaseHostJUnit4Test { 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 @@ public class SecurityTestCase extends BaseHostJUnit4Test { 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 class SecurityTestCase extends BaseHostJUnit4Test { */ 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 3051a183fce..90a40977467 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 @@ public class LocalForegroundService extends LocalService { 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 792ef5d3d83..d2e0776524c 100644 --- a/tests/app/src/android/app/cts/ServiceTest.java +++ b/tests/app/src/android/app/cts/ServiceTest.java @@ -1105,6 +1105,31 @@ public class ServiceTest extends ActivityTestsBase { 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 352ed6d3060..7ec8bfcca84 100644 --- a/tests/backup/app/Android.bp +++ b/tests/backup/app/Android.bp @@ -26,7 +26,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], platform_apis: true, manifest: "fullbackup/AndroidManifest.xml" @@ -47,7 +47,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], platform_apis: true, manifest: "keyvalue/AndroidManifest.xml" @@ -68,7 +68,7 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], platform_apis: true, manifest: "permission/AndroidManifest.xml" @@ -89,7 +89,7 @@ android_test_helper_app { "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 ef6a95eb75a..39d08127976 100644 --- a/tests/framework/base/windowmanager/Android.mk +++ b/tests/framework/base/windowmanager/Android.mk @@ -44,7 +44,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ 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 07069deff76..c8245da1b6b 100644 --- a/tests/framework/base/windowmanager/alertwindowapp/Android.bp +++ b/tests/framework/base/windowmanager/alertwindowapp/Android.bp @@ -29,5 +29,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp b/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp index e7cbcdba8f3..fd6d943be6f 100644 --- a/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp +++ b/tests/framework/base/windowmanager/alertwindowappsdk25/Android.bp @@ -31,5 +31,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/alertwindowservice/Android.bp b/tests/framework/base/windowmanager/alertwindowservice/Android.bp index 58d8688919f..6aee4e4056d 100644 --- a/tests/framework/base/windowmanager/alertwindowservice/Android.bp +++ b/tests/framework/base/windowmanager/alertwindowservice/Android.bp @@ -27,6 +27,7 @@ android_test { "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 b12f93b2d6d..3512924d721 100644 --- a/tests/framework/base/windowmanager/app/Android.bp +++ b/tests/framework/base/windowmanager/app/Android.bp @@ -33,5 +33,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/app27/Android.bp b/tests/framework/base/windowmanager/app27/Android.bp index 6ddf919c573..79d2d22974e 100644 --- a/tests/framework/base/windowmanager/app27/Android.bp +++ b/tests/framework/base/windowmanager/app27/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/appAShareUid/Android.bp b/tests/framework/base/windowmanager/appAShareUid/Android.bp index 57adfd61346..052f829921b 100644 --- a/tests/framework/base/windowmanager/appAShareUid/Android.bp +++ b/tests/framework/base/windowmanager/appAShareUid/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/appBShareUid/Android.bp b/tests/framework/base/windowmanager/appBShareUid/Android.bp index ec15e80daf9..8fe4775ea67 100644 --- a/tests/framework/base/windowmanager/appBShareUid/Android.bp +++ b/tests/framework/base/windowmanager/appBShareUid/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp b/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp index c83b44fd116..8582bf1e5a2 100644 --- a/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp +++ b/tests/framework/base/windowmanager/appDeprecatedSdk/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/appDisplaySize/Android.bp b/tests/framework/base/windowmanager/appDisplaySize/Android.bp index 819a9bfafeb..d492d7bfcb7 100644 --- a/tests/framework/base/windowmanager/appDisplaySize/Android.bp +++ b/tests/framework/base/windowmanager/appDisplaySize/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp b/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp index d110d199495..6f5d5e4b61e 100644 --- a/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp +++ b/tests/framework/base/windowmanager/appPrereleaseSdk/Android.bp @@ -24,5 +24,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/appProfileable/Android.bp b/tests/framework/base/windowmanager/appProfileable/Android.bp index cd540941943..2dcd954868f 100644 --- a/tests/framework/base/windowmanager/appProfileable/Android.bp +++ b/tests/framework/base/windowmanager/appProfileable/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts" ], } diff --git a/tests/framework/base/windowmanager/appSecondUid/Android.bp b/tests/framework/base/windowmanager/appSecondUid/Android.bp index 5f44f5c971b..692f73bbef1 100644 --- a/tests/framework/base/windowmanager/appSecondUid/Android.bp +++ b/tests/framework/base/windowmanager/appSecondUid/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/appThirdUid/Android.bp b/tests/framework/base/windowmanager/appThirdUid/Android.bp index 08a878ccb79..22bab9d60ed 100644 --- a/tests/framework/base/windowmanager/appThirdUid/Android.bp +++ b/tests/framework/base/windowmanager/appThirdUid/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/dndsourceapp/Android.bp b/tests/framework/base/windowmanager/dndsourceapp/Android.bp index 7abd47847ce..9a1463e1937 100644 --- a/tests/framework/base/windowmanager/dndsourceapp/Android.bp +++ b/tests/framework/base/windowmanager/dndsourceapp/Android.bp @@ -26,5 +26,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/dndtargetapp/Android.bp b/tests/framework/base/windowmanager/dndtargetapp/Android.bp index 00b40551e91..0a14121d22e 100644 --- a/tests/framework/base/windowmanager/dndtargetapp/Android.bp +++ b/tests/framework/base/windowmanager/dndtargetapp/Android.bp @@ -24,6 +24,7 @@ android_test { "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 13dbca2e31f..4420670fa80 100644 --- a/tests/framework/base/windowmanager/dndtargetappsdk23/Android.bp +++ b/tests/framework/base/windowmanager/dndtargetappsdk23/Android.bp @@ -24,6 +24,7 @@ android_test { "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 98e5ff5b874..6e19de2ec1c 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.graphics.Rect; 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 @@ public class PinnedStackTests extends ActivityManagerTestBase { } @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 c551c29896c..3a19970473d 100644 --- a/tests/framework/base/windowmanager/translucentapp/Android.bp +++ b/tests/framework/base/windowmanager/translucentapp/Android.bp @@ -31,5 +31,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/framework/base/windowmanager/translucentappsdk26/Android.bp b/tests/framework/base/windowmanager/translucentappsdk26/Android.bp index 7c8d0d88929..4ec800b6fd0 100644 --- a/tests/framework/base/windowmanager/translucentappsdk26/Android.bp +++ b/tests/framework/base/windowmanager/translucentappsdk26/Android.bp @@ -29,5 +29,6 @@ android_test { "cts", "vts10", "general-tests", + "sts", ], } diff --git a/tests/inputmethod/mockime/Android.bp b/tests/inputmethod/mockime/Android.bp index 228354134ef..6159a6c4671 100644 --- a/tests/inputmethod/mockime/Android.bp +++ b/tests/inputmethod/mockime/Android.bp @@ -43,6 +43,7 @@ android_test_helper_app { "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 a1dd9147ec7..412d52e561a 100644 --- a/tests/tests/content/Android.bp +++ b/tests/tests/content/Android.bp @@ -71,7 +71,7 @@ android_test { "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 8536f30483d..dbcba7f339e 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.DecoderTest.AudioParameter; 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 @@ public class DecoderTestXheAac { @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 48208d9f63e..98acf0ba834 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 class MediaMetadataRetrieverTest extends AndroidTestCase { } 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 093cc8c80a1..fb8212f7528 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 @@ public final class TestUtils { 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 e3a26e03ce4..f0f6d976423 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 0b1c4369bc5..a699281f192 100644 --- a/tests/tests/permission/AppThatAccessesCalendarContactsBodySensorCustomPermission/Android.bp +++ b/tests/tests/permission/AppThatAccessesCalendarContactsBodySensorCustomPermission/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp b/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp index 7a8d3e9761a..85c1240ec47 100644 --- a/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp +++ b/tests/tests/permission/AppThatAccessesLocationOnCommand/Android.bp @@ -24,7 +24,7 @@ android_test_helper_app { "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 8fd122f33c4..e89895dc745 100644 --- a/tests/tests/permission/AppThatDefinesUndefinedPermissionGroupElement/Android.bp +++ b/tests/tests/permission/AppThatDefinesUndefinedPermissionGroupElement/Android.bp @@ -23,7 +23,7 @@ android_test_helper_app { "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 5289a03ead9..54ea4acd392 100644 --- a/tests/tests/permission/AppThatDoesNotHaveBgLocationAccess/Android.bp +++ b/tests/tests/permission/AppThatDoesNotHaveBgLocationAccess/Android.bp @@ -24,6 +24,6 @@ android_test_helper_app { "vts10", "general-tests", "sts", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp b/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp index a7737517af8..149f2a8738d 100644 --- a/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp +++ b/tests/tests/permission/AppThatRequestContactsAndCallLogPermission16/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp b/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp index 4aafcf0c5ae..91e9c9965ae 100644 --- a/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp +++ b/tests/tests/permission/AppThatRequestContactsPermission15/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp b/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp index ce315fc6cb1..b52d97c5b47 100644 --- a/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp +++ b/tests/tests/permission/AppThatRequestContactsPermission16/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp b/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp index 5558cd08ab4..79aee92dc10 100644 --- a/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp +++ b/tests/tests/permission/AppThatRequestLocationAndBackgroundPermission29/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp index 5675d7ca6c1..c49a60774c6 100644 --- a/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp +++ b/tests/tests/permission/AppThatRequestLocationPermission22/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp index 8d376883162..dcee0ff681b 100644 --- a/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp +++ b/tests/tests/permission/AppThatRequestLocationPermission28/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp index 3bf0f8a1e44..6df9086c825 100644 --- a/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp +++ b/tests/tests/permission/AppThatRequestLocationPermission29/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp b/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp index 41154281970..b5f8076b8b3 100644 --- a/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp +++ b/tests/tests/permission/AppThatRequestLocationPermission29v4/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestOneTimePermission/Android.bp b/tests/tests/permission/AppThatRequestOneTimePermission/Android.bp index 01de19bfb5a..506cf929d4a 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 @@ android_test_helper_app { // 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 d7357396d54..655cd6f1616 100644 --- a/tests/tests/permission/AppThatRequestPermissionAandB/Android.bp +++ b/tests/tests/permission/AppThatRequestPermissionAandB/Android.bp @@ -24,7 +24,7 @@ android_test_helper_app { "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 9b0963bc843..b6c80c52277 100644 --- a/tests/tests/permission/AppThatRequestPermissionAandC/Android.bp +++ b/tests/tests/permission/AppThatRequestPermissionAandC/Android.bp @@ -24,7 +24,7 @@ android_test_helper_app { "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 29fe7a2f4d9..3786e39cf0c 100644 --- a/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp +++ b/tests/tests/permission/AppThatRequestStoragePermission28/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp b/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp index 412b2d747bf..033a87ed56f 100644 --- a/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp +++ b/tests/tests/permission/AppThatRequestStoragePermission29/Android.bp @@ -23,6 +23,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppThatRunsRationaleTests/Android.bp b/tests/tests/permission/AppThatRunsRationaleTests/Android.bp index f2c7fa50097..de5dd4b6d2c 100644 --- a/tests/tests/permission/AppThatRunsRationaleTests/Android.bp +++ b/tests/tests/permission/AppThatRunsRationaleTests/Android.bp @@ -25,7 +25,7 @@ android_test_helper_app { "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 e82f753a4ee..a336a616a47 100644 --- a/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission28/Android.bp +++ b/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission28/Android.bp @@ -25,6 +25,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp b/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp index 46f0fb9f74b..dcc4792fa11 100644 --- a/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp +++ b/tests/tests/permission/AppWithSharedUidThatRequestLocationPermission29/Android.bp @@ -25,6 +25,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp b/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp index 9f7c3d149b3..9eefccc8f86 100644 --- a/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp +++ b/tests/tests/permission/AppWithSharedUidThatRequestsNoPermissions/Android.bp @@ -22,6 +22,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp b/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp index 43cd87512f8..b999a5100e9 100644 --- a/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp +++ b/tests/tests/permission/AppWithSharedUidThatRequestsPermissions/Android.bp @@ -22,6 +22,6 @@ android_test_helper_app { "cts", "vts10", "general-tests", - "mts", + "mts-permission", ], } diff --git a/tests/tests/permission/StorageEscalationApp28/Android.bp b/tests/tests/permission/StorageEscalationApp28/Android.bp index 63fceda30eb..776374c0b98 100644 --- a/tests/tests/permission/StorageEscalationApp28/Android.bp +++ b/tests/tests/permission/StorageEscalationApp28/Android.bp @@ -20,6 +20,7 @@ android_test_helper_app { 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 8eb6acb9e07..b620bc5c6d8 100644 --- a/tests/tests/permission/StorageEscalationApp29Full/Android.bp +++ b/tests/tests/permission/StorageEscalationApp29Full/Android.bp @@ -21,5 +21,6 @@ android_test_helper_app { "cts", "general-tests", "mts", + "sts", ], } diff --git a/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp b/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp index 424a67fc531..1be05a342ff 100644 --- a/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp +++ b/tests/tests/permission/StorageEscalationApp29Scoped/Android.bp @@ -21,5 +21,6 @@ android_test_helper_app { "cts", "general-tests", "mts", + "sts", ], } diff --git a/tests/tests/permission/sdk28/Android.bp b/tests/tests/permission/sdk28/Android.bp index e7ec37f2bd8..dbc7e020331 100644 --- a/tests/tests/permission/sdk28/Android.bp +++ b/tests/tests/permission/sdk28/Android.bp @@ -25,6 +25,6 @@ android_test { "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 3e302a9b217..2e67179e0ce 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.Instrumentation 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 @@ class StorageEscalationTest { } @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 @@ class StorageEscalationTest { 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 74e2b5a7dc4..f984ea0a6ef 100644 --- a/tests/tests/permission/telephony/Android.bp +++ b/tests/tests/permission/telephony/Android.bp @@ -22,7 +22,7 @@ android_test { "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 92ebffade27..df94eea9403 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionDefinerApp/Android.bp @@ -23,7 +23,7 @@ android_test_helper_app { "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 54c0f8ee356..60650537f0c 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/AdversarialPermissionUserApp/Android.bp @@ -23,7 +23,7 @@ android_test_helper_app { "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 8281a57ef21..bb534f3520d 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionDefinerApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionDefinerApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 ab825ba980d..6245c590623 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionEscalatorApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionEscalatorApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 666c143de18..d4e9bbcdd16 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionUserApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/InstallPermissionUserApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 c7f84915480..c35768e6a4d 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionDefinerApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 942691bcb82..2d7e98e83c1 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/RuntimePermissionUserApp/Android.bp @@ -22,7 +22,7 @@ android_test_helper_app { "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 516527cebe4..11b28f18987 100644 --- a/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp +++ b/tests/tests/permission/testapps/RevokePermissionWhenRemoved/VictimPermissionDefinerApp/Android.bp @@ -23,7 +23,7 @@ android_test_helper_app { "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 fcfb5fdc3cd..60c39fee0a4 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 com.android.compatibility.common.util.SystemUtil.runWithShellPermissionId 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 @@ class PermissionUsageInfoTest : BaseUsePermissionTest() { ) } + @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 00000000000..b64071290be --- /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 Binary files differnew file mode 100644 index 00000000000..a6665024bd8 --- /dev/null +++ b/tests/tests/security/res/raw/cve_2019_2107_hevc.mp4 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 d3278ee1252..6d504f6a5b3 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 @@ public class CVE_2021_0394 { */ @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 a2d5ccd9cab..8b646a2d74e 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 @@ public class StagefrightTest { ***********************************************************/ @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 50fb78a4c01..4fbe86901ac 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 ac0283c5f21..360895ae605 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 class TestHtmlConstants { 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 class TestHtmlConstants { 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 81ea695998b..a99e9aff1a9 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 @@ public class WebViewClientTest extends ActivityInstrumentationTestCase2<WebViewC } }.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) { |