feat: profile attachBaseContext - #21809
Merged
david-allison merged 2 commits intoSep 29, 2026
Merged
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
5 tasks
david-allison
requested changes
Sep 11, 2026
david-allison
left a comment
Member
There was a problem hiding this comment.
Could you implement this for Activities as well, or is this over-reaching in this PR?
criticalAY
force-pushed
the
profiles/context-attach
branch
from
September 18, 2026 07:18
f19e552 to
9052098
Compare
| } | ||
| } | ||
|
|
||
| private var profileManager: ProfileManager? = null |
Member
There was a problem hiding this comment.
I'd consider subclassing for this: what do you think? This one would want to get a second opinion before implementation
david-allison
approved these changes
Sep 18, 2026
criticalAY
force-pushed
the
profiles/context-attach
branch
from
September 18, 2026 15:10
9052098 to
296f37b
Compare
Loads the active profile without throwing, so a caller can fall back to the base context. Throwing during attachBaseContext would stop the app from starting at all. Timber is not planted that early, so the failure is recorded in attachError for the caller to log once logging is available. No caller yet.
AnkiDroidApp now routes its preferences, files, cache, databases and dirs through the active profile. It is set up in attachBaseContext so content providers, which get the Application itself, see it too. The framework's base context is left alone. ActivityThread casts it to ContextImpl when it delivers a manifest broadcast, so handing it a wrapper crashed every receiver, starting with BootService after boot. The ACRA sender process skips the setup: it only sends reports, and it should not write the profile registry from a second process. Users with only the Default profile are unaffected, since the wrapper passes everything through for that profile. Attach failures are logged once Timber is planted. Assisted-by: Claude Opus 5 [helped with tests]
criticalAY
force-pushed
the
profiles/context-attach
branch
from
September 29, 2026 07:50
296f37b to
c975487
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose / Description
ProfileManager and ProfileContextWrapper are fully implemented and tested, but had zero callers in src/main. attachBaseContext appeared nowhere so preparing for wiring data
Fixes
Approach
See commits
How Has This Been Tested?
Added test
Learning (optional, can help others)
The attachBaseContext -> ContentProvider.onCreate -> Application.onCreate ordering is the crux
Checklist
Please, go through these checks before submitting the PR.