fix autobug NPE

pull/266/head
Kevin Hester 2021-03-23 13:21:51 +08:00
rodzic cea7755aa4
commit dd9a2b99d7
1 zmienionych plików z 22 dodań i 21 usunięć

Wyświetl plik

@ -659,30 +659,32 @@ class MainActivity : AppCompatActivity(), Logging,
debug("Getting latest radioconfig from service")
try {
val info = service.myNodeInfo
val info: MyNodeInfo? = service.myNodeInfo // this can be null
model.myNodeInfo.value = info
val isOld = info.minAppVersion > BuildConfig.VERSION_CODE
if (isOld)
showAlert(R.string.app_too_old, R.string.must_update)
else {
val curVer = DeviceVersion(info.firmwareVersion ?: "0.0.0")
if (curVer < MeshService.minFirmwareVersion)
showAlert(R.string.firmware_too_old, R.string.firmware_old)
if (info != null) {
val isOld = info.minAppVersion > BuildConfig.VERSION_CODE
if (isOld)
showAlert(R.string.app_too_old, R.string.must_update)
else {
// If our app is too old/new, we probably don't understand the new radioconfig messages, so we don't read them until here
model.radioConfig.value =
RadioConfigProtos.RadioConfig.parseFrom(service.radioConfig)
val curVer = DeviceVersion(info.firmwareVersion ?: "0.0.0")
if (curVer < MeshService.minFirmwareVersion)
showAlert(R.string.firmware_too_old, R.string.firmware_old)
else {
// If our app is too old/new, we probably don't understand the new radioconfig messages, so we don't read them until here
model.channels.value =
ChannelSet(AppOnlyProtos.ChannelSet.parseFrom(service.channels))
model.radioConfig.value =
RadioConfigProtos.RadioConfig.parseFrom(service.radioConfig)
updateNodesFromDevice()
model.channels.value =
ChannelSet(AppOnlyProtos.ChannelSet.parseFrom(service.channels))
// we have a connection to our device now, do the channel change
perhapsChangeChannel()
updateNodesFromDevice()
// we have a connection to our device now, do the channel change
perhapsChangeChannel()
}
}
}
} catch (ex: RemoteException) {
@ -968,12 +970,11 @@ class MainActivity : AppCompatActivity(), Logging,
try {
bindMeshService()
}
catch(ex: BindFailedException) {
} catch (ex: BindFailedException) {
// App is probably shutting down, ignore
errormsg("Bind of MeshService failed")
}
val bonded = RadioInterfaceService.getBondedDeviceAddress(this) != null
if (!bonded && usbDevice == null) // we will handle USB later
showSettingsPage()
@ -1100,7 +1101,7 @@ class MainActivity : AppCompatActivity(), Logging,
positionToMeter(my_position!!, position).roundToInt()
fs.write(
("${packet_proto.from.toUInt().toString(16)}," +
"${packet_proto.rxSnr},${packet_proto.rxTime},$dist\n")
"${packet_proto.rxSnr},${packet_proto.rxTime},$dist\n")
.toByteArray()
)
}