2

I am trying to unlock the screen lock by swiping forward and for that I have used UiScroller.

Methiod1:

UiScrollable scrollUnlock = new UiScrollable(new UiSelector().packageName("com.android.systemui").className("android.view.ViewGroup").resourceId("com.android.systemui:id/notification_stack_scroller"));
scrollUnlock.scrollForward();

This method sometimes work and sometimes does not work. Any suggestions please.

Method 2:

UiObject scrollUnlock = device.findObject(new UiSelector().packageName("com.android.systemui").className("android.view.ViewGroup").resourceId("com.android.systemui:id/notification_stack_scroller").enabled(true).index(1).scrollable(true));
scrollUnlock.scrollable();

This method does not work.

Please suggest some ideas.

Corey
  • 1,217
  • 3
  • 22
  • 39

1 Answers1

2

Have you tried getUiDevice().swipe()

code:-

public void unlockBySwipe() throws UiObjectNotFoundException, Exception {
  x1 = getUiDevice().getDisplayWidth()/2;
  y1 = getUiDevice().getDisplayHeight()/2;
  x2 = getUiDevice().getDisplayWidth()/3;
  y2 = getUiDevice().getDisplayHeight()/3;
  getUiDevice().swipe(x1,y1,x2,y2, 10);
  getUiDevice().waitForIdle()
}
Rilwan
  • 2,251
  • 2
  • 19
  • 28