Example #1
0
 public void retryResult(String sResponseCode, String sResponseDesc) {
   L.event(
       "In retryResult()... sResponseCode ==> "
           + sResponseCode
           + ", sResponseDesc ==> "
           + sResponseDesc);
   Constants.IS_FAILED_UPLOAD_RUNNING = false;
 }
Example #2
0
 @Override
 protected void onPostExecute(Message msg) {
   String sResponseCode = msg.getData().getString(StringUtils.CODE);
   String sResponseDesc = msg.getData().getString(StringUtils.DESC);
   L.debug("onPostExecute()... " + sResponseDesc);
   DeviceUtil.updateTestScreen();
   NotificationUtil.showFailedNotification(activity, sResponseDesc, true);
   retryResult(sResponseCode, sResponseDesc);
 }
Example #3
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);
  }
Example #4
0
    @Override
    protected Message doInBackground(String... files) {
      Message msg = new Message();

      String sResponseCode = "", sResponseDesc = "";
      int iTotalToUpload, iSuccessUpload = 0, iFailedUpload = 0;
      int filesCount = arrLstDevInfoXMLFilesPath.size();
      iTotalToUpload = filesCount;
      for (int file_i = 0; file_i < filesCount; file_i++) {
        String sLogcatFilePath = arrLstLogcatFilesPath.get(file_i);
        String sDevInfoXMLFilePath = arrLstDevInfoXMLFilesPath.get(file_i);
        Message lc_msg = doUpload(sLogcatFilePath, sDevInfoXMLFilePath);
        sResponseCode = lc_msg.getData().getString(StringUtils.CODE);
        if (sResponseCode.equals(ResponseCodes.SUCCESS)) iSuccessUpload++;
        else iFailedUpload++;
      }
      if (iSuccessUpload == iTotalToUpload) {

        L.debug("@@@@@ Retry Upload Task @@@@");

        sResponseDesc = "All failed results has been uploaded";
        pref.putValue(Preferences.KEY_IS_TEST_CONFIG_SET, false);
        pref.putValue(Preferences.KEY_TEST_NAME, "");
        pref.putValue(Preferences.KEY_SELECTED_MARKET_PALCE, "");

        L.debug("Test config data cleared!!");
      } else {
        sResponseDesc =
            String.format(
                "Failed results upload completed. %d failed of %d results",
                iFailedUpload, iTotalToUpload);
        pref.putValue(Preferences.KEY_IS_TEST_CONFIG_SET, false);
        pref.putValue(Preferences.KEY_TEST_NAME, "");
        pref.putValue(Preferences.KEY_SELECTED_MARKET_PALCE, "");

        L.debug("Test config data cleared!!");
      }
      Bundle bndle = new Bundle();
      bndle.putString(StringUtils.CODE, sResponseCode);
      bndle.putString(StringUtils.DESC, sResponseDesc);
      msg.setData(bndle);
      return msg;
    }
Example #5
0
 void doUploadFailedResults(
     AppActivity activity,
     ArrayList<String> lstXMLFilePath,
     ArrayList<String> lstLogcatFilesPath) {
   L.event(" Uploading failed files ");
   NotificationUtil.showFailedNotification(activity, " Uploading failed files ", true);
   ResultUploadTask retryTask = new ResultUploadTask(activity, lstXMLFilePath, lstLogcatFilesPath);
   retryTask.execute();
   Constants.IS_FAILED_UPLOAD_RUNNING = true;
 }
Example #6
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 #7
0
 protected void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   Constants.CurrentActivity = this;
   event("onNewIntent()");
   try {
     Bundle bndle = intent.getExtras();
     L.printBundleValues(bndle);
   } catch (Exception e) {
     // TODO: handle exception
   }
   setIntent(intent);
 };
Example #8
0
 public ResultUploadTask(
     AppActivity activity,
     ArrayList<String> lstXMLFilePath,
     ArrayList<String> lstLogcatFilesPath) {
   this.activity = activity;
   arrLstDevInfoXMLFilesPath = lstXMLFilePath;
   arrLstLogcatFilesPath = lstLogcatFilesPath;
   L.event(
       "RetryUploadTask()... \n DevInfoXMLFilesPath ==> "
           + arrLstDevInfoXMLFilesPath
           + "\n LogcatFilesPath ==> "
           + arrLstLogcatFilesPath);
 }
