Merge "Update DynamicConfigPusher to find files using CompatibilityBuildHelper" into oc-dev
diff --git a/apps/CtsVerifier/res/values-watch/strings.xml b/apps/CtsVerifier/res/values-watch/strings.xml
index 6f1470c..37ad24f 100644
--- a/apps/CtsVerifier/res/values-watch/strings.xml
+++ b/apps/CtsVerifier/res/values-watch/strings.xml
@@ -24,4 +24,14 @@
       perform a palm press to turn off display and put device into suspend mode. The screen will
       turn on and device will vibrate once all the tests are completed.
     </string>
+
+    <string name="da_tapjacking_instructions">
+        1. Launch the device admin add screen by pressing the button below.\n
+        2. Wait for an overlaying transparent activity to show up obscuring the device admin details window.\n
+        3. The button to activate the admin should be disabled and should not register any taps.\n
+        4. Wait 10 seconds for the overlaying transparent activity to go away.\n
+        5. Exit the device admin details and return to this screen.\n
+        Pass the test if the device admin could not be activated while the details
+        window was being obscured.
+    </string>
 </resources>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/OverlayingActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/OverlayingActivity.java
index 52c7ed5..e81f301 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/OverlayingActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/tapjacking/OverlayingActivity.java
@@ -22,6 +22,7 @@
 import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
 
 import android.app.Activity;
+import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.view.WindowManager;
 
@@ -30,6 +31,8 @@
 
 public class OverlayingActivity extends Activity {
 
+    private static final long ACTIVITY_TIMEOUT_ON_WATCH = 10_000;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -37,5 +40,9 @@
         WindowManager.LayoutParams params = getWindow().getAttributes();
         params.flags = FLAG_LAYOUT_NO_LIMITS | FLAG_NOT_TOUCH_MODAL | FLAG_NOT_TOUCHABLE
                 | FLAG_KEEP_SCREEN_ON;
+        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+            getWindow().getDecorView().postDelayed(() -> OverlayingActivity.this.finish(),
+                    ACTIVITY_TIMEOUT_ON_WATCH);
+        }
     }
 }
diff --git a/hostsidetests/security/securityPatch/Bug-35764875/poc.c b/hostsidetests/security/securityPatch/Bug-35764875/poc.c
index 4b42cf2..b099685 100644
--- a/hostsidetests/security/securityPatch/Bug-35764875/poc.c
+++ b/hostsidetests/security/securityPatch/Bug-35764875/poc.c
@@ -109,7 +109,7 @@
   memset(&event32_dup, 0, sizeof(event32_dup));
   event32_dup.timeout_ms = 1;
 
