Fix touch actions below API 18

This commit is contained in:
Isaac Murchie
2014-05-14 13:13:31 -07:00
parent 1cae9c593c
commit 5ae62f983e
2 changed files with 23 additions and 7 deletions

View File

@@ -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) {

View File

@@ -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;
}