Repository navigation
fix: backup reminder cross profile share - #22901
criticalAY wants to merge 1 commit into
Conversation
|
Can we make an explicit issue for this? It's gonna be a nasty one with quite a lot to discuss |
|
Sure! |
On Android 16 the share sheet hides which app was picked when it is in the work profile, so sharing an exported collection there didn't postpone the backup reminder. A hidden pick now counts as well. Part of 22893 Assisted-by: Claude Opus 5.5
ebd2ced to
9e4132a
Compare
mikehardy
left a comment
There was a problem hiding this comment.
Assisted-by: grok-4.7
Thank you for splitting this out of #22895 and for the regression test that drives the real IntentSender. The same-profile, legacy, and copy cases are the right controls.
Locally I rebased the single commit onto current main without force-pushing (prep stayed at the PR tip). Lint (lintAll, ktlintCheck, lint-rules:test), unit tests (jacocoUnitTestReport), and release emulator tests (TEST_RELEASE_BUILD=true via run_emulator_tests.py on emulator-5556 / API35_GAPI) all passed.
AnkiActivity shares an exported package with Intent.createChooser(sendIntent, title, ExportSharedReceiver.getIntentSender(...)). The sender is a mutable broadcast PendingIntent whose base intent targets ExportSharedReceiver and carries exportPath. onReceive reads EXTRA_CHOSEN_COMPONENT. From API 35 up, isCrossProfileShare() is true when EXTRA_CHOOSER_RESULT is a ChooserResult whose type is CHOOSER_RESULT_UNKNOWN. That flag skips the return that used to ignore a missing component or this app's package. If exportPath is still present and the file name is a collection package, BackupPromptDialog.onFileExported calls onBackup(), which stores timeToShowBackupDialog at now plus 13–16 days. A copy result, a missing chooser result, or a same-profile component in this package still returns before that write. The fill-in from the chooser is merged onto the original broadcast intent, so exportPath survives; the new tests only pass because that merge reaches onBackup.
Requesting changes: #22902 is still open and has no product decision yet. David asked for that issue because cross-profile / redacted chooser results need discussion. This PR treats every CHOOSER_RESULT_UNKNOWN as grounds to postpone the backup reminder, including Android 16's cross-profile selection where the component is null — so a share to work-profile AnkiDroid would postpone the reminder the same as a share to another app. Please settle #22902 before merge; if the answer is yes this branch can stay, if no drop the UNKNOWN path.
some acceptable findings, no action required, just leaving for posterity: isCrossProfileShare is every CHOOSER_RESULT_UNKNOWN, and AOSP uses that same type for ShareAction.APPLICATION_DEFINED (this share site does not register one); the gate is VANILLA_ICE_CREAM (API 35) while the cross-profile redaction is the Android 16 sender; PR Approach is NA and the body cites Part of #22893 rather than #22902; commit subject is 59 characters (fix(backup): count a work-profile share is 40).
Note
Assisted-by: Opus 5.5
Purpose / Description
On Android 16, when the share sheet sends an exported collection to an app in the work profile, it doesn't say which app was picked. The share then didn't postpone the "Backup your collection" reminder.
Fixes
Approach
NA
How Has This Been Tested?
tests only
Learning (optional, can help others)
Android 15 still reports which app was picked for a work-profile share; hiding it is new in Android 16. The share sheet also sends
CHOOSER_RESULT_UNKNOWNfor an app's own custom share actions, but AnkiDroid doesn't add any.https://android.googlesource.com/platform/packages/modules/IntentResolver/+/refs/heads/android16-release/java/src/com/android/intentresolver/ui/ShareResultSender.kt
Checklist
Please, go through these checks before submitting the PR.