Java Code Examples for android.support.test.uiautomator.UiDevice.wakeUp()

The following are Jave code examples for showing how to use wakeUp() of the android.support.test.uiautomator.UiDevice class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: smart-lens   File: BaseTestClass.java   Source Code and License Vote up 9 votes
@Before
public void setup() {
    // Unlock the screen if it's locked
    UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    try {
        device.wakeUp();
    } catch (RemoteException e) {
        e.printStackTrace();
    }

    // Set the flags on our activity so it'll appear regardless of lock screen state
    new Handler(Looper.getMainLooper()).post(() -> {
        if (getActivity() == null) return;
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    });
}
 
Example 2
Project: bluesnap-android-int   File: EspressoBasedTest.java   Source Code and License Vote up 5 votes
public void wakeUpDeviceScreen() throws RemoteException {
    UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    uiDevice.wakeUp();
    ActivityLifecycleMonitorRegistry.getInstance().addLifecycleCallback(new ActivityLifecycleCallback() {
        @Override
        public void onActivityLifecycleChanged(Activity activity, Stage stage) {
            //if (stage == Stage.PRE_ON_CREATE) {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            // }
        }
    });
}