Merge "Remove clock mode time picker when only testing spinner mode" into oreo-mr1-cts-dev
diff --git a/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py b/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
index 065f854..f7f2003 100644
--- a/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
+++ b/apps/CameraITS/tests/scene5/test_lens_shading_and_color_uniformity.py
@@ -52,6 +52,8 @@
 
     with its.device.ItsSession() as cam:
         props = cam.get_camera_properties()
+        its.caps.skip_unless(its.caps.ae_lock(props) and
+                             its.caps.awb_lock(props))
         if its.caps.read_3a(props):
             # Converge 3A and get the estimates.
             sens, exp, gains, xform, focus = cam.do_3a(get_results=True,
diff --git a/apps/CameraITS/tools/validate_scene.py b/apps/CameraITS/tools/validate_scene.py
index cfe14e2..1c0f0fd 100644
--- a/apps/CameraITS/tools/validate_scene.py
+++ b/apps/CameraITS/tools/validate_scene.py
@@ -49,8 +49,9 @@
                 " to frame the test scene: " + scene_name +
                 "\nThe scene setup should be: " + scene_desc )
         # Converge 3A prior to capture.
-        cam.do_3a(do_af=do_af, lock_ae=True, lock_awb=True)
         props = cam.get_camera_properties()
+        cam.do_3a(do_af=do_af, lock_ae=its.caps.ae_lock(props),
+                  lock_awb=its.caps.awb_lock(props))
         req = its.objects.fastest_auto_capture_request(props)
         if its.caps.ae_lock(props):
             req["android.control.awbLock"] = True
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java
index a441e56..b3d7add 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/KeyguardLockedTests.java
@@ -177,6 +177,7 @@
         mAmWmState.assertVisibility(SHOW_WHEN_LOCKED_ACTIVITY, true);
 
         gotoKeyguard();
+        mAmWmState.computeState(mDevice, null);
         mAmWmState.waitForKeyguardShowingAndOccluded(mDevice);
         assertShowingAndOccluded();
         mAmWmState.assertVisibility(SHOW_WHEN_LOCKED_ACTIVITY, true);
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySoftKeyboardModesTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySoftKeyboardModesTest.java
index 49c209f..eb8e0e8 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySoftKeyboardModesTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilitySoftKeyboardModesTest.java
@@ -140,26 +140,6 @@
         assertTrue(mKeyboardController.removeOnShowModeChangedListener(listener));
     }
 
-    public void testHideSoftKeyboard_shouldHideKeyboardOnRequest() throws Exception {
-        // The soft keyboard should be in its default mode.
-        assertEquals(SHOW_MODE_AUTO, mKeyboardController.getShowMode());
-
-        if (!tryShowSoftInput()) {
-            // If the current (default) IME declined to show its window, then there is nothing we
-            // can test here.
-            // TODO: Create a mock IME so that we can test only the framework behavior.
-            return;
-        }
-
-        waitForImePresentToBe(true);
-        // Request the keyboard be hidden.
-        assertTrue(mKeyboardController.setShowMode(SHOW_MODE_HIDDEN));
-
-        waitForImePresentToBe(false);
-
-        assertTrue(mKeyboardController.setShowMode(SHOW_MODE_AUTO));
-    }
-
     private void waitForCallbackValueWithLock(int expectedValue) throws Exception {
         long timeoutTimeMillis = SystemClock.uptimeMillis() + TIMEOUT_PROPAGATE_SETTING;
 
@@ -180,89 +160,8 @@
                 + "> does not match expected value < " + expectedValue + ">");
     }
 
-    private void waitForWindowChanges() {
-        try {
-            mUiAutomation.executeAndWaitForEvent(new Runnable() {
-                @Override
-                public void run() {
-                    // Do nothing.
-                }
-            },
-            new UiAutomation.AccessibilityEventFilter() {
-                @Override
-                public boolean accept (AccessibilityEvent event) {
-                    return event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED;
-                }
-            },
-            TIMEOUT_PROPAGATE_SETTING);
-        } catch (TimeoutException ignored) {
-            // Ignore since the event could have occurred before this method was called. There
-            // should be a check after this method returns to catch incorrect values.
-        }
-    }
-
-    private boolean isImeWindowPresent() {
-        List<AccessibilityWindowInfo> windows = mUiAutomation.getWindows();
-        for (int i = 0; i < windows.size(); i++) {
-            if (windows.get(i).getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private void waitForImePresentToBe(boolean imeShown) {
-        long timeOutTime = System.currentTimeMillis() + TIMEOUT_ASYNC_PROCESSING;
-        while (isImeWindowPresent() != imeShown) {
-            assertTrue(System.currentTimeMillis() < timeOutTime);
-            waitForWindowChanges();
-        }
-    }
-
     /**
-     * Tries to call {@link InputMethodManager#hideSoftInputFromWindow(IBinder, int)} to see if
-     * software keyboard is shown as a result or not.
-     * @return {@code true} if the current input method reported that it is currently shown
-     * @throws Exception when the result is unknown, including the system did not return the result
-     *                   within {@link #TIMEOUT_SHOW_SOFTINPUT_RESULT}
-     */
-    private boolean tryShowSoftInput() throws Exception {
-        final BlockingQueue<Integer> queue = new ArrayBlockingQueue<>(1);
-
-        getInstrumentation().runOnMainSync(() -> {
-            Activity activity = getActivity();
-            ResultReceiver resultReceiver =
-                    new ResultReceiver(new Handler(activity.getMainLooper())) {
-                            @Override
-                            protected void onReceiveResult(int resultCode, Bundle resultData) {
-                                queue.add(resultCode);
-                            }
-                    };
-            View editText = activity.findViewById(R.id.edit_text);
-            activity.getSystemService(InputMethodManager.class)
-                    .showSoftInput(editText, InputMethodManager.SHOW_FORCED, resultReceiver);
-        });
-
-        Integer result;
-        try {
-            result = queue.poll(TIMEOUT_SHOW_SOFTINPUT_RESULT, TimeUnit.MILLISECONDS);
-        } catch (InterruptedException e) {
-            throw new Exception("Failed to get the result of showSoftInput().", e);
-        }
-        if (result == null) {
-            throw new Exception("Failed to get the result of showSoftInput() within timeout.");
-        }
-        switch (result) {
-            case InputMethodManager.RESULT_SHOWN:
-            case InputMethodManager.RESULT_UNCHANGED_SHOWN:
-                return true;
-            default:
-                return false;
-        }
-    }
-
-    /**
-     * Activity for testing the AccessibilityService API for hiding and showring the soft keyboard.
+     * Activity for testing the AccessibilityService API for hiding and showing the soft keyboard.
      */
     public static class SoftKeyboardModesActivity extends AccessibilityTestActivity {
         public SoftKeyboardModesActivity() {