Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f3d1cc0
Provide callback instead of doing UI tasks of calling app
sunkup Feb 19, 2025
6bd6422
Use the right scope
sunkup Feb 20, 2025
b465b60
Use a deferred to await user decision instead of flow
sunkup Feb 20, 2025
11f6cf7
Pass scope only where needed
sunkup Feb 25, 2025
ce1d76e
Minor rearrangements
sunkup Feb 25, 2025
c91fbb4
Fix tests
sunkup Feb 25, 2025
0924124
Mark userDecision property as volatile
sunkup Feb 25, 2025
e32a205
Remove TrustCertificateActivity from manifest
sunkup Feb 25, 2025
96a102e
Remove unused strings
sunkup Feb 25, 2025
7ec1ded
Fix tests for CI
sunkup Feb 26, 2025
67c6a1b
Remove remaining notification related code
sunkup Feb 26, 2025
031f718
Update README.md
sunkup Feb 26, 2025
89d5990
Remove remaining unused string resources
sunkup Feb 26, 2025
8fb0ea2
Merge branch 'main' into 49-provide-callback-instead-of-doing-ui-task…
rfc2822 Feb 27, 2025
aa7fea6
Revert "Remove unused strings"
sunkup Mar 4, 2025
9d9bfdb
Revert "Remove remaining unused string resources"
sunkup Mar 4, 2025
a85285d
Extract and use composable from TrustCertificateActivity
sunkup Mar 4, 2025
42efa84
Merge branch 'main' into 49-provide-callback-instead-of-doing-ui-task…
sunkup Mar 10, 2025
7c65abb
Remove theme
sunkup Mar 10, 2025
cf358a1
Remove livedata, viewmodel and activity related dependencies
sunkup Mar 10, 2025
246a542
Minor UI changes
rfc2822 Mar 11, 2025
751d675
Move state of pending decision into Flow
rfc2822 Mar 11, 2025
863629d
Improve kdoc
sunkup Mar 11, 2025
8c6e7b7
Move companion object to the end of class
sunkup Mar 11, 2025
6d4263c
Make PendingDecision a data class
sunkup Mar 11, 2025
02427de
Update comment
sunkup Mar 11, 2025
106c60a
Revert "Make PendingDecision a data class"
sunkup Mar 11, 2025
47b9aca
Minor changes in structure, comments
rfc2822 Mar 12, 2025
e42a98a
Add param to kdoc
sunkup Mar 12, 2025
f4ace05
Replace iterator with forEach
sunkup Mar 12, 2025
c5bfc05
Revert "Replace iterator with forEach"
sunkup Mar 12, 2025
6b60ca4
More comments for iteration
rfc2822 Mar 12, 2025
12f1b45
Use Collections.synchronizedMap to synchronize access
rfc2822 Mar 12, 2025
0c0bbd5
Add test to check whether pendingDecisions are empty after cancellation
sunkup Mar 13, 2025
49bd354
Remove decisions list from pendingDecisions map if list is empty
sunkup Mar 18, 2025
3de7b87
Main activity: edge-to-edge
rfc2822 Apr 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import androidx.lifecycle.viewModelScope
import at.bitfire.cert4android.Cert4Android
import at.bitfire.cert4android.CustomCertManager
import at.bitfire.cert4android.CustomCertStore
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import org.apache.http.conn.ssl.AllowAllHostnameVerifier
import org.apache.http.conn.ssl.StrictHostnameVerifier
Expand Down Expand Up @@ -179,10 +179,10 @@ class MainActivity : ComponentActivity() {
private val _certificateFlow = MutableStateFlow<X509Certificate?>(null)
val certificateFlow: StateFlow<X509Certificate?> = _certificateFlow

private val _userDecisionFlow = MutableStateFlow<Boolean?>(null)
private var userDecision: CompletableDeferred<Boolean> = CompletableDeferred()

fun setUserDecision(decision: Boolean) {
_userDecisionFlow.value = decision
userDecision.complete(decision)
_certificateFlow.value = null
}

Expand All @@ -208,21 +208,14 @@ class MainActivity : ComponentActivity() {
viewModelScope,
trustSystemCerts = trustSystemCerts,
getUserDecision = { cert ->
// Called by cert4android to get user decision on whether to trust this certificate
Log.i(Cert4Android.TAG, "getUserDecision(${cert.encoded}): ?")
// Reset user decision
userDecision = CompletableDeferred()

// Show TrustDecisionDialog with certificate to user
_certificateFlow.value = cert

// ... wait for user decision and save it
val userDecision: Boolean = _userDecisionFlow.first { it != null } == true

// ... reset user decision
_userDecisionFlow.value = null

// return the decision to cert4android
Log.i(Cert4Android.TAG, "getUserDecision(${cert.encoded}): $userDecision")
userDecision
// Wait for user decision and return it
userDecision.await()
}
)
urlConn.hostnameVerifier = certMgr.HostnameVerifier(StrictHostnameVerifier())
Expand Down
Loading