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

Local state pref to use from Java #16486

Merged
merged 8 commits into from
Jan 4, 2023
Merged

Conversation

AlexeyBarabash
Copy link
Contributor

@AlexeyBarabash AlexeyBarabash commented Dec 28, 2022

Resolves brave/brave-browser#27632

Intruduced BraveLocalState class.

Removed methods from BravePrefServiceBridge which were used to access these local_state prefs:

  • BravePref.P3A_ENABLED
  • BravePref.P3A_NOTICE_ACKNOWLEDGED
  • BravePref.STATS_REPORTING_ENABLED
  • BravePref.SAFETYNET_STATUS
  • BravePref.ENS_RESOLVE_METHOD
  • BravePref.SNS_RESOLVE_METHOD
  • BravePref.UNSTOPPABLE_DOMAINS_RESOLVE_METHOD
  • BravePref.ENS_OFFCHAIN_RESOLVE_METHOD

Removed unused Java/JNI methods:

  • BravePrefServiceBridge.setReferralAndroidFirstRunTimestamp;
  • BravePrefServiceBridge.setReferralCheckedForPromoCodeFile;
  • BravePrefServiceBridge.setReferralInitialization;
  • BravePrefServiceBridge.setReferralPromoCode;
  • BravePrefServiceBridge.setReferralDownloadId.

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

New features are not added with this PR. The test plan is required to verify nothing is broken.

I. brave.p3a.enabled

  1. Make fresh installation
  2. Launch browser, on FTRW uncheck Share completely private and anonymous product insights about what features are being used by Brave's users.
  3. Open brave://local-state, must exist
 "p3a": {
         "enabled": true,

entry.
4. Go to app menu => Settings => Brave Shields & privacy, Allow privacy-preserving product diagnostic (P3A) must be unchecked
5. Check Allow privacy-preserving product diagnostic (P3A) switch
6. Open brave://local-state, the entry should look

 "p3a": {
         "enabled": false,

II. brave.stats.reporting_enabled

  1. Open app menu => Settings => Brave Shields & privacy, turn off Automatically send daily usage pings
  2. Open brave://local-state, find reporting_enabled should be false
  3. Open again app menu => Settings => Brave Shields & privacy, Automatically send daily usage pings must be unchecked

III. safetynet.status
According to the code, the Brave Rewards grant should be retreived successfullt to verify it works as before.

IV. brave.unstoppable_domains.resolve_method

  1. Open app menu => Settings => Brave Shields & privacy => Unstoppable Domains, switch it to Enabled
  2. Open brave://local-state, find resolve_method near unstoppable_domains, it should be
"unstoppable_domains": {
         "resolve_method": 3
      },
  1. Relaunch browser, open app menu => Settings => Brave Shields & privacy => Unstoppable Domains, it should still be Enabled

V. brave.ens.resolve_method

  1. Open app menu => Settings => Brave Shields & privacy => Ethereum Name Service, switch to Enabled
  2. Open brave://local-state, find resolve_method near ens, it should be
"ens": {
         "resolve_method": 3
      },
  1. Relaunch browser, open app menu => Settings => Brave Shields & privacy => Ethereum Name Service, it should still be Enabled

VI. brave.sns.resolve_method

  1. Open brave://flags => Enable Solana Name Service support => Enabled, relaunch browser
  2. Open app menu => Settings => Brave Shields & privacy => Solana Name Service, switch to Enabled
  3. Open brave://local-state, find resolve_method near sns, it should be
"sns": {
         "resolve_method": 3
      },
  1. Relaunch browser, open app menu => Settings => Brave Shields & privacy => Solana Name Service, it should still be Enabled

VII. brave.ens.offchain_resolve_method

  1. Open app menu => Settings => Brave Shields & privacy => Unstoppable Domains, switch ENS offchain lookup to Enabled
  2. Open brave://local-state, find resolve_method near unstoppable_domains, it should be
"ens": {
         "offchain_resolve_method": 2,
  1. Relaunch browser, open app menu => Settings => Brave Shields & privacy => Unstoppable Domains, ENS offchain lookup should still be Enabled

@github-actions github-actions bot added the potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false label Dec 28, 2022
@AlexeyBarabash AlexeyBarabash force-pushed the android_local_state branch 4 times, most recently from 429d2c7 to 188f850 Compare December 29, 2022 18:48
- BravePrefServiceBridge.setReferralAndroidFirstRunTimestamp;
- BravePrefServiceBridge.setReferralCheckedForPromoCodeFile;
- BravePrefServiceBridge.setReferralInitialization;
- BravePrefServiceBridge.setReferralPromoCode;
- BravePrefServiceBridge.setReferralDownloadId.
@AlexeyBarabash AlexeyBarabash marked this pull request as ready for review January 4, 2023 14:39
Copy link
Member

@SergeyZhukovsky SergeyZhukovsky left a comment

Choose a reason for hiding this comment

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

++

return BraveLocalStateJni.get().getPrefService();
}

/** Makes local state data be written to the disk asap */
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should not do this, the actual writing of prefs to disk should be left to the pref service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use PrefService Java class for local state prefs from BravePrefServiceBridge
3 participants