use of android.accessibilityservice.GestureDescription in project Auto.js by hyb1996.
the class GlobalActionAutomator method gesturesWithoutHandler.
@RequiresApi(api = Build.VERSION_CODES.N)
private boolean gesturesWithoutHandler(GestureDescription description) {
prepareLooperIfNeeded();
final VolatileBox<Boolean> result = new VolatileBox<>(false);
Handler handler = new Handler(Looper.myLooper());
mService.dispatchGesture(description, new AccessibilityService.GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
result.set(true);
quitLoop();
}
@Override
public void onCancelled(GestureDescription gestureDescription) {
result.set(false);
quitLoop();
}
}, handler);
Looper.loop();
return result.get();
}
use of android.accessibilityservice.GestureDescription in project kdeconnect-android by KDE.
the class MouseReceiverService method createClick.
@RequiresApi(api = Build.VERSION_CODES.N)
private static GestureDescription createClick(float x, float y, int duration) {
Path clickPath = new Path();
clickPath.moveTo(x, y);
GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, duration);
GestureDescription.Builder clickBuilder = new GestureDescription.Builder();
clickBuilder.addStroke(clickStroke);
return clickBuilder.build();
}
use of android.accessibilityservice.GestureDescription in project WeChatLuckyMoney by geeeeeeeeek.
the class HongbaoService method openPacket.
private void openPacket() {
DisplayMetrics metrics = getResources().getDisplayMetrics();
float dpi = metrics.densityDpi;
Log.d(TAG, "openPacket!" + dpi);
if (android.os.Build.VERSION.SDK_INT <= 23) {
mUnpackNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
} else {
if (android.os.Build.VERSION.SDK_INT > 23) {
Path path = new Path();
if (640 == dpi) {
// 1440
path.moveTo(720, 1575);
} else if (320 == dpi) {
// 720p
path.moveTo(355, 780);
} else if (480 == dpi) {
// 1080p
path.moveTo(533, 1115);
}
GestureDescription.Builder builder = new GestureDescription.Builder();
GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription(path, 450, 50)).build();
dispatchGesture(gestureDescription, new GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
Log.d(TAG, "onCompleted");
mMutex = false;
super.onCompleted(gestureDescription);
}
@Override
public void onCancelled(GestureDescription gestureDescription) {
Log.d(TAG, "onCancelled");
mMutex = false;
super.onCancelled(gestureDescription);
}
}, null);
}
}
}
use of android.accessibilityservice.GestureDescription in project robolectric by robolectric.
the class ShadowAccessibilityServiceTest method getGesturesDispatched_returnsFirstGestureResultCallback.
@Test
@Config(minSdk = N)
public void getGesturesDispatched_returnsFirstGestureResultCallback() {
GestureDescription gestureDescription = createTestGesture();
GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback();
service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/
null);
assertThat(shadow.getGesturesDispatched().get(0).callback()).isSameInstanceAs(gestureResultCallback);
}
use of android.accessibilityservice.GestureDescription in project robolectric by robolectric.
the class ShadowAccessibilityServiceTest method setCanDispatchGestures_true_causesDispatchGestureToReturnTrue.
@Test
@Config(minSdk = N)
public void setCanDispatchGestures_true_causesDispatchGestureToReturnTrue() {
GestureDescription gestureDescription = createTestGesture();
GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback();
shadow.setCanDispatchGestures(false);
shadow.setCanDispatchGestures(true);
assertThat(service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/
null)).isTrue();
}
Aggregations