Provide callback instead of doing UI tasks of calling app #49#50
Provide callback instead of doing UI tasks of calling app #49#50
Conversation
3d64c67 to
fe9ba2d
Compare
fe9ba2d to
f3d1cc0
Compare
lib/src/main/java/at/bitfire/cert4android/UserDecisionRegistry.kt
Outdated
Show resolved
Hide resolved
lib/src/main/java/at/bitfire/cert4android/UserDecisionRegistry.kt
Outdated
Show resolved
Hide resolved
sample-app/src/main/java/at/bitfire/cert4android/demo/MainActivity.kt
Outdated
Show resolved
Hide resolved
d88df8e to
2776ce7
Compare
2776ce7 to
7ec1ded
Compare
rfc2822
left a comment
There was a problem hiding this comment.
Looks good! Can you add more documentation for parameters, especially scope and what it does exactly (cancel waiting for a decision when the scope is cancelled I guess)?
b00fcf9 to
47b9aca
Compare
There was a problem hiding this comment.
The Continuation logic is still hard to understand for me because it's so low-level. I have tried to add a few comments to make it better understandable.
Looks good otherwise.
Please have a final look at 47b9aca, then we can merge
Makes sense. I added a missing It's still complicated, but moving the |
lib/src/main/java/at/bitfire/cert4android/UserDecisionRegistry.kt
Outdated
Show resolved
Hide resolved
f63b58a to
49bd354
Compare
|
Ok bad news from my side regarding cert4android. I must say that I don't understand the complexity of the current flow, including what exactly the So I'm afraid that merging this may introduce new bugs in very rare cases (which we want to reduce). I had originally thought that we could just "pull out" the UI as a first part of the redesign, but I guess I had underestimated the consequences and complexity that's still in there. So an unfortunate (because of the work you have already put into this) question: shall we wait with this until we have the time to redesign the cert4android API from scratch in a better way? It's not perfect until it now is but it works in most cases. When we would redesign the API at a later time, we could take the time to think about all known cases and side-cases. |
|
As you like. I learned a lot, so it was not useless work for me 👍 It's true that with a better designed API we could probably do this way cleaner. |
|
So let's only keep https://github.com/bitfireAT/cert4android/pull/50/files/12f1b4596fd26750094877df8be908c4930bf61e#r1991806967 ? .. in a new PR. |
Created #52 for that new PR |
Purpose
cert4android shouldn't show the
TrustCertificateActivityand a notification by itself. Instead it should execute a callback which is provided by the calling application.Short description
appInForeground) to cert4androidgetUserDecisionand the coroutine scope in which it should runNote
I would like to avoid the
delay(1000)intestCheck_MultipleDecisionsForSameCert_Negative, but I could not make it work using a countdown latch and using a mutex quickly became complicated too. I also thought of launching a 6th seperate coroutine which would watchregistry.pendingDecisions.sizewith a while loop and release the semaphore as soon as 5 pending decisions are reached, but could not make that work either. In the end thedelay(1000)is quite simple and seems to work well, but let me know if you find a cleaner way.