Beispiel #1
0
 public static void updateTestScreen() {
   AppActivity curr_activity = Constants.CurrentActivity;
   L.debug("Current Activity is " + curr_activity.getClass().getName());
   if (curr_activity != null && curr_activity instanceof TestTypeActivity) {
     L.debug("Current Activity is instance of TestTypeActivity");
     TestTypeActivity testTypeActivity = (TestTypeActivity) curr_activity;
     testTypeActivity.checkBundleValues();
   }
 }
Beispiel #2
0
  void startTesting() {
    no_of_cycles = Long.parseLong(FTPTestConfigObj.sTestCyles);

    DeviceUtil.clearLogcat();

    // context.print("FTPTestConfigObj -> " + FTPTestConfigObj.toString());
    sHostURL = FTPTestConfigObj.sServerURL;
    sUsername = FTPTestConfigObj.sUsername;
    sPassword = FTPTestConfigObj.sPassword;
    sDownloadSrcFilePath = FTPTestConfigObj.sFileToDownload;
    sUploadSrcFilePath = FTPTestConfigObj.sManuallUploadFile;

    bManuallUploadStatus = FTPTestConfigObj.bManuallUploadStatus;

    sDownloadDestFilePath =
        FileUtil.APP_TMP_DIR + "/" + new File(FTPTestConfigObj.sFileToDownload).getName();

    context.print(
        "sDownloadSrcFilePath - "
            + sDownloadSrcFilePath
            + ", sDownloadDestFilePath - "
            + sDownloadDestFilePath);

    if (bManuallUploadStatus) {
      sUploadSrcFilePath = FTPTestConfigObj.sManuallUploadFile;
      L.debug("FTP TEST RUNNER: Manuall Upload File Path: " + sUploadSrcFilePath);
    } else {
      sUploadSrcFilePath = sDownloadDestFilePath;

      L.debug("FTP TEST RUNNER: Upload File Path: " + sUploadSrcFilePath);
    }

    sUploadDestDirPath = FTPTestConfigObj.sUploadPath;

    for (int cyc_i = 0; cyc_i < no_of_cycles; cyc_i++) {
      context.print("startTesting()... cyc_i  -> " + cyc_i);
      L.debug("*********** FTP TEST STARTED ***********");
      L.debug("FTP Cycle's count: " + cyc_i);
      doDownloadAndUpload();
    }

    // doDownloadAndUpload();
    DownloadAndUploadCompletedHandler.sendEmptyMessage(0);
  }
Beispiel #3
0
  public void startTest() {

    deviceOSVersion = android.os.Build.VERSION.SDK_INT;
    L.debug("DEVICE OS VERSION: " + deviceOSVersion);

    FTPTestConfigObj = testconfig.getFTPTestConfig();

    /*
     *
     * String sTestName = testconfig.getTestName() +
     * StringUtils.TEST_CYCLE_APPEND_FILE + testconfig.getTestCycle();
     */

    String sTestName =
        pref.getValue(Preferences.KEY_TEST_NAME, "")
            + StringUtils.TEST_CYCLE_APPEND_FILE
            + testconfig.getTestCycle();

    pref.setFTPTestRunningState(true);

    DeviceUtil dv = new DeviceUtil(context);

    String sDeviceInfoXML =
        dv.getDeviceInfo(
            StringUtils.FILE_CODE_TEST_TYPE_FTP,
            sTestName,
            pref.getUsername(),
            pref.getValue(Preferences.KEY_SELECTED_MARKET_PLACE_ID, ""));
    L.debug(sDeviceInfoXML);

    String sCurrTime = TimeUtil.getCurrentTimeFilename();

    FileUtil.CURRENT_FTP_TESTTIME = sCurrTime;
    String path = FileUtil.FTP_LOG_DIR + "deviceinfo" + "_" + sTestName + "_" + sCurrTime + ".xml";
    File fle = new File(path);
    if (fle.exists()) {
      fle.delete();
    }
    String dev_info_path = FileUtil.writeToXMLFile(path, sDeviceInfoXML);
    L.debug("Device info initial data written into " + dev_info_path);

    pref.putValue(Preferences.KEY_CURRENT_FTP_DEV_INFO_PATH, dev_info_path);

    String logcat_path =
        FileUtil.FTP_LOG_DIR
            + StringUtils.FILE_CODE_TEST_TYPE_FTP
            + "_"
            + dv.getIMEI()
            + "_"
            + sTestName
            + "_"
            + sCurrTime
            + ".txt";

    L.debug("!!! logcat_path !!!!: " + logcat_path);

    File log_fle = new File(logcat_path);

    try {
      log_fle.createNewFile();
    } catch (IOException e) {
    }
    pref.putValue(Preferences.KEY_CURRENT_FTP_LOGCAT_PATH, log_fle.getAbsolutePath());
    try {
      Airometric app = (Airometric) context.getApplication();
      app.startListeners(dev_info_path);
    } catch (Exception e) {
      e.printStackTrace();
    }
    NotificationUtil.cancelNotification(context, StringUtils.TEST_TYPE_CODE_FTP);

    uploadTask = new StartTestTask();
    uploadTask.execute();
    Constants.CurrentTask = uploadTask;

    NotificationUtil.showRunningNotification(context, StringUtils.TEST_TYPE_CODE_FTP);
    context.showActivity(TestTypeActivity.class);
  }
