Skip to content

Commit

Permalink
Uplift of #26210 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Oct 25, 2024
1 parent c446320 commit 0868120
Showing 1 changed file with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import org.chromium.brave_vpn.mojom.BraveVpnConstants;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.billing.InAppPurchaseWrapper;
import org.chromium.chrome.browser.billing.PurchaseModel;
Expand Down Expand Up @@ -65,31 +66,37 @@ public static void handleOnGetTimezonesForRegions(Activity activity,
BraveVpnServerRegion braveVpnServerRegion =
BraveVpnUtils.getServerRegionForTimeZone(
jsonTimezones, TimeZone.getDefault().getID());
String region = braveVpnServerRegion.getRegionName();
if (TextUtils.isEmpty(region)) {
String regionFromTimeZone = braveVpnServerRegion.getRegionName();
if (TextUtils.isEmpty(regionFromTimeZone)) {
BraveVpnUtils.showToast(
String.format(
activity.getResources()
.getString(R.string.couldnt_get_matching_timezone),
TimeZone.getDefault().getID()));
return;
}
if (BraveVpnUtils.selectedServerRegion != null) {
if (!BraveVpnUtils.selectedServerRegion
.getRegionName()
.equals(BraveVpnPrefUtils.PREF_BRAVE_VPN_AUTOMATIC)) {
region = BraveVpnUtils.selectedServerRegion.getRegionName();
braveVpnServerRegion = BraveVpnUtils.selectedServerRegion;
}
String regionForHostName = regionFromTimeZone;
String regionPrecision = braveVpnServerRegion.getRegionPrecision();

// Determine the region for host name and precision
if (BraveVpnUtils.selectedServerRegion != null
&& !BraveVpnUtils.selectedServerRegion
.getRegionName()
.equals(BraveVpnPrefUtils.PREF_BRAVE_VPN_AUTOMATIC)) {

regionForHostName = BraveVpnUtils.selectedServerRegion.getRegionName();
braveVpnServerRegion = BraveVpnUtils.selectedServerRegion;
regionPrecision = braveVpnServerRegion.getRegionPrecision();
} else {
String serverRegion = BraveVpnPrefUtils.getRegionName();
region =
serverRegion.equals(BraveVpnPrefUtils.PREF_BRAVE_VPN_AUTOMATIC)
? region
: serverRegion;
if (serverRegion.equals(BraveVpnPrefUtils.PREF_BRAVE_VPN_AUTOMATIC)) {
regionPrecision = BraveVpnConstants.REGION_PRECISION_DEFAULT;
} else {
regionForHostName = serverRegion;
}
}
BraveVpnNativeWorker.getInstance()
.getHostnamesForRegion(region, braveVpnServerRegion.getRegionPrecision());
.getHostnamesForRegion(regionForHostName, regionPrecision);
braveVpnPrefModel.setServerRegion(braveVpnServerRegion);
} else {
BraveVpnUtils.showToast(
Expand Down

0 comments on commit 0868120

Please sign in to comment.