Example #9
0
        @Override
        public void handleMessage(Message msg) {

          // ###################
          String sResponseCode = msg.getData().getString(StringUtils.CODE);
          String sResponseDesc = msg.getData().getString(StringUtils.DESC);

          clearFTPFiles();

          if (sResponseCode.equals(ResponseCodes.SUCCESS)) {
            L.debug("File download and upload success");
          } else {
            L.debug(sResponseDesc);

            if (!pref.isTestCanceled() && pref.isTestRunning()) {
              L.debug("RunnableFailed...");
              pref.setFTPTestRunningState(false);

              /*
               * NotificationUtil.showFinishedNotification( context,
               * StringUtils.TEST_TYPE_CODE_FTP, testconfig.getTestName()
               * + "_" + testconfig.getTestCycle(),
               * Messages.FTP_DOWNLOAD_FAILED);
               */

              NotificationUtil.showFinishedNotification(
                  context,
                  StringUtils.TEST_TYPE_CODE_FTP,
                  pref.getValue(Preferences.KEY_TEST_NAME, "") + "_" + testconfig.getTestCycle(),
                  Messages.FTP_DOWNLOAD_FAILED);

              DeviceUtil.updateTestScreen();
              doResultUploaded(sResponseCode, sResponseDesc);
            }
          }
        }
Example #10
0
    public void run() {
      if (pref.isFTPTestRunning()) {

        if (Constants.OS_VERSION_JELLY_BEAN_MR2 <= deviceOSVersion) {
          CurrRXBytes = TrafficStats.getUidRxBytes(uid);

          CurrRXSegments = TrafficStats.getUidTcpRxSegments(uid);
        } else {
          CurrRXBytes = TrafficStats.getUidTcpRxBytes(uid);
          CurrRXSegments = TrafficStats.getUidTcpRxSegments(uid);
        }

        long CurrAllRXPackets = TrafficStats.getUidRxPackets(uid);
        long CurrTotalRXPackets = TrafficStats.getTotalRxPackets();
        long CurrMobileRXPackets = TrafficStats.getMobileRxPackets();

        context.debug(
            "StartRXBytes bytes - "
                + StartRXBytes
                + ", CurrRXBytes - "
                + CurrRXBytes
                + ", CurrRXSegments - "
                + CurrRXSegments);
        /*System.out.println("by Ank StartRXBytes bytes - " + StartRXBytes
        + ", CurrRXBytes - " + CurrRXBytes
        + ", CurrRXSegments - " + CurrRXSegments);*/

        long RXBytes = CurrRXBytes - StartRXBytes;
        long RXSegments = CurrRXSegments - StartRXSegments;

        context.debug("Start :" + StartAllRXPackets + "RXPackets :" + CurrAllRXPackets);

        long AllRXPackets = CurrAllRXPackets - StartAllRXPackets;

        context.debug("AllRXPackets :" + AllRXPackets);

        long TotalRXPackets = CurrTotalRXPackets - StartTotalRXPackets;
        long MobileRXPackets = CurrMobileRXPackets - StartMobileRXPackets;

        L.log_ftp_rx(
            settings.getFTPLogcatPath(),
            RXBytes,
            RXSegments,
            AllRXPackets,
            TotalRXPackets,
            MobileRXPackets);
      } else timer.cancel();
    }
