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

Advanced server selection follow up android #25604

Merged
merged 5 commits into from
Sep 19, 2024

Conversation

deeppandya
Copy link
Contributor

@deeppandya deeppandya commented Sep 17, 2024

Resolves brave/brave-browser#41106
Resolves brave/brave-browser#41477

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 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 this to the 1.72.x - Nightly milestone Sep 17, 2024
@deeppandya deeppandya self-assigned this Sep 17, 2024
@deeppandya deeppandya changed the title Advanced server selection follow up android [WIP]Advanced server selection follow up android Sep 17, 2024
@@ -94,6 +96,9 @@ mojom::RegionPtr GetRegionFromValueWithoutCity(const base::Value::Dict& value) {
if (auto* name_pretty = value.FindString(brave_vpn::kRegionNamePrettyKey)) {
region->name_pretty = *name_pretty;
}
if (auto* country = value.FindString(brave_vpn::kRegionCountryKey)) {
region->country = *country;
Copy link
Member

Choose a reason for hiding this comment

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

Curious what this data has and destkop also needs changes with this new property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a suggestion from the guardian team to persist the country and continent to use it for region selection to avoid future migration.

Copy link
Member

@simonhong simonhong Sep 19, 2024

Choose a reason for hiding this comment

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

country has country name? and then maybe desktop also need to use this property for country name instead of name_pretty?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, ok. I saw it from region-list.ts. It has country name.
I'll f/u to replace it with namePretty on desktop.

@deeppandya deeppandya force-pushed the advanced_server_selection_follow_up_android branch from cacbacf to 80aa94e Compare September 18, 2024 11:59
@github-actions github-actions bot added the CI/storybook-url Deploy storybook and provide a unique URL for each build label Sep 18, 2024
@deeppandya deeppandya marked this pull request as ready for review September 18, 2024 12:01
@deeppandya deeppandya changed the title [WIP]Advanced server selection follow up android Advanced server selection follow up android Sep 18, 2024
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@@ -131,12 +131,18 @@ public void prepareMenu(Menu menu, AppMenuHandler handler) {
menu.findItem(R.id.request_vpn_location_row_menu_id).getSubMenu();
MenuItem vpnLocationSubMenuItem =
vpnLocationSubMenu.findItem(R.id.request_vpn_location_id);
String isoCode = BraveVpnPrefUtils.getRegionIsoCode();
String country =
(!BraveVpnPrefUtils.getRegionCountry().equals("")
Copy link
Member

Choose a reason for hiding this comment

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

why are there brackets at the beginning and at the end?

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.

++

@deeppandya deeppandya force-pushed the advanced_server_selection_follow_up_android branch from 80aa94e to 32acb34 Compare September 18, 2024 19:38
Copy link
Contributor

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

Description

This PR makes significant changes to the Brave VPN functionality, particularly in how server regions are handled and displayed. It modifies several Java files in the Android app and updates the data model for VPN regions.

Changes

Changes

  1. BraveTabbedAppMenuPropertiesDelegate.java:

    • Added import for java.util.Locale
    • Modified how the VPN location is displayed, now using the country name instead of a "pretty" name
    • Added fallback to use Locale.getDisplayCountry() if the country name is not available
  2. VpnServerActivity.java:

    • Updated the BraveVpnServerRegion constructor call with new parameters
    • Changed how the selected server region is set, now including more detailed information like country and continent
  3. VpnServerSelectionActivity.java:

    • Modified the BraveVpnServerRegion constructor call for automatic server selection
    • Removed the call to BraveVpnPrefUtils.setAutomaticServerSelection()
  4. BraveVpnServerSelectionAdapter.java:

    • Changed the condition for checking if a server is selected, now comparing ISO codes instead of region names
  5. VpnServerAdapter.java:

    • Significantly updated the logic for determining if a server is enabled
    • Added checks for country and city precision
  6. BraveVpnServerRegion.java:

    • Added new fields: mIsAutoSelected, mCountry, and mContinent
    • Removed mRegionCityName and mRegionCityNamePretty
    • Updated constructor and getter methods accordingly
  7. BraveVpnPrefUtils.java:

    • Added new methods for getting and setting region country and continent
    • Removed methods related to city name and city name pretty
    • Updated setPrefModel() method to reflect new BraveVpnServerRegion structure
  8. BraveVpnRegionDataHelper.cc:

    • Added country field to the region dictionary
  9. brave_vpn_constants.h:

    • Added a new constant kRegionCountryKey
  10. brave_vpn.mojom:

    • Added country field to the Region struct
  11. region-list.ts:

    • Added country field to all region and city objects in the mock data

Possible Issues

  • The removal of setAutomaticServerSelection() in VpnServerSelectionActivity.java might affect the automatic server selection feature if it's not handled elsewhere.
  • The changes in how regions are compared and selected might cause unexpected behavior if not all parts of the codebase are updated consistently.

Security Hotspots

None identified. The changes appear to be primarily related to data structure and UI updates, without introducing apparent security risks.

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

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

components/brave_vpn/ ++

@deeppandya deeppandya merged commit 88bf0b8 into master Sep 19, 2024
17 checks passed
@deeppandya deeppandya deleted the advanced_server_selection_follow_up_android branch September 19, 2024 12:51
brave-builds added a commit that referenced this pull request Sep 19, 2024
@hffvld
Copy link
Collaborator

hffvld commented Oct 10, 2024

Verified on Pixel 7 using version(s):

Device/OS: Pixel 7 / panther_beta-user 15 AP41.240823.009 release-keys
Brave build: 1.72.66 
Chromium: 130.0.6723.31 (Official Build) canary (64-bit) 

Filed follow-up issue #41557

"Automatic" server location

STEPS:

  1. Buy an IAP subscription on a fresh profile
  2. Create a VPN profile
  3. Turn on VPN
  4. Go to the Server selection page
  5. Verify that Automatic must be selected

ACTUAL RESULTS:

  • Verified that Automatic location is selected by default when enabling VPN

1 2 3
1 2 3
1 2 3
"Optimal" server location from the selected region

STEPS:

  1. Go to Server selection page
  2. Disable Automatic toggle switch > Verify that your region (USA in my case) is selected by default
  3. Select the USA as a region
  4. On the next page, select Optimal
  5. Verify that the Best server location would be selected and it could give a different location based on the available resources on the location at the time

ACTUAL RESULTS:

  • Verified that your region (USA in my case) is selected by default after disabling the Automatic toggle switch.
  • Verified that the Best server location must be selected when tapping on Optimal, and it could give a different location based on the available resources at the time.

1 2 3
1 2 3
1 2 3
"Specific" server selection

STEPS:

  1. Go to Server selection page
  2. Select the USA as a region
  3. On the next page, select Atlanta
  4. Verify that Atlanta must be selected as server location

ACTUAL RESULTS:

  • Verified that a specific city/server must be selected as server location when tapping the city name.

1 2 3 4
1 2 3 4
"Upgrade" scenario

STEPS:

  1. Install and launch Brave 1.70.32 > Purchase/enable VPN
  2. Upgrade Brave to 1.72.66 > Enable VPN > Go to the Server selection page
  3. Verify that the Selected region from the previous version must be selected in the new UI
  4. Tap on the region
  5. Verify that Optimal must be selected as we didn't have a granular details from the previous version. A new version of the app would follow the new changes moving forward.

ACTUAL RESULTS:

  • Verified that Automatic is NOT selected after Brave upgrade.
  • Verified that the previously selected region is still selected after Brave upgrade.
  • Verified that the Optimal server location is selected by default after Brave upgrade as we didn't have granular details from the previous version. A new version of the app would follow the new changes moving forward.
  • Verified that multiple radio buttons can't be selected at the same time

Before upgrade After upgrade
1 2
1 2
1 2
1 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/storybook-url Deploy storybook and provide a unique URL for each build puLL-Merge
Projects
None yet
5 participants