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

Remove rewards onboarding icon #21455

Merged
merged 2 commits into from
Jan 15, 2024
Merged

Conversation

deeppandya
Copy link
Contributor

Resolves brave/brave-browser#33922

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • 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:

@deeppandya deeppandya added CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-ios Do not run CI builds for iOS CI/skip-windows-x64 Do not run CI builds for Windows x64 unused-CI/skip-linux-x64 Do not run CI builds for Linux x64 labels Dec 22, 2023
@deeppandya deeppandya added this to the 1.63.x - Nightly milestone Dec 22, 2023
@deeppandya deeppandya self-assigned this Dec 22, 2023
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.

++

Copy link
Contributor

@tapanmodh tapanmodh left a comment

Choose a reason for hiding this comment

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

lgtm

@deeppandya deeppandya force-pushed the remove_rewards_onboarding_icon branch from 5e66125 to 067685a Compare January 12, 2024 09:27
@deeppandya deeppandya force-pushed the remove_rewards_onboarding_icon branch from 067685a to 48d3607 Compare January 14, 2024 19:01
Copy link
Contributor

[puLL-Merge] - brave/brave-core@21455

Description

This pull request seems to modify how the Brave browser app handles user preferences, particularly with regard to the Brave Rewards feature. It appears to swap out the usage of SharedPreferences in favor of a new ChromeSharedPreferences mechanism. Additionally, it adds logic related to the timing and visibility of the Brave Rewards onboarding icon, and it contains a few minor cleanups and refactors.

Changes

Changes

android/java/org/chromium/chrome/browser/BraveRewardsHelper.java

  • Moved from SharedPreferences to ChromeSharedPreferences for persisting reward-related preferences.
  • Added constants for new preference keys (PREF_REWARDS_ONBOARDING_ICON_TIMING, PREF_REWARDS_ONBOARDING_ICON_INVISIBLE_TIMING, PREF_REWARDS_ONBOARDING_ICON_INVISIBLE).
  • Refactored resetRewards() and other methods to use ChromeSharedPreferences.
  • Added new methods for getting and setting the new preference values related to onboarding icon timing and visibility (getRewardsOnboardingIconTiming(), setRewardsOnboardingIconTiming() etc.).
  • Refactor of the LargeIconBridge object to use a static instance sLargeIconBridge.
  • Added helper methods createIconGeneratorWithFallbackColor() and scheduleIconRetrievalWithDelay() to improve code readability.

android/java/org/chromium/chrome/browser/app/BraveActivity.java

  • Introduced the isFirstInstall local variable to cache the result of the PackageUtils.isFirstInstall(this) call.
  • Made use of the isFirstInstall variable throughout the file to simplify checks.
  • Added a constant DAYS_7.
  • In the finishNativeInitialization() method, added logic to set the PREF_REWARDS_ONBOARDING_ICON_TIMING if it's the first install and the BRAVE_APP_OPEN_COUNT is 1.

android/java/org/chromium/chrome/browser/toolbar/top/BraveToolbarLayoutImpl.java

  • Replaced the usage of SharedPreferences with ChromeSharedPreferences.
  • Added a constant DAYS_7.
  • In onNativeLibraryReady(), simplified the conditional statement that checks for showing the Brave Rewards icon using ChromeSharedPreferences.
  • In OnNotificationsCount(), now checks if the current time is beyond the value set in getRewardsOnboardingIconTiming() to decide whether to show the onboarding icon.
  • Added logic to update PREF_REWARDS_ONBOARDING_ICON_INVISIBLE_TIMING and PREF_REWARDS_ONBOARDING_ICON_INVISIBLE if necessary.

Security Hotspots

  1. Preference Data Exposure Risk: Changing how preferences are stored and retrieved can potentially expose sensitive data if not done correctly. Review the new ChromeSharedPreferences implementation to ensure it offers the same or improved security over the previously used SharedPreferences, in terms of data access and encryption at rest.

  2. Static Usage of LargeIconBridge: The switch from an instance variable mLargeIconBridge to a static sLargeIconBridge could lead to potential resource leaks or unintended sharing of state across different parts of the app if not managed correctly. It is therefore important to ensure that this shared state is being appropriately handled during the lifecycle of the app.

  3. Reward Timing Logic: The new logic introduced to control the timing and visibility of the Brave Rewards onboarding icon uses system time (System.currentTimeMillis()) and adds to it (calender.add(Calendar.DATE, DAYS_7)). It's essential to verify that manipulating system time does not introduce ways to exploit the application behavior for rewards, such as by artificially manipulating the device's clock to affect the rewards timing.

  4. Onboarding Modal Logic Changes: Any modifications in the login sequence, such as onboarding modals, require careful review to ensure new edge cases or logical errors haven't been introduced.

  5. Data Validation: The new logic for the Brave Rewards helper should ensure that timing values (such as nextDate in setRewardsOnboardingIconTiming()) are validated before use to protect against potential integer overflow or other data-related issues.

@deeppandya deeppandya merged commit 8ba5bf7 into master Jan 15, 2024
18 checks passed
@deeppandya deeppandya deleted the remove_rewards_onboarding_icon branch January 15, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-ios Do not run CI builds for iOS CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-windows-x64 Do not run CI builds for Windows x64 puLL-Merge unused-CI/skip-linux-x64 Do not run CI builds for Linux x64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove ? from the BAT icon
3 participants