-
Notifications
You must be signed in to change notification settings - Fork 931
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
Multi-process shared prefs #1920
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
ec81256
to
e93939e
Compare
|
||
import android.content.SharedPreferences | ||
|
||
class InMemorySharedPreferences : SharedPreferences, SharedPreferences.Editor { |
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.
Added this class to easily fake shared preferences. The usage of this is limited right now. We can create a subsequent task to increase test coverage when possible
vpn-store/src/main/java/com/duckduckgo/mobile/android/vpn/store/VpnDatabase.kt
Show resolved
Hide resolved
vpn/src/main/java/com/duckduckgo/mobile/android/vpn/pixels/DeviceShieldPixels.kt
Show resolved
Hide resolved
interface VpnSharedPreferencesProvider { | ||
fun getSharedPreferences(name: String, multiprocess: Boolean = false): SharedPreferences | ||
} |
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.
This is only in the :vpn
module for now. If we like this pattern we can move it to eg. :common
module and use it across the app (which I think we should). But it's kind of out of scope of this PR I think
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 personally like the idea.
e93939e
to
cfcfbb2
Compare
vpn/src/main/java/com/duckduckgo/mobile/android/vpn/ui/onboarding/VpnStore.kt
Show resolved
Hide resolved
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.
Tested and works a treat. Personally I'd go for this option instead of a table to fix the multi-process issue. I'll leave the rest to comment on it, but approved from my side.
interface VpnSharedPreferencesProvider { | ||
fun getSharedPreferences(name: String, multiprocess: Boolean = false): SharedPreferences | ||
} |
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 personally like the idea.
return runBlocking(dispatcherProvider.io()) { | ||
vpnDatabasePreferences.getPreference(KEY_ALWAYS_ON_MODE_ENABLED)?.value ?: false | ||
} | ||
return preferences.getBoolean(KEY_ALWAYS_ON_MODE_ENABLED, false) |
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.
🔥
Task/Issue URL: https://app.asana.com/0/414730916066338/1202242242171822/f
Description
Multi-process shared prefs
Steps to test this PR
Smoke tests for browser and AppTP
Repeat always on tests