-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix: handle database-related errors / import in AnkiActivity #17512
fix: handle database-related errors / import in AnkiActivity #17512
Conversation
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.
I don't know here. It's a big change for a patch release. I'd want to see it sit in beta for a little while
Implementation-wise: I feel this makes sense. A user tapping a dialog should be moved to the main screen, if this can't occur, the dialog should still be functional
- Rename
ankiActivity
->activity
in param names - If something went wrong, also send an exception report
I'd approve after the nits are picked
The decoded statement here is, are we sure this all works? That is, it needs more testing, right? I think a request for directed testing vs a mild hope that beta users will magically check everything is more valid. And I can do that It's a lot of diff but conceptually - given type safety etc - it isn't that big a move IMHO. Only distasteful because "more stuff in AnkiActivity"... |
5109273
to
264de93
Compare
I've added 3 commits nestled around the "real" fix, and implemented the nits - updated the description in Approach to describe same |
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.
One nit I feel is blocking (naming the key). The rest looks great. Pre-approved in the labels given that they're all nits
Great catch on the BadWindowToken
fix!
AnkiDroid/src/main/java/com/ichi2/anki/preferences/DevOptionsFragment.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/preferences/DevOptionsFragment.kt
Show resolved
Hide resolved
previously we would ignore our sendExceptionReport param if a dialog post fails, meaning that we would not get exception reports from ACRA in circumstances we really want them
this patch has been floating around a lot, and it is very useful you can use it to test the permanently inaccessible storage dialog, which you can then also use to test the restore from backup dialog
…om them so we do not need the full stack trace and they shouldn't be warn
3853a91
to
36851ed
Compare
fixed the 2 nits possible - stated as pre-approved given those + appropriate tags
this removes all the casting to DeckPicker that causes crashes at the worst possible time (like when you lost collection permission and the PermissionActivity is not a DeckPicker type)
I wanna do 2.19.3 basically immediately to get it out for a soak with limited distribution so I'm going to accept responsibility and ask for apologies if there is a need for any follow-ons, but here we go |
Purpose / Description
this removes all the casting to DeckPicker that causes crashes at the worst possible time (like when you lost collection permission and the PermissionActivity is not a DeckPicker type)
Fixes
PermissionsUntil29Fragment
: PermissionsActivity cannot be cast tocom.ichi2.anki.DeckPicker
#17372Approach
We've got hierarchy problems, and the problem is that we have multiple sub-types that think they can blindly refer to things as
DeckPicker
through various mechanisms.But they can't, and they crash.
So I've moved the things that were crashing on up in the hierarchy so that all the types had them, and hopefully they won't crash.
By commits:
1- sendExceptionReport in our helper method for showing errors to users, even if the dialog show failed (non-controversial? but perhaps using
showError
is controversial and we just want a directsendExceptionReport
)2- the main fix: move all the DialogHandler.asyncMessage / import-related stuff up to AnkiActivity so now PermissionsActivity can safely host it
3- add a dev preference to set your database path to pre-scoped storage. This lets you trigger the PermissionsActivity dialog fragment which let's you choose restore from backup which lets you verify it still works in this context. Unfortunately it isn't possible to test all the permissions fragments (like the PermanentlyRevoked one...) without manual hackery in testing
4- quiet a couple error messages that weren't really errors. Can drop this, but I was in there and it seemed like the right thing to do so tacked it on
How Has This Been Tested?
After this change, I went to the DeckPicker and I exported a package, then I imported a package, and it worked, both .apkg and colpkg types
A more involved test - use the new "set collection path" dev option to set my collection to the old path - re-open the app and get the permissions dialog - then try to restore from backup, it works
Learning (optional, can help others)
I have clearly learned nothing about clean architecture 😆 but I'm laser-focused on not crashing right now.
Checklist
Please, go through these checks before submitting the PR.