diff options
Diffstat (limited to 'java/com/android/dialer/location')
-rw-r--r-- | java/com/android/dialer/location/CountryDetector.java | 12 | ||||
-rw-r--r-- | java/com/android/dialer/location/GeoUtil.java | 18 |
2 files changed, 7 insertions, 23 deletions
diff --git a/java/com/android/dialer/location/CountryDetector.java b/java/com/android/dialer/location/CountryDetector.java index a90febf2b..110cf4502 100644 --- a/java/com/android/dialer/location/CountryDetector.java +++ b/java/com/android/dialer/location/CountryDetector.java @@ -33,8 +33,8 @@ import android.telephony.TelephonyManager; import android.text.TextUtils; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutors; import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.util.PermissionsUtil; import java.util.List; import java.util.Locale; @@ -72,7 +72,7 @@ public class CountryDetector { // exceedingly rare event that the device does not have a default locale set for some reason. private static final String DEFAULT_COUNTRY_ISO = "US"; - @VisibleForTesting static CountryDetector sInstance; + @VisibleForTesting public static CountryDetector sInstance; private final TelephonyManager telephonyManager; private final LocaleProvider localeProvider; @@ -80,7 +80,7 @@ public class CountryDetector { private final Context appContext; @VisibleForTesting - CountryDetector( + public CountryDetector( Context appContext, TelephonyManager telephonyManager, LocationManager locationManager, @@ -192,7 +192,7 @@ public class CountryDetector { } /** Interface for accessing the current locale. */ - interface LocaleProvider { + public interface LocaleProvider { Locale getLocale(); } @@ -216,7 +216,9 @@ public class CountryDetector { private static void processLocationUpdate( Context appContext, Geocoder geocoder, Location location) { - DialerExecutors.createNonUiTaskBuilder(new GeocodeCountryWorker(geocoder)) + DialerExecutorComponent.get(appContext) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new GeocodeCountryWorker(geocoder)) .onSuccess( country -> { if (country == null) { diff --git a/java/com/android/dialer/location/GeoUtil.java b/java/com/android/dialer/location/GeoUtil.java index 1be40544d..b39256d32 100644 --- a/java/com/android/dialer/location/GeoUtil.java +++ b/java/com/android/dialer/location/GeoUtil.java @@ -17,11 +17,6 @@ package com.android.dialer.location; import android.content.Context; -import com.google.i18n.phonenumbers.NumberParseException; -import com.google.i18n.phonenumbers.PhoneNumberUtil; -import com.google.i18n.phonenumbers.Phonenumber; -import com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder; -import java.util.Locale; /** Static methods related to Geo. */ public class GeoUtil { @@ -31,17 +26,4 @@ public class GeoUtil { // The {@link CountryDetector} should never return null so this is safe to return as-is. return CountryDetector.getInstance(context).getCurrentCountryIso(); } - - public static String getGeocodedLocationFor(Context context, String phoneNumber) { - final PhoneNumberOfflineGeocoder geocoder = PhoneNumberOfflineGeocoder.getInstance(); - final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); - try { - final Phonenumber.PhoneNumber structuredPhoneNumber = - phoneNumberUtil.parse(phoneNumber, getCurrentCountryIso(context)); - final Locale locale = context.getResources().getConfiguration().locale; - return geocoder.getDescriptionForNumber(structuredPhoneNumber, locale); - } catch (NumberParseException e) { - return null; - } - } } |