mirror of
https://github.com/appium/appium.git
synced 2026-02-07 01:58:55 -06:00
Fix touch actions below API 18
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package io.appium.android.bootstrap.handler;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import android.view.MotionEvent.PointerCoords;
|
||||
|
||||
import com.android.uiautomator.core.UiObject;
|
||||
@@ -39,12 +41,18 @@ public class MultiPointerGesture extends TouchableEvent {
|
||||
}
|
||||
} else {
|
||||
Object controller = getController();
|
||||
final Method pmpg = getMethod("performMultiPointerGesture", controller);
|
||||
Boolean rt = (Boolean)pmpg.invoke(controller, (Object)pcs);
|
||||
if (rt.booleanValue()) {
|
||||
return getSuccessResult("OK");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
final Method pmpg = getMethod("performMultiPointerGesture", controller);
|
||||
Boolean rt = (Boolean)pmpg.invoke(controller, (Object)pcs);
|
||||
if (rt.booleanValue()) {
|
||||
return getSuccessResult("OK");
|
||||
} else {
|
||||
return getErrorResult("Unable to perform multi pointer gesture");
|
||||
}
|
||||
} else {
|
||||
return getErrorResult("Unable to perform multi pointer gesture");
|
||||
Logger.error("Device does not support API < 18!");
|
||||
return new AndroidCommandResult(WDStatus.UNKNOWN_ERROR,
|
||||
"Cannot perform multi pointer gesture on device below API level 18");
|
||||
}
|
||||
}
|
||||
} catch (final ElementNotInHashException e) {
|
||||
|
||||
@@ -3,6 +3,8 @@ package io.appium.android.bootstrap.handler;
|
||||
import io.appium.android.bootstrap.CommandHandler;
|
||||
import io.appium.android.bootstrap.Logger;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import android.view.MotionEvent.PointerCoords;
|
||||
|
||||
import com.android.uiautomator.core.UiDevice;
|
||||
@@ -34,8 +36,14 @@ public abstract class TouchableEvent extends CommandHandler {
|
||||
final UiDevice device = UiDevice.getInstance();
|
||||
final Object bridge = enableField(device.getClass(), "mUiAutomationBridge")
|
||||
.get(device);
|
||||
final Object controller = enableField(bridge.getClass().getSuperclass(),
|
||||
"mInteractionController").get(bridge);
|
||||
Object controller = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
controller = enableField(bridge.getClass().getSuperclass(),
|
||||
"mInteractionController").get(bridge);
|
||||
} else {
|
||||
controller = enableField(bridge.getClass(),
|
||||
"mInteractionController").get(bridge);
|
||||
}
|
||||
return controller;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user