Beispiel #4
0
  protected void doDownloadAndUpload() {
    context.print("doDownloadAndUpload()...");
    Message msg = new Message();
    Bundle bndle = new Bundle();

    String sResponseCode = "", sResponseDesc = "";
    try {

      ftp = new FTP(handler);
      if (ftp.ftpConnect(sHostURL, sUsername, sPassword, port)) {

        timer = new Timer();
        uid = android.os.Process.myUid();
        if (Constants.OS_VERSION_JELLY_BEAN_MR2 <= deviceOSVersion) {
          StartRXBytes = DeviceUtil.getStats(uid).getReceiveCount();
          // StartRXBytes = TrafficStats.getUidRxBytes(uid);
          StartRXSegments = TrafficStats.getUidTcpRxSegments(uid);
        } else {
          StartRXBytes = TrafficStats.getUidTcpRxBytes(uid);
          StartRXSegments = TrafficStats.getUidTcpRxSegments(uid);
        }
        context.debug(
            "Initial RX bytes - " + StartRXBytes + ", Initial RX Segments - " + StartRXSegments);
        downloadTimerTask = new DownloadTimeTask();
        timer.schedule(downloadTimerTask, 0, Constants.FTP_LOG_INTERVAL * 1000);

        // Download

        if (ftp.ftpDownload(sDownloadSrcFilePath, sDownloadDestFilePath)) {
          context.print("File downloaded");
          sResponseCode = ResponseCodes.SUCCESS;
          timer.cancel();

          try {

            timer = new Timer();
            /*
            Constants.OS_VERSION_JELLY_BEAN_MR2 == deviceOSVersion
            		|| Constants.OS_VERSION_KIT_KAT == deviceOSVersion || Constants.OS_VERSION_LOLLIPOP == deviceOSVersion
            		|| Constants.OS_VERSION_LOLLIPOP_MR2 == deviceOSVersion || Constants.OS_VERSION_MARSHMALLOW == deviceOSVersion*/

            if (Constants.OS_VERSION_JELLY_BEAN_MR2 <= deviceOSVersion) {
              StartTXBytes = TrafficStats.getUidTxBytes(uid);
              StartTXSegments = TrafficStats.getUidTcpTxSegments(uid);
            } else {
              StartTXBytes = TrafficStats.getUidTcpTxBytes(uid);
              StartTXSegments = TrafficStats.getUidTcpTxSegments(uid);
            }

            context.debug(
                "Initial TX bytes - "
                    + StartTXBytes
                    + ", Initial TX segments - "
                    + StartTXSegments);
            uploadTimerTask = new UploadTimeTask();
            timer.schedule(uploadTimerTask, 0, Constants.FTP_LOG_INTERVAL * 1000);

            L.debug("Upload Section- src file path: " + sUploadSrcFilePath);
            L.debug("Upload Section- dest file path: " + sUploadDestDirPath);

            // Upload

            if (ftp.ftpUpload(
                sUploadSrcFilePath, new File(sUploadSrcFilePath).getName(), sUploadDestDirPath)) {
              context.print("File uploaded");
              sResponseCode = ResponseCodes.SUCCESS;
              L.debug("********* FTP UPLOADING SUCCESS **********");
            } else {
              context.print("File upload failed - " + ftp.getServerError());
              sResponseCode = StringUtils.ERROR_CODE;
              sResponseDesc = Messages.FTP_UPLOAD_FAILED + "(" + ftp.getServerError() + ")";
            }
          } catch (Exception e) {
            e.printStackTrace();
            sResponseCode = StringUtils.ERROR_CODE;
            sResponseDesc = Messages.FTP_UPLOAD_FAILED + "(" + Messages.err(e) + ")";
          }

        } else {
          context.print("File download failed - " + ftp.getServerError());
          sResponseCode = StringUtils.ERROR_CODE;
          sResponseDesc = Messages.FTP_DOWNLOAD_FAILED;
        }
        timer.cancel();
      } else {
        sResponseCode = StringUtils.ERROR_CODE;
        sResponseDesc = Messages.FTP_LOGIN_FAILED;
      }
      try {
        if (ftp.getClient().isConnected()) ftp.ftpDisconnect();
      } catch (Exception e) {

      }
    } catch (Exception e) {
      e.printStackTrace();
      sResponseCode = StringUtils.ERROR_CODE;
      sResponseDesc = Messages.err(e);
    }

    bndle.putString(StringUtils.CODE, sResponseCode);
    bndle.putString(StringUtils.DESC, sResponseDesc);
    msg.setData(bndle);
    if (!pref.isTestCanceled() && pref.isTestRunning()) DownloadAndUploadHandler.sendMessage(msg);
  }