This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; | |
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; | |
import static android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; | |
public class CustomJUnitRunner extends AndroidJUnitRunner { | |
@Override public void onCreate(Bundle arguments) { | |
super.onCreate(arguments); | |
ActivityLifecycleMonitorRegistry.getInstance().addLifecycleCallback(new ActivityLifecycleCallback() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |