Beispiel #1
0
  /** APT启动后初始化操作 */
  private void initAPT() {
    // 打开控制台
    APTConsoleFactory.getInstance().openConsole();
    // 初始化状态栏
    StatusBar.getInstance().init();
    APTState.getInstance().setInitState();

    // 获取当前APT插件运行的系统
    PCInfo.OSName = System.getProperty("os.name");

    if (!GetAdbPathUtil.getAdbPath()) {
      DeviceInfo.getInstance().state = PhoneState.STATE_NOT_ADB;
      // TODO 这里要测试是不是需要重新启动
      String info = "请安装ADT插件,并Eclipse Preferences中设置Android SDK Location后,重新启动APT";
      APTConsoleFactory.getInstance().APTPrint(info);
      MessageDialog.openWarning(
          PlatformUI.getWorkbench().getDisplay().getActiveShell(), "提示", info);
    } else {
      // apt
    }
    DDMSUtil.init();
    APTConsoleFactory.getInstance().APTPrint("initAPT complete");
  }
Beispiel #2
0
    public void run() {
      synchronized (this) {
        if (DeviceInfo.getInstance().state == PhoneState.STATE_NOT_ADB) {
          testAction.setEnabled(false);
          return;
        }
        APTConsoleFactory.getInstance().APTPrint("正在获取手机信息...");
        GetDeviceInfo.getDeviceInfo();

        PhoneState state = DeviceInfo.getInstance().state;
        // 应该不会触发下面的if分支
        if (state == PhoneState.STATE_NOT_ADB) {
          APTConsoleFactory.getInstance().APTPrint("确保android sdk路径中不要存在空格");
          testAction.setEnabled(false);
          PlatformUI.getWorkbench()
              .getDisplay()
              .asyncExec(
                  new Runnable() {
                    @Override
                    public void run() {
                      MessageDialog.openWarning(
                          PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                          "提示",
                          "确保android sdk路径中不要存在空格,然后重启APT");
                    }
                  });

        } else if (state == PhoneState.STATE_NOT_FOUND_PHONE) {
          APTConsoleFactory.getInstance().APTPrint("请连接手机");
        } else if (state == PhoneState.STATE_MULTI_FOUND_PHONE) {
          APTConsoleFactory.getInstance().APTPrint("确保当前连接一个手机");
        } else {
          APTConsoleFactory.getInstance().APTPrint("获取手机信息成功");
          if (!sourcePkgTableViewer.getTable().getDisplay().isDisposed()) {
            sourcePkgTableViewer
                .getTable()
                .getDisplay()
                .asyncExec(
                    new Runnable() {

                      @Override
                      public void run() {
                        // 更新手机上的进程列表信息
                        sourcePkgTableViewer.setInput(DeviceInfo.getInstance().pkgList.toArray());

                        // 更新被测进程列表对应pkg的PID信息
                        int pkgNumber = targetPkgTableViewer.getTable().getItemCount();
                        List<PkgInfo> curPkgInfos = DeviceInfo.getInstance().pkgList;

                        // 更新被测进程列表中对应进程的PID信息
                        for (int i = 0; i < pkgNumber; i++) {
                          String pkgName = targetPkgTableViewer.getTable().getItem(i).getText(0);
                          String pid = getPidByPkgName(pkgName, curPkgInfos);
                          targetPkgTableViewer.getTable().getItem(i).setText(1, pid);
                        }
                      }
                    });
          }
        }
      }
    }