Fix the KeyListeners tests.
Change-Id: Id2c34da004860a330c22d54f90dc8819940661f4
diff --git a/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java b/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java
index ef3d751..375ea54 100644
--- a/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java
+++ b/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java
@@ -64,8 +64,12 @@
mInstrumentation = getInstrumentation();
mTextView = (TextView) mActivity.findViewById(R.id.keylistener_textview);
- mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
- WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
+ mActivity.runOnUiThread(new Runnable() {
+ public void run() {
+ // Ensure that the screen is on for this test.
+ mTextView.setKeepScreenOn(true);
+ }
+ });
assertTrue(mActivity.waitForWindowFocus(5 * DateUtils.SECOND_IN_MILLIS));
}