fix autobug - apparently EXTRA_DEVICE can be null on some implementations

This commit is contained in:
Kevin Hester
2021-03-31 19:40:33 +08:00
parent d9a2a469bc
commit 091b18a5bb

View File

@@ -489,9 +489,11 @@ class MainActivity : AppCompatActivity(), Logging,
}
UsbManager.ACTION_USB_DEVICE_ATTACHED -> {
val device: UsbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)!!
debug("Handle USB device attached! $device")
usbDevice = device
val device: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
if (device != null) {
debug("Handle USB device attached! $device")
usbDevice = device
}
}
Intent.ACTION_MAIN -> {