-  for (int i = 0;i < 10000; i++) {
+  for (int i = 0;i < 500; i++) {
     memcpy(&event32, &event32_dup, sizeof(event32_dup));
     ret = ioctl(fd, AUDIO_GET_EVENT_32, &event32);
 
@@ -121,7 +121,7 @@
 
     trycount++;
 
-    usleep(100);
+    usleep(1000);
   }
 
   close(fd);
diff --git a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
index eb38965..ff41e40 100644
--- a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
@@ -42,6 +42,14 @@
     }
 
     /**
+     * Allows a CTS test to pass if called after a planned reboot.
+     */
+    public void updateKernelStartTime() throws Exception {
+        kernelStartTime = System.currentTimeMillis()/1000 -
+            Integer.parseInt(getDevice().executeShellCommand("cut -f1 -d. /proc/uptime").trim());
+    }
+
+    /**
      * Use {@link NativeDevice#enableAdbRoot()} internally.
      *
      * The test methods calling this function should run even if enableAdbRoot fails, which is why 
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
index 8e65682..d18cef7 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
@@ -105,6 +105,10 @@
      * Tests whether the Display sizes change when rotating the device.
      */
     public void testConfigurationUpdatesWhenRotatingWhileFullscreen() throws Exception {
+        if (!supportsRotation()) {
+            CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no rotation support");
+            return;
+        }
         setDeviceRotation(0);
         final String logSeparator = clearLogcat();
         launchActivityInStack(RESIZEABLE_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID);
@@ -268,6 +272,11 @@
      */
     @Presubmit
     public void testDialogWhenLargeSplitSmall() throws Exception {
+        if (!supportsSplitScreenMultiWindow()) {
+            CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
+            return;
+        }
+
         launchActivityInStack(DIALOG_WHEN_LARGE_ACTIVITY, DOCKED_STACK_ID);
         final ActivityManagerState.ActivityStack stack = mAmWmState.getAmState()
                 .getStackById(DOCKED_STACK_ID);
diff --git a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
index d4ed6be..a6d4226 100644
--- a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
+++ b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
@@ -562,6 +562,17 @@
         return output.startsWith("true");
     }
 
+    /**
+     * Rotation support is indicated by explicitly having both landscape and portrait
+     * features or not listing either at all.
+     */
+    protected boolean supportsRotation() throws DeviceNotAvailableException {
+        return (hasDeviceFeature("android.hardware.screen.landscape")
+                    && hasDeviceFeature("android.hardware.screen.portrait"))
+            || (!hasDeviceFeature("android.hardware.screen.landscape")
+                    && !hasDeviceFeature("android.hardware.screen.portrait"));
+    }
+
     protected boolean hasDeviceFeature(String requiredFeature) throws DeviceNotAvailableException {
         if (mAvailableFeatures == null) {
             // TODO: Move this logic to ITestDevice.
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java b/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
index 6fb5fbd..c99f001 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
@@ -131,20 +131,21 @@
     //         });
     //    }
 
-    static final int oversizedDimension = 5000;
+    // TODO(b/63993863) : Disabled pending public API to fetch maximum surface size.
+    // static final int oversizedDimension = 5000;
     // With FLAG_LAYOUT_NO_LIMITS  we should get the size we request, even if its much
     // larger than the screen.
-    public void testOversizedDimensionsNoLimits() throws Exception {
-        // TODO(b/36890978): We only run this in fullscreen because of the
-        // unclear status of NO_LIMITS for non-child surfaces in MW modes
-        doFullscreenTest("OversizedDimensionsNoLimits",
-            (WindowState parent, WindowState dialog) -> {
-                Rectangle contentFrame = parent.getContentFrame();
-                Rectangle expectedFrame = new Rectangle(contentFrame.x, contentFrame.y,
-                        oversizedDimension, oversizedDimension);
-                assertEquals(expectedFrame, dialog.getFrame());
-            });
-    }
+    // public void testOversizedDimensionsNoLimits() throws Exception {
+    // TODO(b/36890978): We only run this in fullscreen because of the
+    // unclear status of NO_LIMITS for non-child surfaces in MW modes
+    //     doFullscreenTest("OversizedDimensionsNoLimits",
+    //        (WindowState parent, WindowState dialog) -> {
+    //            Rectangle contentFrame = parent.getContentFrame();
+    //            Rectangle expectedFrame = new Rectangle(contentFrame.x, contentFrame.y,
+    //                    oversizedDimension, oversizedDimension);
+    //            assertEquals(expectedFrame, dialog.getFrame());
+    //        });
+    // }
 
     // If we request the MATCH_PARENT and a non-zero position, we wouldn't be
     // able to fit all of our content, so we should be adjusted to just fit the
diff --git a/tests/tests/media/src/android/media/cts/MediaCodecTest.java b/tests/tests/media/src/android/media/cts/MediaCodecTest.java
index afe5019..61298e8 100644
--- a/tests/tests/media/src/android/media/cts/MediaCodecTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCodecTest.java
@@ -1757,6 +1757,11 @@
      * <br> getInputBuffer() after the failed queueSecureInputBuffer() succeeds.
      */
     public void testCryptoError() throws Exception {
+        if (!supportsCodec(MIME_TYPE, true)) {
+            Log.i(TAG, "No encoder found for mimeType= " + MIME_TYPE);
+            return;
+        }
+
         MediaDrm drm = new MediaDrm(CLEARKEY_SCHEME_UUID);
         byte[] sessionId = drm.openSession();
         MediaCrypto crypto = new MediaCrypto(CLEARKEY_SCHEME_UUID, new byte[0]);