Skip to content

Replace SharedPreferences with typed data stores - #702

Open
m4pl wants to merge 14 commits into
GrapheneOS:mainfrom
m4pl:prefs-settings-repo
Open

Replace SharedPreferences with typed data stores#702
m4pl wants to merge 14 commits into
GrapheneOS:mainfrom
m4pl:prefs-settings-repo

Conversation

@m4pl

@m4pl m4pl commented Sep 3, 2026

Copy link
Copy Markdown

Closes #686

RankoR and others added 14 commits September 3, 2026 20:53
SharedPreferences kept every setting, every SAF grant and the last captured
item in untyped files, read and written on whichever thread asked. Replace it
with three DataStores serialized as JSON - one for what the owner configured,
one for the SAF trees, one for what the app has captured - each opened once in
a SingletonComponent module and reached only through its repository. A
DataMigration per family carries the legacy keys over on first use.

An absent field means "unset", so a value equal to today's default is never
written and a later change to that default still reaches existing installs.
Installs migrated from SharedPreferences are the exception for the per-mode
settings, whose defaults the old code wrote out explicitly.

Lockscreen isolation now falls out of the wiring rather than a branch inside a
store: an ActivityComponent provider hands a SecureActivity an in-memory
snapshot of the owner's settings and SAF grants, while captured-media state
stays durable so a photo taken from the lockscreen survives the session.

Writes now block until the store has committed, where SharedPreferences.apply()
returned before the write landed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move preferences to SettingsRepository

2 participants