Allow String keycode

This commit is contained in:
Isaac Murchie
2014-05-16 10:18:09 -07:00
parent b66732d937
commit fc595d1557

View File

@@ -13,7 +13,7 @@ import com.android.uiautomator.core.UiDevice;
/**
* This handler is used to PressKeyCode.
*
*
*/
public class PressKeyCode extends CommandHandler {
public Integer keyCode;
@@ -21,11 +21,11 @@ public class PressKeyCode extends CommandHandler {
/*
* @param command The {@link AndroidCommand} used for this handler.
*
*
* @return {@link AndroidCommandResult}
*
*
* @throws JSONException
*
*
* @see io.appium.android.bootstrap.CommandHandler#execute(io.appium.android.
* bootstrap.AndroidCommand)
*/
@@ -34,7 +34,14 @@ public class PressKeyCode extends CommandHandler {
throws JSONException {
try {
final Hashtable<String, Object> params = command.params();
keyCode = (Integer) params.get("keycode");
Object kc = params.get("keycode");
if (kc instanceof Integer) {
keyCode = (Integer) kc;
} else if (kc instanceof String) {
keyCode = Integer.parseInt((String) kc);
} else {
throw new IllegalArgumentException("Keycode of type " + kc.getClass() + "not supported.");
}
if (params.get("metastate") != JSONObject.NULL) {
metaState = (Integer) params.get("metastate");