-
Notifications
You must be signed in to change notification settings - Fork 8
Provide callback instead of doing UI tasks of calling app #49 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
TrustCertificateActivity
and a notification by itself. Instead it should execute a callback which is provided by the calling application.Short description
appInForeground
) to cert4androidgetUserDecision
and 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.size
with 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.