Exemple #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    INSTANCE = this;
    // 已启动
    if (GTApp.getGTRunStatus()) {
      if (!GTMainActivity.isActived) {
        Intent intent = new Intent(SplashActivity.this, GTMainActivity.class);
        startActivity(intent);
      }
      finish();
    }
    // 启动
    else {
      GTApp.setGTRunStatus(true);

      // 协议对话框,同意一次之后不再弹出
      if (sIsFirstTimeEnter) {

        // 显示闪屏
        setContentView(R.layout.gt_splash);

        // 开启入口service 开启远程服务service
        GTEntrance.GTopen(getApplicationContext());

        // 已同意过法律条款
        if (Eula.isAccepted()) {
          // 加载完跳到MainActivity
          new Handler()
              .postDelayed(
                  new Runnable() {
                    public void run() {
                      Intent intent = new Intent(SplashActivity.this, GTMainActivity.class);
                      startActivity(intent);
                      SplashActivity.this.finish();
                    }
                  },
                  2000);
        } else {
          // 异步从网络上准备协议条款
          eulaTask = new EULATask();
          eulaTask.execute();
        }
        sIsFirstTimeEnter = false;
      } else {
        Intent intent = new Intent(this, GTMainActivity.class);
        startActivity(intent);
        this.finish();
      }
    }
  }
Exemple #2
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.upload_btn:
       if ((null != WtloginUtil.getUin()) && (isNewProj == false)) {
         String sk = WtloginUtil.getSKey(WtloginUtil.getUin());
         String psk = WtloginUtil.getPsKey(WtloginUtil.getUin());
         String lsk = WtloginUtil.getLsKey(WtloginUtil.getUin());
         dataPersisted();
         showUploadDialog(sk, psk, lsk);
       } else if (isNewProj == true) {
         String sk = WtloginUtil.getSKey(WtloginUtil.getUin());
         String psk = WtloginUtil.getPsKey(WtloginUtil.getUin());
         String lsk = WtloginUtil.getLsKey(WtloginUtil.getUin());
         File file = new File(strNewProjName);
         comfirmUpdateSize(file, sk, psk, lsk);
       } else {
         ToastUtil.ShowLongToast(GTApp.getContext(), R.string.qq_need_login);
       }
       break;
     case R.id.back_gt:
       finish();
       break;
   }
 }
Exemple #3
0
  private void judgeToast() {
    if (upperValue <= lowerValue && !isToasted) {
      isToasted = true;
      ToastUtil.ShowLongToast(GTApp.getContext(), "lower value must less than upper value!");
      return;
    } else if (upperValue <= lowerValue && isToasted) {
      return;
    }

    isToasted = false;
  }
Exemple #4
0
  /* 进行验证码验证,或者进行快速登录的回调,这两个是进行快速登录可能遇到的情况 */
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    String userAccount = "";
    ErrMsg errMsg = null;
    WUserSigInfo userSigInfo = null;
    switch (requestCode) {
      case WtloginUtil.REQ_VCODE:
        {
          if (data == null) break;
          Bundle bundle = data.getExtras();
          if (bundle == null) break;
          userAccount = bundle.getString("ACCOUNT");
          errMsg = (ErrMsg) bundle.getParcelable("ERRMSG");
          userSigInfo = (WUserSigInfo) bundle.getParcelable("USERSIG");

          if (resultCode == util.S_SUCCESS) {
            // 转菊花,等待产品列表获取结果
            showProDialog(
                getString(R.string.pi_octopus_pull_products),
                getString(R.string.pi_octopus_pull_products_content));
            loginSuccess(userAccount);
          } else if (resultCode == util.S_LH_EXPIRED || resultCode == util.S_BABYLH_EXPIRED) {
            Ticket ticket = WtloginHelper.GetUserSigInfoTicket(userSigInfo, SigType.WLOGIN_LHSIG);
            finish();
            ToastUtil.ShowLongToast(
                GTApp.getContext(),
                "lhsig=" + util.buf_to_string(ticket._sig) + " errMsg=" + errMsg);
          } else {
            finish();
            ToastUtil.ShowLongToast(GTApp.getContext(), "errMsg=" + errMsg);
          }
        }
        break;
      case WtloginUtil.REQ_QLOGIN: // 快速登录返回
        try {
          if (data == null) { // 这种情况下用户多半是直接按了返回按钮,没有进行快速登录;快速登录失败可提醒用户输入密码登录
            break;
          }

          WUserSigInfo sigInfo = WtloginUtil.getSigInfo(data);
          if (sigInfo == null) {
            ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_login_user_quickerror);
            break;
          }

          WtloginUtil.setUin(sigInfo.uin);

          // 转菊花,等待产品列表获取结果
          showProDialog(
              getString(R.string.pi_octopus_pull_products),
              getString(R.string.pi_octopus_pull_products_content));

          // 快速登录只是从手Q换取了A1票据,A1则相当于用户密码,在此仍需要再发起一次A1换票的流程,才能拿到目标票据
          WtloginUtil.getStWithPasswd(sigInfo);
          // 换票据成功后会触发wtloginListener的监听
        } catch (Exception e) {
          util.printException(e);
        }
        break;
      default:
        break;
    }
  }
