Пример #1
0
 public String getTestUuid() {
   if (testTask != null) {
     return testTask.getTestUuid();
   } else {
     return ConfigHelper.getLastTestUuid(getApplicationContext(), true);
   }
 }
Пример #2
0
 @Override
 public void taskEnded() {
   unlock();
   removeNotification();
   handler.removeCallbacks(deadman);
   completed = true;
   sendBroadcast(new Intent(BROADCAST_TEST_FINISHED));
   stopSelf();
   if (testTask != null) {
     ConfigHelper.setLastTestUuid(getApplicationContext(), testTask.getTestUuid());
   }
   Log.i("RMBTService", "stopped!");
 }
Пример #3
0
  @Override
  public void onCreate() {
    Log.d(DEBUG_TAG, "created");
    super.onCreate();

    handler = new Handler();

    // initialise the locks
    loopMode = ConfigHelper.isLoopMode(this);

    // initialise the locks
    wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "RMBTWifiLock");
    wakeLock =
        ((PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RMBTWakeLock");

    // mNetworkStateIntentReceiver = new BroadcastReceiver() {
    // @Override
    // public void onReceive(Context context, Intent intent) {
    // if
    // (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION))
    // {
    //
    // final boolean connected = !
    // intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,
    // false);
    // if (! connected)
    // stopTest();
    // }
    // }
    // };
    // final IntentFilter networkStateChangedFilter = new IntentFilter();
    // networkStateChangedFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    //
    // registerReceiver(mNetworkStateIntentReceiver,
    // networkStateChangedFilter);
  }
Пример #4
0
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public View onCreateView(
      final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {

    super.onCreateView(inflater, container, savedInstanceState);

    final Bundle args = getArguments();

    String url = args.getString(ARG_URL);

    if (url == null || url.length() == 0) url = this.getString(R.string.url_help);

    final Activity activity = getActivity();

    final WebView webview =
        new WebView(activity) {
          @Override
          public boolean onKeyDown(final int keyCode, final KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && canGoBack()) {
              goBack();
              return true;
            }
            return super.onKeyDown(keyCode, event);
          }
        };

    final WebSettings webSettings = webview.getSettings();
    final String userAgent = AppConstants.getUserAgentString(getActivity());
    if (userAgent != null) {
      webSettings.setUserAgentString(userAgent);
    }
    webSettings.setJavaScriptEnabled(true);

    webview.setWebViewClient(
        new WebViewClient() {
          @Override
          public void onReceivedError(
              final WebView view,
              final int errorCode,
              final String description,
              final String failingUrl) {
            Log.w(getTag(), "error code:" + errorCode);
            Log.d(getTag(), "error desc:" + description);
            Log.d(getTag(), "error url:" + failingUrl);
            webview.loadUrl("file:///android_res/raw/error.html");
            super.onReceivedError(view, errorCode, description, failingUrl);
          }
        });

    webview.setDownloadListener(
        new DownloadListener() {
          public void onDownloadStart(
              String url,
              String userAgent,
              String contentDisposition,
              String mimetype,
              long contentLength) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
          }
        });

    if (!url.matches("^https?://.*")) {
      final String protocol = ConfigHelper.isControlSeverSSL(activity) ? "https" : "http";
      url = protocol + "://" + url;
    }

    webview.loadUrl(url);

    return webview;
  }
  public RMBTHistoryPagerAdapter(
      final RMBTMainActivity _activity,
      final ArrayList<HashMap<String, String>> itemList,
      final int resultAfterTestPos,
      final Handler _handler) {
    activity = _activity;
    this.itemList = itemList;
    this.resultAfterTestPos = resultAfterTestPos;
    handler = _handler;
    ndt = ConfigHelper.isNDT(_activity);

    if (ndt && resultAfterTestPos != -1)
      progressUpdater =
          new Runnable() {
            @Override
            public void run() {
              //                    Log.d(DEBUG_TAG, "refreshing progress");
              final NdtStatus status;
              float progress = 0f;
              if (service != null) {
                //                        Log.d(DEBUG_TAG, "we have the service");
                NdtStatus _status = service.getNdtStatus();
                if (_status == null)
                  _status = lastNdtStatus == null ? NdtStatus.NOT_STARTED : lastNdtStatus;
                status = _status;
                lastNdtStatus = status;
                progress = service.getNDTProgress();
              } else {
                //                        Log.d(DEBUG_TAG, "we have no service");
                NdtStatus _status = lastNdtStatus;
                if (_status == null) _status = NdtStatus.NOT_STARTED;
                if (_status == NdtStatus.RUNNING) _status = NdtStatus.FINISHED;
                status = _status;
              }

              //                    Log.d(DEBUG_TAG, String.format("status: %s", status == null ?
              // "null" : status.toString()));

              switch (status) {
                case NOT_STARTED:
                case ABORTED:
                case ERROR:
                  progress = 0f;
                  break;

                case FINISHED:
                case RESULTS:
                  progress = 1f;
                  break;
              }

              //                    Log.d(DEBUG_TAG, String.format("progress: %f", progress));

              if (extendedProgressView != null) extendedProgressView.setProgress(progress);
              if (extendedStatusView != null)
                switch (status) {
                  case NOT_STARTED:
                    extendedStatusView.setText(R.string.result_extended_test_not_started);
                    break;

                  case RUNNING:
                    extendedStatusView.setText(
                        String.format(
                            "%s (%d%%)",
                            activity.getString(R.string.result_extended_test_running),
                            Math.round(progress * 100f)));
                    break;

                  case RESULTS:
                    extendedStatusView.setText(
                        activity.getString(R.string.result_extended_test_results));
                    break;

                  case FINISHED:
                    extendedStatusView.setText(R.string.result_extended_test_finished);
                    break;

                  case ABORTED:
                    extendedStatusView.setText(R.string.result_extended_test_aborted);
                    break;

                  case ERROR:
                    extendedStatusView.setText(R.string.result_extended_test_error);
                    break;
                }

              if (status == NdtStatus.RUNNING
                  && extendedResultButtonCancel != null
                  && extendedResultButtonCancel.getVisibility() == View.GONE) {
                extendedResultButtonCancel.setVisibility(View.VISIBLE);
                if (extendedButtonDetails != null) extendedButtonDetails.setVisibility(View.GONE);
              }

              if (status == NdtStatus.NOT_STARTED
                  || status == NdtStatus.RUNNING
                  || status == NdtStatus.RESULTS) {
                //                        Log.d(DEBUG_TAG, "rescheduling progressUpdater");
                handler.postDelayed(progressUpdater, 500);
              } else {
                //                        Log.d(DEBUG_TAG, "no reschulding");
                if (extendedResultButtonCancel != null)
                  extendedResultButtonCancel.setVisibility(View.GONE);
                if (extendedButtonDetails != null)
                  extendedButtonDetails.setVisibility(View.VISIBLE);
              }
            }
          };
  }