From 3ba3c43faaa7c8a1725f82e9d6225df9879f84ba Mon Sep 17 00:00:00 2001 From: Seungah Lim Date: Wed, 3 Feb 2021 13:17:41 +0900 Subject: [PATCH] request location based country detector in WiFi ON bug: 179272424 Change-Id: I665d7a19077a6a09f47f33d3927add9e561f9fce Signed-off-by: Seungah Lim --- .../countrydetector/ComprehensiveCountryDetector.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/location/countrydetector/ComprehensiveCountryDetector.java b/services/core/java/com/android/server/location/countrydetector/ComprehensiveCountryDetector.java index af3907e784327..dda502b2b9aad 100644 --- a/services/core/java/com/android/server/location/countrydetector/ComprehensiveCountryDetector.java +++ b/services/core/java/com/android/server/location/countrydetector/ComprehensiveCountryDetector.java @@ -320,13 +320,15 @@ public class ComprehensiveCountryDetector extends CountryDetectorBase { "(source: " + detectedCountry.getSource() + ", countryISO: " + detectedCountry.getCountryIso() + ")") + " isAirplaneModeOff()=" + isAirplaneModeOff() + + " isWifiOn()=" + isWifiOn() + " mListener=" + mListener + " isGeoCoderImplemnted()=" + isGeoCoderImplemented()); } if (startLocationBasedDetection && (detectedCountry == null || detectedCountry.getSource() > Country.COUNTRY_SOURCE_LOCATION) - && isAirplaneModeOff() && mListener != null && isGeoCoderImplemented()) { + && (isAirplaneModeOff() || isWifiOn()) && mListener != null + && isGeoCoderImplemented()) { if (DEBUG) Slog.d(TAG, "run startLocationBasedDetector()"); // Start finding location when the source is less reliable than the // location and the airplane mode is off (as geocoder will not @@ -387,6 +389,11 @@ public class ComprehensiveCountryDetector extends CountryDetectorBase { mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 0; } + protected boolean isWifiOn() { + return Settings.Global.getInt( + mContext.getContentResolver(), Settings.Global.WIFI_ON, 0) != 0; + } + /** * Notify the country change. */