Skip to content
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

Merged
merged 6 commits into from
May 11, 2022
Merged

Multi-process shared prefs #1920

merged 6 commits into from
May 11, 2022

Conversation

aitorvs
Copy link
Collaborator

@aitorvs aitorvs commented May 8, 2022

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

@aitorvs
Copy link
Collaborator Author

aitorvs commented May 8, 2022

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

versions.properties Outdated Show resolved Hide resolved
@aitorvs aitorvs force-pushed the feature/aitor/atp/harmony branch 2 times, most recently from ec81256 to e93939e Compare May 9, 2022 14:34

import android.content.SharedPreferences

class InMemorySharedPreferences : SharedPreferences, SharedPreferences.Editor {
Copy link
Collaborator Author

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

Comment on lines +27 to +29
interface VpnSharedPreferencesProvider {
fun getSharedPreferences(name: String, multiprocess: Boolean = false): SharedPreferences
}
Copy link
Collaborator Author

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

Copy link
Contributor

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.

@aitorvs aitorvs force-pushed the feature/aitor/atp/harmony branch from e93939e to cfcfbb2 Compare May 9, 2022 19:33
Copy link
Contributor

@malmstein malmstein left a 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.

Comment on lines +27 to +29
interface VpnSharedPreferencesProvider {
fun getSharedPreferences(name: String, multiprocess: Boolean = false): SharedPreferences
}
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

@aitorvs aitorvs marked this pull request as ready for review May 11, 2022 11:26
@aitorvs aitorvs merged commit 58c7d36 into develop May 11, 2022
@aitorvs aitorvs deleted the feature/aitor/atp/harmony branch May 11, 2022 11:27
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.

3 participants