Exemple #5
0
  private void comfirmUpdateSize(
      final File folder, final String skey, final String pskey, final String lskey) {
    // 从folder解析出三级目录
    String[] paths = folder.getPath().split(FileUtil.separator);
    if (paths == null || paths.length <= 3) {
      // TODO 非预期目录有问题,无法处理的error
      return;
    }
    final String path1 = paths[paths.length - 3];
    final String path2 = paths[paths.length - 2];
    final String path3 = paths[paths.length - 1];

    Object oProductPair = spProductName.getSelectedItem();
    if (oProductPair == null) {
      ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_upload_not_select);
      return;
    }
    if (!(oProductPair instanceof Pair)) {
      ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_upload_not_select);
      return;
    }
    final Pair<String, String> productPair = (Pair) oProductPair;

    // 转菊花,等待产品列表获取结果
    showProDialog(
        getString(R.string.pi_octopus_calc_size), getString(R.string.pi_octopus_calc_size_content));

    new Thread(
            new Runnable() {

              @Override
              public void run() {
                long size = 0;
                File[] csvFiles = folder.listFiles(FileUtil.CSV_FILTER);
                // 网络操作需要在独立线程完成
                PreUploadEntry preUploadEntry =
                    HttpAssist.preUpload(
                        csvFiles,
                        productPair.first,
                        path1,
                        path2,
                        path3,
                        WtloginUtil.getUin(),
                        skey,
                        pskey,
                        lskey);
                if (preUploadEntry == null) {
                  ToastUtil.ShowLongToast(GTApp.getContext(), ErrorMsg.NET_ERROR);
                  return;
                }

                final List<String> chosedFilePathList = new ArrayList<String>();
                for (File f : preUploadEntry.choicedCsvFileList) {
                  size += f.length();
                  chosedFilePathList.add(f.getPath());
                }
                final long sizeKB = size / 1024 + 1;

                runOnUiThread(
                    new Runnable() {

                      @Override
                      public void run() {
                        dismissProDialog();

                        AlertDialog.Builder builder = new Builder(GTOctopusActivity.this);
                        builder.setMessage(
                            getString(R.string.pi_octopus_upload_confirm_content) + sizeKB + "KB");
                        builder.setTitle(getString(R.string.pi_octopus_upload_confirm_title));
                        builder.setPositiveButton(
                            getString(R.string.cancel),
                            new DialogInterface.OnClickListener() {

                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                              }
                            });
                        builder.setNegativeButton(
                            getString(R.string.ok),
                            new DialogInterface.OnClickListener() {

                              @Override
                              public void onClick(DialogInterface dialog, int which) {

                                dialog.dismiss();
                                Object oProductPair = spProductName.getSelectedItem();
                                if (oProductPair == null) {
                                  ToastUtil.ShowLongToast(
                                      GTApp.getContext(), R.string.pi_octopus_upload_not_select);
                                  return;
                                }
                                if (!(oProductPair instanceof Pair)) {
                                  ToastUtil.ShowLongToast(
                                      GTApp.getContext(), R.string.pi_octopus_upload_not_select);
                                  return;
                                }
                                Pair<String, String> productPair = (Pair) oProductPair;

                                // 从folder解析出三级目录
                                String[] paths = folder.getPath().split(FileUtil.separator);
                                if (paths == null || paths.length <= 3) {
                                  // TODO 报个error
                                  return;
                                }
                                // 分析文件,准备上传,用Service处理
                                Intent intent = new Intent();
                                intent.putExtra(SRC, folder.getPath());
                                intent.putExtra(
                                    FILE_ARRAY, chosedFilePathList.toArray(new String[] {}));

                                intent.putExtra(PRODUCT_ID, productPair.first);
                                intent.putExtra(PRODUCT_NAME, productPair.second);
                                intent.putExtra(PATH1, paths[paths.length - 3]);
                                intent.putExtra(PATH2, paths[paths.length - 2]);
                                intent.putExtra(PATH3, paths[paths.length - 1]);
                                intent.putExtra(UIN, WtloginUtil.getUin());
                                intent.putExtra(S_KEY, skey);
                                intent.putExtra(P_S_KEY, pskey);
                                intent.putExtra(LS_KEY, lskey);

                                PluginManager.getInstance()
                                    .getPluginControler()
                                    .startService(GTOctopusEngine.getInstance(), intent);
                              }
                            });
                        builder.setCancelable(false);
                        builder.show();
                      }
                    });
              }
            },
            "choicedCsvFilesThread")
        .start();
  }
  @Override
  public void onReceive(Context context, Intent intent) {
    try {
      String action = intent.getAction();
      if (null == action) {
        return;
      }
      if (action.equals(ACTION_START_TEST)) {
        pkgName = intent.getStringExtra(INTENT_KEY_PNAME);
        verName = intent.getStringExtra(INTENT_KEY_PVERNAME);
        pid = intent.getIntExtra(INTENT_KEY_PID, -1);
        GTAutoTestInternal.startProcTest(pkgName, verName, pid);
      } else if (action.equals(ACTION_SAMPLE)) {

        // PSS的命令字
        int startMem = intent.getIntExtra(GTAutoTestInternal.INTENT_KEY_PSS, -1);
        if (startMem != -1 && pkgName != null) {
          if (startMem == 1) {
            GTAutoTestInternal.startSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_PSS);
          } else if (startMem == 0) {
            GTAutoTestInternal.stopSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_PSS);
          }
        }

        // PRI的命令字
        int startPri = intent.getIntExtra(GTAutoTestInternal.INTENT_KEY_PRI, -1);
        if (startPri != -1 && pkgName != null) {
          if (startPri == 1) {
            GTAutoTestInternal.startSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_PRI);
          } else if (startPri == 0) {
            GTAutoTestInternal.stopSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_PRI);
          }
        }

        // CPU命令字
        int startCpu = intent.getIntExtra(GTAutoTestInternal.INTENT_KEY_CPU, -1);
        if (startCpu != -1 && pkgName != null) {
          if (startCpu == 1) {
            GTAutoTestInternal.startSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_CPU);
          } else if (startCpu == 0) {
            GTAutoTestInternal.stopSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_CPU);
          }
        }

        // jiffies命令字
        int startJif = intent.getIntExtra(GTAutoTestInternal.INTENT_KEY_JIF, -1);
        if (startJif != -1 && pkgName != null) {
          if (startJif == 1) {
            GTAutoTestInternal.startSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_JIF);
          } else if (startJif == 0) {
            GTAutoTestInternal.stopSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_JIF);
          }
        }

        // NET命令字
        int startNet = intent.getIntExtra(GTAutoTestInternal.INTENT_KEY_NET, -1);
        if (startNet != -1 && pkgName != null) {
          if (startNet == 1) {
            GTAutoTestInternal.startSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_NET);
          } else if (startNet == 0) {
            GTAutoTestInternal.stopSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_NET);
          }
        }

        // 4.x以上的FPS
        int startFps = intent.getIntExtra(GTAutoTestInternal.INTENT_KEY_FPS, -1);
        if (startFps != -1) {
          if (startFps == 1) {
            GTAutoTestInternal.startSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_FPS);
          } else if (startFps == 0) {
            GTAutoTestInternal.stopSample(pkgName, pid, GTAutoTestInternal.INTENT_KEY_FPS);
          }
        }

        // 通知AUT页和出参页同步状态
        GTApp.getAUTHandler().sendEmptyMessage(0);
        GTApp.getOpHandler().sendEmptyMessage(5);
        GTApp.getOpEditHandler().sendEmptyMessage(0);
      } else if (action.equals(ACTION_END_TEST)) {
        String folderName = intent.getStringExtra(INTENT_KEY_SAVE_FOLDER);
        String desc = intent.getStringExtra(INTENT_KEY_SAVE_DESC);
        // 当folderName==null时,会保存到上一次保存的目录,如果没有上一次的目录,会保存到默认目录GW_DATA下
        GTAutoTestInternal.endGlobalTest(folderName, desc, true);
      } else if (action.equals(ACTION_EXIT_GT)) {
        /*
         * 修复金刚系统检查出的漏洞:
         * 在应用首次启动时动态加载功能代码等情况,可能会出现未完全加载类或某些前置环境未满足,
         * 即接收到以上消息来启动它,导致classNotFoundException等异常,使得应用崩溃
         */
        try {
          GTAutoTestInternal.exitGT();
        } catch (Exception e) {

        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }