Example #1
0
    private Message doUpload(String sLogcatFilePath, String sDevInfoXMLFilePath) {

      Message msg = new Message();
      Bundle bndle = new Bundle();

      String sResponseCode = "", sResponseDesc = "";

      try {
        APIManager apiClient = new APIManager(activity);

        String sIMEI = new DeviceUtil(activity).getIMEI();
        Preferences pref = new Preferences(activity);
        String sUsername = pref.getUsername();
        String sPwd = pref.getPassword();
        APIManager.Status status = APIManager.Status.NONE;

        if (Validator.isEmpty(sLogcatFilePath)) {
          status = apiClient.processUploadSingle(sDevInfoXMLFilePath);
        } else {
          status =
              apiClient.processUpload(sUsername, sPwd, sIMEI, sLogcatFilePath, sDevInfoXMLFilePath);
        }

        if (status == APIManager.Status.ERROR) {
          sResponseCode = ResponseCodes.FAILURE;
          sResponseDesc = apiClient.getErrorMessage();
        } else {
          String sResponse = apiClient.getResponse();
          L.debug("Upload Response :: " + sResponse);
          if (sResponse != null
              && sResponse.trim().equalsIgnoreCase(ResponseCodes.SUCCESS_UPLOAD)) {
            sResponseCode = ResponseCodes.SUCCESS;
            sResponseDesc = "Result uploaded!";
          } else {
            sResponseCode = ResponseCodes.FAILURE;
            sResponseDesc = sResponse;
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
        sResponseCode = ResponseCodes.FAILURE;
        sResponseDesc = Messages.err(e);
      }
      if (Constants.DELETE_FILES_AFTER_UPLOAD)
        if (sResponseCode.equals(ResponseCodes.SUCCESS)) {
          // Delete log files
          FileUtil.delete(sDevInfoXMLFilePath);
          FileUtil.delete(sLogcatFilePath);
        }
      bndle.putString(StringUtils.CODE, sResponseCode);
      bndle.putString(StringUtils.DESC, sResponseDesc);
      msg.setData(bndle);
      return msg;
    }
Example #2
0
  public void checkBundleValues() {
    event("checkBundleValues()");

    Bundle bndle = this.getIntent().getExtras();
    if (bndle != null)
      if (bndle.containsKey(StringUtils.EXTRA_STATUS_MSG))
        msg = bndle.getString(StringUtils.EXTRA_STATUS_MSG);
    L.debug("MESSAGE in TEST TYPE ACTIVITITY: " + msg);

    if (!Validator.isEmpty(msg)) {
      new AppAlert(activity, msg) {

        @Override
        public void okClickListener() {
          L.debug("Message != empty");
          final Intent intent = new Intent(activity, TestTypeActivity.class);

          new Timer()
              .schedule(
                  new TimerTask() {
                    @Override
                    public void run() {
                      finish();
                      startActivity(intent);
                    }
                  },
                  20000);
        }
      };
    }
    if (pref.isTestRunning()) isAnyOfTestRunning = true;
    else isAnyOfTestRunning = false;

    btnStopTest.setVisibility(View.GONE);

    if (isAnyOfTestRunning) {
      boolean ext_tst_runng = pref.isExternalTestRunning();

      if (ext_tst_runng) {
        new Timer()
            .schedule(
                new TimerTask() {
                  @Override
                  public void run() {
                    // btnStopTest.setVisibility(View.GONE);
                    activity.runOnUiThread(
                        new Runnable() {
                          @Override
                          public void run() {
                            btnStopTest.setVisibility(View.GONE);
                          }
                        });
                  }
                },
                10000);
      } else btnStopTest.setVisibility(View.VISIBLE);
    } else {
      new Timer()
          .schedule(
              new TimerTask() {
                @Override
                public void run() {
                  // btnStopTest.setVisibility(View.GONE);
                  activity.runOnUiThread(
                      new Runnable() {
                        @Override
                        public void run() {
                          btnStopTest.setVisibility(View.GONE);
                        }
                      });
                }
              },
              10000);
    }
  }