Example #1
0
  public void TouchDrag(int x, int y) {
    for (TouchEventValue eventValues : touchDownValues) {
      if (0x0003 /*EV_ABS*/ == eventValues.type && 0x0035 /*ABS_MT_POSITION_X*/ == eventValues.id) {
        eventValues.value = x;
        String cmd =
            String.format(
                "sendevent %s %d %d %d",
                touch_device_name, eventValues.type, eventValues.id, eventValues.value);
        adb_shell.command(cmd, null);
      } else if (0x0003 /*EV_ABS*/ == eventValues.type
          && 0x0036 /*ABS_MT_POSITION_Y*/ == eventValues.id) {
        eventValues.value = y;
        String cmd =
            String.format(
                "sendevent %s %d %d %d",
                touch_device_name, eventValues.type, eventValues.id, eventValues.value);
        adb_shell.command(cmd, null);
      } else if (0x0000 /*EV_SYN*/ == eventValues.type && 0x0000 /*SYN_REPORT*/ == eventValues.id) {
        String cmd =
            String.format(
                "sendevent %s %d %d %d",
                touch_device_name, eventValues.type, eventValues.id, eventValues.value);
        adb_shell.command(cmd, null);

      } else {
        continue;
      }
    }
  }
Example #2
0
  /** 기존 연결된 ADB을 종료하고, 새로운 ADB을 연결한다. */
  public void reconnection() {
    release();

    for (Process adb : G.AdbProcess) {
      adb.destroy();
    }
    G.AdbProcess.clear();

    if (!bLoadTouchValue) {
      Log.d("not loaded touch event values!");
      return;
    }
    if (touch_device_name == null) {
      Log.d("touch device name is null");
      return;
    }

    if (adb_shell == null) {
      adb_shell = new AdbShell();
      if (!adb_shell.connect(deviceInfo)) {
        Log.i("ERROR: failed 'adb shell -s %s'", deviceInfo.serialNumber);
        return;
      }
    }
  }
Example #3
0
  public void release() {
    if (adb_shell != null) {
      adb_shell.close();

      adb_shell = null;
    }
  }
Example #4
0
  /**
   * @param x
   * @param y
   * @return
   */
  public boolean TouchDown(int x, int y) {
    if (!bLoadTouchValue) {
      Log.d("not loaded touch event values!");
      return false;
    }
    if (touch_device_name == null) {
      Log.d("touch device name is null");
      return false;
    }

    if (adb_shell == null) {
      adb_shell = new AdbShell();
      if (!adb_shell.connect(deviceInfo)) {
        Log.i("ERROR: failed 'adb shell -s %s'", deviceInfo.serialNumber);
        return false;
      }
    }

    for (TouchEventValue eventValues : touchDownValues) {
      if (0x0001 /*EV_ABS*/ == eventValues.type && 0x0110 /*ABS_MT_POSITION_Y*/ == eventValues.id) {
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0000, x * 70),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0001, y * 107),
            null);

      } else if (0x0001 /*EV_SYN*/ == eventValues.type && 0x014a /*SYN_REPORT*/ == eventValues.id) {
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0001, 0x014a, 0x00000001),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x003a, 0x00000001),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0035, x), null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0036, y), null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0000, 0x0002, 0x00000000),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0000, 0x0000, 0x00000000),
            null);
        // break;

      } else if (0x0003 /*EV_SYN*/ == eventValues.type
          && 0x0039 /*SYN_REPORT*/ == eventValues.id) { // 겔럭시 팝		

        adb_shell.command(
            String.format(
                "sendevent %s %d %d %d",
                touch_device_name, eventValues.type, eventValues.id, eventValues.value),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0032, 0x0000000d),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0035, x), null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0036, y), null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0030, 0x0000000e),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x0031, 0x0000000b),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0003, 0x003c, 0x0000000a),
            null);
        adb_shell.command(
            String.format("sendevent %s %d %d %d", touch_device_name, 0x0000, 0x0000, 0x00000000),
            null);
        break;

      } else {
        eventValues.value = y;
      }
      String cmd =
          String.format(
              "sendevent %s %d %d %d",
              touch_device_name, eventValues.type, eventValues.id, eventValues.value);
      // Log.i( "adb shell command : %s", cmd );
      adb_shell.command(cmd, null);
    }

    // isTouchDown = true;

    return true;
  }
Example #5
0
  /**
   * 단말기에 대한 Touch Event Test 정보를 수집하고 저장합니다.<br>
   * 본 함수는 touchScreenTest 함수를 호출값이 false 일때 호출해 주면 된다.
   *
   * @param _frame
   */
  public void touchScreenTestRun(JFrame _frame) {
    final AdbShell _shell = new AdbShell();
    final JFrame frame = _frame;

    if (_shell.connect(deviceInfo)) {

      bLoadTouchValue = false;
      _shell.command(
          "getevent",
          new AdbShellCallback() {

            ArrayList<TouchEventValue> touchValues = null;

            public void callback(AdbShell shell, String line) {
              if (!line.startsWith(touch_device_name)) return;
              while (line.contains("  ")) {
                line = line.replace("  ", " ");
              }

              String[] tokens = line.split(" ");
              TouchEventValue newEventValue = new TouchEventValue();

              newEventValue.type = Integer.valueOf(tokens[1], 16);
              newEventValue.id = Integer.valueOf(tokens[2], 16);
              try {
                newEventValue.value =
                    tokens[3].startsWith("f") ? -1 : Integer.valueOf(tokens[3], 16);
              } catch (Exception e) {
                newEventValue.value = -1;
              }

              Log.d("=> %04x %04x %08x", newEventValue.type, newEventValue.id, newEventValue.value);

              if (newEventValue.type == 0x0003) { // touch up
                if (newEventValue.id == 0x0039) {
                  if (newEventValue.value == -1) {
                    touchValues = touchUpValues;
                  } else {
                    touchValues = touchDownValues;
                  }
                  touchValues.add(newEventValue);
                  return;

                } else {
                  return;
                }
              } else if (newEventValue.type == 0x0001) {
                if (newEventValue.id == 0x0110) {
                  if (newEventValue.value == 1) {
                    touchValues = touchDownValues;
                  } else {
                    touchValues = touchUpValues;
                  }
                } else if (newEventValue.id == 0x014a) {
                  if (newEventValue.value == 1) {
                    touchValues = touchDownValues;
                  } else {
                    touchValues = touchUpValues;
                  }
                } else {
                  return;
                }
              }

              if (touchValues == null) {
                return;
              }

              boolean found = false;
              for (TouchEventValue eventValue : touchValues) {
                if (eventValue.type == newEventValue.type && eventValue.id == newEventValue.id) {
                  eventValue.value = newEventValue.value;
                  found = true;
                }
              }

              if (found) {
                return;
              }

              if (newEventValue.type == 0x0000
                  && newEventValue.id == 0x0000
                  && newEventValue.value == 0) { // report
                if (touchValues == touchUpValues) {
                  Log.d("TouchEvent END");

                  shell.close();

                  JOptionPane.showMessageDialog(
                      frame,
                      "단말기의 터치값 추출이 완료 되었습니다.",
                      "TouchTest",
                      JOptionPane.INFORMATION_MESSAGE);

                  saveTouchValue();
                  print_touch_values();

                  bLoadTouchValue = true;
                }
              } else {
                touchValues.add(newEventValue);
              }
            }
          });
    }
  }