Troubleshoot device previously claimed issues

This commit is contained in:
Davide Depau 2018-08-14 17:22:53 +02:00
parent 23f0842e9a
commit 1296c3ec39

View file

@ -64,25 +64,33 @@ class ConfirmInfoFragment : WizardFragment() {
view.confirm_sel_usbdev.text = StateKeeper.usbDevice?.name view.confirm_sel_usbdev.text = StateKeeper.usbDevice?.name
try { for (trial in 0..1) {
StateKeeper.usbMassStorageDevice!!.init() try {
val blockDev = StateKeeper.usbMassStorageDevice?.blockDevice StateKeeper.usbMassStorageDevice!!.init()
val blockDev = StateKeeper.usbMassStorageDevice?.blockDevice
if (blockDev != null) { if (blockDev != null) {
val devSize = (blockDev.size.toLong() * blockDev.blockSize.toLong()) val devSize = (blockDev.size.toLong() * blockDev.blockSize.toLong())
view.confirm_sel_usbdev_size.text = devSize.toHRSize() view.confirm_sel_usbdev_size.text = devSize.toHRSize()
if (imgSize!! > devSize) if (imgSize!! > devSize)
view.confirm_extra_info.text = getString(R.string.image_bigger_than_usb) view.confirm_extra_info.text = getString(R.string.image_bigger_than_usb)
else { else {
view.confirm_extra_info.text = getString(R.string.tap_next_to_write) view.confirm_extra_info.text = getString(R.string.tap_next_to_write)
canContinue = true canContinue = true
}
} else {
view.confirm_extra_info.text = getString(R.string.cant_read_usbdev)
}
} catch (e: IOException) {
if (trial == 0) {
StateKeeper.usbMassStorageDevice!!.close()
continue
} else {
view.confirm_extra_info.text = "Could not access USB device. Maybe you ran the app previously and it crashed? Remove and reinsert the USB drive, then restart the app."
break
} }
} else {
view.confirm_extra_info.text = getString(R.string.cant_read_usbdev)
} }
} catch (e: IOException) {
view.confirm_extra_info.text = "Could not access USB device. Maybe you ran the app previously and it crashed? Remove and reinsert the USB drive, then restart the app."
} }
return view return view