fix: ensure bg loc permissions, unbind service (#2050)

This commit is contained in:
James Rich
2025-06-07 20:42:29 +00:00
committed by GitHub
parent d8e9c30399
commit 89462be97a
2 changed files with 29 additions and 0 deletions

View File

@@ -389,6 +389,25 @@ class MainActivity : AppCompatActivity(), Logging {
)
}
private fun unbindMeshService() {
// If we have received the service, and hence registered with
// it, then now is the time to unregister.
// if we never connected, do nothing
debug("Unbinding from mesh service!")
connectionJob?.let { job ->
connectionJob = null
warn("We had a pending onConnection job, so we are cancelling it")
job.cancel("unbinding")
}
mesh.close()
serviceRepository.setMeshService(null)
}
override fun onStop() {
unbindMeshService()
super.onStop()
}
override fun onStart() {
super.onStart()
bluetoothViewModel.enabled.observe(this) { enabled ->

View File

@@ -471,6 +471,16 @@ fun ConnectionsScreen(
}
AnimatedVisibility(isConnected) {
val provideLocation by uiViewModel.provideLocation.collectAsState(false)
LaunchedEffect(provideLocation) {
if (provideLocation) {
if (!context.hasLocationPermission()) {
debug("Requesting location permission for providing location")
showLocationRationaleDialog = true
} else if (isGpsDisabled) {
uiViewModel.showSnackbar(context.getString(R.string.location_disabled))
}
}
}
Row(
modifier = Modifier
.fillMaxWidth()