Merge "Check max supported size before setting them to media format." into stage-aosp-oc-cts-dev
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
index 62b7af9..e065ce8 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/CompatibilityTestSuite.java
@@ -18,7 +18,6 @@
 import com.android.compatibility.SuiteInfo;
 import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
 import com.android.compatibility.common.tradefed.testtype.ISubPlan;
-import com.android.compatibility.common.tradefed.testtype.ModuleRepo;
 import com.android.compatibility.common.tradefed.testtype.SubPlan;
 import com.android.compatibility.common.util.TestFilter;
 import com.android.tradefed.build.IBuildInfo;
@@ -250,7 +249,7 @@
             }
         }
         if (mModuleName != null) {
-            List<String> modules = ModuleRepo.getModuleNamesMatching(
+            List<String> modules = ModuleRepoSuite.getModuleNamesMatching(
                     mBuildHelper.getTestsDir(), mModuleName);
             if (modules.size() == 0) {
                 throw new IllegalArgumentException(
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/ModuleRepoSuite.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/ModuleRepoSuite.java
index 2e5d712..a889330 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/ModuleRepoSuite.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/suite/ModuleRepoSuite.java
@@ -217,6 +217,33 @@
         return true;
     }
 
+    /**
+     * @return the {@link List} of modules whose name contains the given pattern.
+     */
+    public static List<String> getModuleNamesMatching(File directory, String pattern) {
+        String[] names = directory.list(new FilenameFilter(){
+            @Override
+            public boolean accept(File dir, String name) {
+                return name.contains(pattern) && name.endsWith(CONFIG_EXT);
+            }
+        });
+        List<String> modules = new ArrayList<String>(names.length);
+        for (String name : names) {
+            int index = name.indexOf(CONFIG_EXT);
+            if (index > 0) {
+                String module = name.substring(0, index);
+                if (module.equals(pattern)) {
+                    // Pattern represents a single module, just return a single-item list
+                    modules = new ArrayList<>(1);
+                    modules.add(module);
+                    return modules;
+                }
+                modules.add(module);
+            }
+        }
+        return modules;
+    }
+
     private void addFilters(Set<String> stringFilters,
             Map<String, List<TestFilter>> filters, Set<IAbi> abis) {
         for (String filterString : stringFilters) {
diff --git a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsJobDurationTests.java b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsJobDurationTests.java
index ea2b8d4..fb90b2e 100644
--- a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsJobDurationTests.java
+++ b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/BatteryStatsJobDurationTests.java
@@ -39,7 +39,7 @@
     private static final ComponentName JOB_COMPONENT_NAME =
             new ComponentName("com.android.server.cts.device.batterystats",
                     SimpleJobService.class.getName());
-    public static final String TAG = "BatteryStatsJobDurationTests";
+    public static final String TAG = "BatteryStatsJobDurTests";
 
     private JobInfo createJobInfo(int id) {
         JobInfo.Builder builder = new JobInfo.Builder(id, JOB_COMPONENT_NAME);
@@ -52,10 +52,11 @@
         JobScheduler js = mContext.getSystemService(JobScheduler.class);
         assertTrue("JobScheduler service not available", js != null);
         final JobInfo job = createJobInfo(1);
-        long startTime = System.currentTimeMillis();
         for (int i = 0; i < 3; i++) {
             CountDownLatch latch = SimpleJobService.resetCountDownLatch();
+            Log.i(TAG, "Scheduling job.");
             js.schedule(job);
+            Log.i(TAG, "Waiting for job to finish.");
             if (!latch.await(5, TimeUnit.SECONDS)) {
                 Log.e(TAG, "Job didn't finish in 5 seconds");
                 fail("Job didn't finish in 5 seconds");
diff --git a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleJobService.java b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleJobService.java
index c1d259b..cd9fdaf 100644
--- a/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleJobService.java
+++ b/hostsidetests/incident/apps/batterystatsapp/src/com/android/server/cts/device/batterystats/SimpleJobService.java
@@ -52,6 +52,7 @@
             if (sLatch != null) {
                 sLatch.countDown();
             }
+            Log.i(TAG, "Finished job.");
         }
     };
 
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml
index c31aec8..f7580e7 100755
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/AndroidManifest.xml
@@ -242,7 +242,10 @@
                   android:exported="true"
                   android:theme="@style/TranslucentTheme"
         />
+        <!-- An animation test with an explicitly opaque theme, overriding device defaults, as the
+             animation background being tested is not used in translucent activities. -->
         <activity android:name=".AnimationTestActivity"
+                  android:theme="@style/OpaqueTheme"
                   android:exported="true"
         />
         <activity android:name=".VirtualDisplayActivity"
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/res/values/styles.xml b/hostsidetests/services/activityandwindowmanager/activitymanager/app/res/values/styles.xml
index 5068ea9..6e2a820 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/res/values/styles.xml
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/res/values/styles.xml
@@ -37,6 +37,11 @@
         <item name="android:windowIsTranslucent">true</item>
         <item name="android:windowDisablePreview">true</item>
     </style>
+    <style name="OpaqueTheme">
+        <item name="android:windowIsTranslucent">false</item>
+        <item name="android:windowSwipeToDismiss">false</item>
+        <item name="android:windowIsFloating">false</item>
+    </style>
     <style name="NoPreview">
         <item name="android:windowDisablePreview">true</item>
     </style>
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index b97d109..c639251 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -323,6 +323,9 @@
     @MediumTest
     public void testProcSelfPagemapSane() throws ErrnoException, IOException {
         FileDescriptor pagemap = null;
+        int dumpable = Os.prctl(OsConstants.PR_GET_DUMPABLE, 0, 0, 0, 0);
+        Os.prctl(OsConstants.PR_SET_DUMPABLE, 1, 0, 0, 0);
+
         try {
             pagemap = Os.open("/proc/self/pagemap", OsConstants.O_RDONLY, 0);
 
@@ -339,6 +342,7 @@
         } finally {
             if (pagemap != null)
                 Os.close(pagemap);
+            Os.prctl(OsConstants.PR_SET_DUMPABLE, dumpable, 0, 0, 0);
         }
     }