Skip to content

fix: backup reminder cross profile share - #22901

Draft
criticalAY wants to merge 1 commit into
ankidroid:mainfrom
criticalAY:fix/backup-reminder-cross-profile-share
Draft

criticalAY wants to merge 1 commit into
ankidroid:mainfrom
criticalAY:fix/backup-reminder-cross-profile-share

Conversation

@criticalAY

@criticalAY criticalAY commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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_UNKNOWN for 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.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@criticalAY criticalAY added Blocked by dependency Currently blocked by some other dependent / related change and removed Needs Review labels Nov 2, 2026
@david-allison

Copy link
Copy Markdown
Member

Can we make an explicit issue for this? It's gonna be a nasty one with quite a lot to discuss

@criticalAY

Copy link
Copy Markdown
Contributor Author

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
@criticalAY
criticalAY force-pushed the fix/backup-reminder-cross-profile-share branch from ebd2ced to 9e4132a Compare November 3, 2026 05:58

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@mikehardy mikehardy added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Nov 3, 2026
@david-allison
david-allison marked this pull request as draft November 3, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backup reminder: should a share to a work profile app count as a backup? (Android 16+)

3 participants