Example #11
0
    public void run() {
      if (pref.isFTPTestRunning()) {

        if (Constants.OS_VERSION_JELLY_BEAN_MR2 <= deviceOSVersion) {
          CurrTXBytes = DeviceUtil.getStats(uid).getSendCount();
          CurrTXSegments = TrafficStats.getUidTcpTxSegments(uid);
        } else {
          CurrTXBytes = TrafficStats.getUidTcpTxBytes(uid);
          CurrTXSegments = TrafficStats.getUidTcpTxSegments(uid);
        }

        context.debug(
            "StartTXBytes bytes - "
                + StartTXBytes
                + ", CurrTXBytes - "
                + CurrTXBytes
                + ", CurrTXSegments - "
                + CurrTXSegments);

        long CurrAllTXPackets = TrafficStats.getUidTxPackets(uid);
        long CurrTotalTXPackets = TrafficStats.getTotalTxPackets();
        long CurrMobileTXPackets = TrafficStats.getMobileTxPackets();
        long TXBytes = CurrTXBytes - StartTXBytes;
        long TXSegments = CurrTXSegments - StartTXSegments;
        long AllTXPackets = CurrAllTXPackets - StartAllTXPackets;
        long TotalTXPackets = CurrTotalTXPackets - StartTotalTXPackets;
        long MobileTXPackets = CurrMobileTXPackets - StartMobileTXPackets;

        L.log_ftp_tx(
            settings.getFTPLogcatPath(),
            TXBytes,
            TXSegments,
            AllTXPackets,
            TotalTXPackets,
            MobileTXPackets);
      } else {
        timer.cancel();
        try {
          if (ftp != null && ftp.getClient() != null) ftp.getClient().abort();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
Example #12
0
        @Override
        public void handleMessage(Message msg) {
          if (!pref.isTestCanceled() && pref.isTestRunning()) {
            L.debug("DownloadAndUploadCompletedHandler...");
            pref.setFTPTestRunningState(false);

            // testconfig.getTestName()

            new ResultUploader(
                context,
                pref.getValue(Preferences.KEY_TEST_NAME, "")
                    + StringUtils.TEST_CYCLE_APPEND_FILE
                    + testconfig.getTestCycle(),
                StringUtils.TEST_TYPE_CODE_FTP,
                settings.getFTPDeviceInfoPath(),
                settings.getFTPLogcatPath()) {
              public void resultUploaded(String code, String desc) {
                doResultUploaded(code, desc);
              };
            };
          }
        }
Example #13
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);
  }
Example #14
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);
  }
Example #15
0
  private void initLayouts() {
    L.log("Initialize Layouts...");

    rbTestTypeGroup = (RadioGroup) findViewById(R.id.rbTestTypeGroup);
    rbDownloadConfigurationTest = (RadioButton) findViewById(R.id.rbDownloadConfigurationTest);
    rbManualConfigurationTest = (RadioButton) findViewById(R.id.rbManualConfigurationTest);
    rbExternalTest = (RadioButton) findViewById(R.id.rbExternalTest);

    rbDownloadConfigurationTest.setChecked(false);
    rbManualConfigurationTest.setChecked(false);
    rbExternalTest.setChecked(false);

    String sLevel = pref.getUserLevel();
    debug("Logged in user -> + " + pref.getUsername() + "; Level -> " + sLevel);
    if (sLevel.equalsIgnoreCase(StringUtils.USER_LEVEL_TECHNICIAN)) {
      rbManualConfigurationTest.setEnabled(false);
      rbManualConfigurationTest.setTextColor(color.gray_light);
    }

    ((TextView) findViewById(R.id.txt_settings))
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                Intent i = new Intent(TestTypeActivity.this, SettingsActivity.class);
                startActivityForResult(i, 1);
              }
            });

    // rbTestTypeGroup.setSelected(false);

    rbTestTypeGroup.setOnCheckedChangeListener(chkListener);

    isAnyOfTestRunning = false;
    if (pref.isTestRunning()) isAnyOfTestRunning = true;
    btnStopTest = (Button) findViewById(R.id.btnStopTest);
    btnStopTest.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            stopTest();
          }
        });
    btnUploadFailedResults = (Button) findViewById(R.id.btnUploadFailedResults);
    btnUploadFailedResults.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            doUploadFailedResults();
          }
        });
    if (isAnyOfTestRunning) {
      boolean ext_tst_runng = pref.isExternalTestRunning();

      if (ext_tst_runng) btnStopTest.setVisibility(View.GONE);
      else btnStopTest.setVisibility(View.VISIBLE);
    } else {
      btnStopTest.setVisibility(View.GONE);

      /*new Timer().schedule(new TimerTask() {
      	@Override
      	public void run() {

      		activity.runOnUiThread(new Runnable() {
      	        @Override
      	        public void run() {
      	        	btnStopTest.setVisibility(View.GONE);
      	        }
      	});
      	}
      }, 5000);*/
    }
  }
Example #16
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);
    }
  }