Skip to content

Instantly share code, notes, and snippets.

@oguzbabaoglu
Created February 10, 2016 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oguzbabaoglu/ff01f98d8527a07ae029 to your computer and use it in GitHub Desktop.
Save oguzbabaoglu/ff01f98d8527a07ae029 to your computer and use it in GitHub Desktop.
Wake lock solution in u2020
String name = U2020TestRunner.class.getSimpleName();
// Unlock the device so that the tests can input keystrokes.
KeyguardManager keyguard = (KeyguardManager) app.getSystemService(KEYGUARD_SERVICE);
keyguard.newKeyguardLock(name).disableKeyguard();
// Wake up the screen.
PowerManager power = (PowerManager) app.getSystemService(POWER_SERVICE);
wakeLock = power.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, name);
wakeLock.acquire();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment