aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin Jin <kjin@google.com>2014-05-06 13:30:42 -0700
committerKevin Jin <kjin@google.com>2014-05-06 13:30:42 -0700
commitd414dc59622a9a8a0a2e3af94387d2ecd148ca55 (patch)
tree50828a3107578e6fba67803606793c9eedbea2c2 /src
parentf1fd9d00b1c6add0647f8cb7a272cff75ec8e2c7 (diff)
downloaddroiddriver-d414dc59622a9a8a0a2e3af94387d2ecd148ca55.tar.gz
fix BaseUiDevice.wakeUp when the root is invisible
The old code called getRootElement().perform(POWER_ON). UiElement.perform() checks that the UiElement is visible. So wakeUp only worked when the root UiElement is launcher, which has the visible attribute even when the screen is off. The new implementation always works because we don't use the root now. Change-Id: I6edf9c9f8d0d112cff669ee2a04f123a30ec0b5e
Diffstat (limited to 'src')
-rw-r--r--src/com/google/android/droiddriver/base/BaseUiDevice.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/com/google/android/droiddriver/base/BaseUiDevice.java b/src/com/google/android/droiddriver/base/BaseUiDevice.java
index cc1d092..606bfcb 100644
--- a/src/com/google/android/droiddriver/base/BaseUiDevice.java
+++ b/src/com/google/android/droiddriver/base/BaseUiDevice.java
@@ -39,9 +39,10 @@ public abstract class BaseUiDevice implements UiDevice {
private static final SingleKeyAction POWER_OFF = new SingleKeyAction(KeyEvent.KEYCODE_POWER, 0,
false);
// power on should always trigger new events
- private static final SingleKeyAction POWER_ON = new SingleKeyAction(KeyEvent.KEYCODE_POWER, 1000L,
- false);
+ private static final SingleKeyAction POWER_ON = new SingleKeyAction(KeyEvent.KEYCODE_POWER,
+ 1000L, false);
+ @SuppressWarnings("deprecation")
@Override
public boolean isScreenOn() {
PowerManager pm =
@@ -53,7 +54,10 @@ public abstract class BaseUiDevice implements UiDevice {
@Override
public void wakeUp() {
if (!isScreenOn()) {
- perform(POWER_ON);
+ // Cannot call perform(POWER_ON) because perform() checks the UiElement is
+ // visible.
+ POWER_ON.perform(getContext().getInjector(), null);
+ getContext().tryWaitForIdleSync(POWER_ON.getTimeoutMillis());
}
}