Skip to content

Commit 54eaecc

Browse files
sunkuprfc2822
authored andcommitted
Backport of bitfireAT/davx5#655: honor build config decision on whether users are allowed to accept custom certificates
* Honor customCertsUI build config value on whether users are allowed to accept custom certificates Signed-off-by: Sunik Kupfer <[email protected]> * Add kdoc Signed-off-by: Sunik Kupfer <[email protected]> * Update comment Signed-off-by: Sunik Kupfer <[email protected]> * Extract config evaluation; Update kdoc Signed-off-by: Sunik Kupfer <[email protected]> --------- Signed-off-by: Sunik Kupfer <[email protected]>
1 parent 0012dec commit 54eaecc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/src/main/kotlin/at/bitfire/davdroid/network/HttpClient.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ class HttpClient(
234234
val certManager = CustomCertManager(
235235
context = context,
236236
trustSystemCerts = !settingsManager.getBoolean(Settings.DISTRUST_SYSTEM_CERTIFICATES),
237-
appInForeground = ForegroundTracker.inForeground
237+
appInForeground = if (/* davx5-ose */ true)
238+
ForegroundTracker.inForeground // interactive mode
239+
else
240+
null // non-interactive mode
238241
)
239242

240243
val sslContext = SSLContext.getInstance("TLS")

app/src/main/kotlin/at/bitfire/davdroid/ui/ForegroundTracker.kt

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import kotlinx.coroutines.flow.asStateFlow
1212
*/
1313
object ForegroundTracker {
1414

15+
/**
16+
* Whether the app is in the foreground.
17+
* Used by cert4android to known when it's possible to show the certificate trust decision dialog.
18+
*/
1519
private val _inForeground = MutableStateFlow(false)
1620

1721
/**
@@ -32,4 +36,5 @@ object ForegroundTracker {
3236
fun onPaused() {
3337
_inForeground.value = false
3438
}
39+
3540
}

0 commit comments

Comments
 (0)