Skip to content

Commit fb7c2e4

Browse files
fix: auto-reset serviceFailed on permission re-grant, document source column
LocationServiceCoordinator: - Add resetFailedState() method - acquire() checks permission when serviceFailed is true and resets automatically if re-granted (no process restart needed) ReceivedLocationEntity: - Document that source column is scaffolding for future SOS trail entries (PR torlando-tech#713) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 58a7a62 commit fb7c2e4

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

app/src/main/java/network/columba/app/service/LocationServiceCoordinator.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,26 @@ object LocationServiceCoordinator {
2020

2121
// Set when the service fails to start (e.g. SecurityException on Android 14+).
2222
// Prevents observers from retrying acquire() in a loop.
23-
// Reset when the user re-grants permission and the app is restarted.
2423
@Volatile
2524
private var serviceFailed = false
2625

2726
fun isAcquired(reason: String): Boolean = synchronized(activeReasons) { reason in activeReasons }
2827

28+
/** Call after the user re-grants location permission to allow re-acquiring the service. */
29+
fun resetFailedState() {
30+
serviceFailed = false
31+
Log.d(TAG, "serviceFailed flag cleared — permission likely re-granted")
32+
}
33+
2934
fun acquire(context: Context, reason: String) {
30-
if (serviceFailed) return
35+
if (serviceFailed) {
36+
// Check if permission was re-granted since the failure
37+
if (com.lxmf.messenger.util.LocationPermissionManager.hasPermission(context)) {
38+
resetFailedState()
39+
} else {
40+
return
41+
}
42+
}
3143
synchronized(activeReasons) {
3244
val wasEmpty = activeReasons.isEmpty()
3345
activeReasons.add(reason)

data/src/main/java/network/columba/app/data/db/entity/ReceivedLocationEntity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ data class ReceivedLocationEntity(
3838
) {
3939
companion object {
4040
const val SOURCE_LOCATION_SHARING = "location_sharing"
41+
// Future: SOURCE_SOS_TRAIL = "sos_trail" for SOS breadcrumb trail entries (see PR #713)
4142
}
4243
}

0 commit comments

Comments
 (0)