@Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feature_dfu);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    isBLESupported();
    setGUI();

    // Try to create sample files
    if (FileHelper.newSamplesAvailable(this)) {
      if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
          == PackageManager.PERMISSION_GRANTED) {
        FileHelper.createSamples(this);
      } else {
        final DialogFragment dialog =
            PermissionRationaleFragment.getInstance(
                R.string.permission_sd_text, Manifest.permission.WRITE_EXTERNAL_STORAGE);
        dialog.show(getSupportFragmentManager(), null);
      }
    }

    // restore saved state
    mFileType = DfuService.TYPE_AUTO; // Default
    if (savedInstanceState != null) {
      mFileType = savedInstanceState.getInt(DATA_FILE_TYPE);
      mFileTypeTmp = savedInstanceState.getInt(DATA_FILE_TYPE_TMP);
      mFilePath = savedInstanceState.getString(DATA_FILE_PATH);
      mFileStreamUri = savedInstanceState.getParcelable(DATA_FILE_STREAM);
      mInitFilePath = savedInstanceState.getString(DATA_INIT_FILE_PATH);
      mInitFileStreamUri = savedInstanceState.getParcelable(DATA_INIT_FILE_STREAM);
      mSelectedDevice = savedInstanceState.getParcelable(DATA_DEVICE);
      mStatusOk = mStatusOk || savedInstanceState.getBoolean(DATA_STATUS);
      mUploadButton.setEnabled(mSelectedDevice != null && mStatusOk);
    }

    final Intent intent = getIntent();
    mbluetoothLeDevice = intent.getParcelableExtra(BLEDeviceActivity.EXTRA_DEVICE);
    mBleDeviceType = intent.getIntExtra(BLEDeviceActivity.EXTRA_BLE_DEVICE_TYPE, 0xff);
    if (mBleDeviceType == SentekBLEDeviceType.Dongle_DFU.ordinal()) {
      swapDFU_UUID(true);
    } else if (mBleDeviceType == SentekBLEDeviceType.Probe_DFU.ordinal()) {
      swapDFU_UUID(false);
    }

    if (mbluetoothLeDevice != null) {
      mSelectedDevice = mbluetoothLeDevice.getDevice();
      mUploadButton.setEnabled(mStatusOk);
      mDeviceNameView.setText(
          mSelectedDevice.getName() != null
              ? mSelectedDevice.getName()
              : getString(R.string.sentek_dfu));
    }

    FileHelper.createSamplesNew(this);
    mFileType = mFileTypeTmp = DfuService.TYPE_APPLICATION;
    updateFileInfoNew(false); // TODO:
    //		doUpload(true);
  }
 private void showDeviceScanningDialog() {
   final ScannerFragmentAutoSelect dialog =
       ScannerFragmentAutoSelect.getInstance(
           UUID.fromString(SentekUUID.Probe_DFU),
           mbluetoothLeDevice.getAddress(),
           "Searching Probe DFU...",
           false); // Device that is advertising directly does not have the GENERAL_DISCOVERABLE
                   // nor LIMITED_DISCOVERABLE flag set.
   dialog.show(getSupportFragmentManager(), "scan_fragment");
 }
 private void showDeviceScanningDialogAndSelectProbe(int mBleDeviceType) {
   //        startDFUActivity(SentekApplication.mdevice);
   String trimDeviceName = "Probe";
   if (SentekApplication.mdevice != null)
     trimDeviceName = SentekApplication.mdevice.getName().trim();
   String msg = "Searching " + trimDeviceName + " for Connect...";
   final ScannerFragmentAutoSelect dialog =
       ScannerFragmentAutoSelect.getInstance(
           UUID.fromString(SentekUUID.Probe),
           mbluetoothLeDevice.getAddress(),
           msg,
           true); // Device that is advertising directly does not have the GENERAL_DISCOVERABLE nor
                  // LIMITED_DISCOVERABLE flag set.
   dialog.show(getSupportFragmentManager(), "scan_fragment");
 }