0.7.2 hotfixes for autobugs

This commit is contained in:
geeksville
2020-06-08 14:19:49 -07:00
parent 303fb86aa6
commit c0ada64653
3 changed files with 16 additions and 7 deletions

View File

@@ -17,8 +17,8 @@ android {
applicationId "com.geeksville.mesh"
minSdkVersion 22 // The oldest emulator image I have tried is 22 (though 21 probably works)
targetSdkVersion 29
versionCode 171
versionName "0.7.1"
versionCode 172
versionName "0.7.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {

View File

@@ -443,9 +443,11 @@ class MeshService : Service(), Logging {
val wantForeground = RadioInterfaceService.getBondedDeviceAddress(this) != null
info("Requesting foreground service=$wantForeground")
if (wantForeground)
startForeground(notifyId, createNotification())
else
// We always start foreground because that's how our service is always started (if we didn't then android would kill us)
// but if we don't really need forground we immediately stop it.
startForeground(notifyId, createNotification())
if (!wantForeground)
stopForeground(true)
}

View File

@@ -100,11 +100,18 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
}
data class DeviceListEntry(val name: String, val address: String, val bonded: Boolean) {
// val isSelected get() = macAddress == selectedMacAddr
val bluetoothAddress
get() =
if (address[0] == 'x')
address.substring(1)
else
null
override fun toString(): String {
return "DeviceListEntry(name=${name.anonymize}, addr=${address.anonymize})"
}
}
override fun onCleared() {
@@ -281,7 +288,7 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
} else {
// We ignore missing BT adapters, because it lets us run on the emulator
bluetoothAdapter
?.getRemoteDevice(it.address)?.let { device ->
?.getRemoteDevice(it.bluetoothAddress)?.let { device ->
requestBonding(activity, device) { state ->
if (state == BOND_BONDED) {
errorText.value = activity.getString(R.string.pairing_completed)