Inject WAKEUP instead of POWER
To power the device on, inject KEYCODE_WAKEUP to avoid a possible race condition (the device might become off between the test isScreenOn() and the POWER keycode injection).
This commit is contained in:
parent
30714aba34
commit
322f1512ea
1 changed files with 3 additions and 3 deletions
|
@ -48,10 +48,10 @@ public class Controller {
|
|||
public void control() throws IOException {
|
||||
// on start, power on the device
|
||||
if (!device.isScreenOn()) {
|
||||
device.injectKeycode(KeyEvent.KEYCODE_POWER);
|
||||
device.injectKeycode(KeyEvent.KEYCODE_WAKEUP);
|
||||
|
||||
// dirty hack
|
||||
// After POWER is injected, the device is powered on asynchronously.
|
||||
// After the keycode is injected, the device is powered on asynchronously.
|
||||
// To turn the device screen off while mirroring, the client will send a message that
|
||||
// would be handled before the device is actually powered on, so its effect would
|
||||
// be "canceled" once the device is turned back on.
|
||||
|
@ -225,7 +225,7 @@ public class Controller {
|
|||
}
|
||||
|
||||
private boolean pressBackOrTurnScreenOn() {
|
||||
int keycode = device.isScreenOn() ? KeyEvent.KEYCODE_BACK : KeyEvent.KEYCODE_POWER;
|
||||
int keycode = device.isScreenOn() ? KeyEvent.KEYCODE_BACK : KeyEvent.KEYCODE_WAKEUP;
|
||||
return device.injectKeycode(keycode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue