Home | History | Annotate | Download | only in location

Lines Matching refs:country

20 import android.location.Country;
38 * This class is used to detect the country where the user is. The sources of
39 * country are queried in order of reliability, like
43 * <li>SIM's country</li>
47 * Call the {@link #detectCountry()} to get the available country immediately.
49 * To be notified of the future country change, using the
52 * Using the {@link #stop()} to stop listening to the country change.
54 * The country information will be refreshed every
55 * {@link #LOCATION_REFRESH_INTERVAL} once the location based country is used.
70 * The refresh interval when the location based country was used
77 private Country mCountry;
79 private Country mCountryFromLocation;
85 * List of the most recent country state changes for debugging. This should have
88 private final ConcurrentLinkedQueue<Country> mDebugLogs = new ConcurrentLinkedQueue<Country>();
91 * Most recent {@link Country} result that was added to the debug logs {@link #mDebugLogs}.
92 * We keep track of this value to help prevent adding many of the same {@link Country} objects
95 private Country mLastCountryAddedToLogs;
135 public void onCountryDetected(Country country) {
136 if (DEBUG) Slog.d(TAG, "Country detected via LocationBasedCountryDetector");
137 mCountryFromLocation = country;
150 public Country detectCountry() {
167 * Get the country from different sources in order of the reliability.
169 private Country getCountry() {
170 Country result = null;
186 * Attempt to add this {@link Country} to the debug logs.
188 private void addToLogs(Country country) {
189 if (country == null) {
192 // If the country (ISO and source) are the same as before, then there is no
193 // need to add this country as another entry in the logs. Synchronize access to this
196 if (mLastCountryAddedToLogs != null && mLastCountryAddedToLogs.equals(country)) {
199 mLastCountryAddedToLogs = country;
206 Slog.d(TAG, country.toString());
208 mDebugLogs.add(country);
212 // On CDMA TelephonyManager.getNetworkCountryIso() just returns SIM country. We don't want
213 // to prioritize it over location based country, so ignore it.
220 * @return the country from the mobile network.
222 protected Country getNetworkBasedCountry() {
227 return new Country(countryIso, Country.COUNTRY_SOURCE_NETWORK);
234 * @return the cached location based country.
236 protected Country getLastKnownLocationBasedCountry() {
241 * @return the country from SIM card
243 protected Country getSimBasedCountry() {
247 return new Country(countryIso, Country.COUNTRY_SOURCE_SIM);
253 * @return the country from the system's locale.
255 protected Country getLocaleCountry() {
258 return new Country(defaultLocale.getCountry(), Country.COUNTRY_SOURCE_LOCALE);
266 * country
268 * be started if the current country source is less reliable than the location.
271 private Country detectCountry(boolean notifyChange, boolean startLocationBasedDetection) {
272 Country country = getCountry();
273 runAfterDetectionAsync(mCountry != null ? new Country(mCountry) : mCountry, country,
275 mCountry = country;
282 protected void runAfterDetectionAsync(final Country country, final Country detectedCountry,
288 country, detectedCountry, notifyChange, startLocationBasedDetection);
313 void runAfterDetection(final Country country, final Country detectedCountry,
316 notifyIfCountryChanged(country, detectedCountry);
329 || detectedCountry.getSource() > Country.COUNTRY_SOURCE_LOCATION)
340 || detectedCountry.getSource() >= Country.COUNTRY_SOURCE_LOCATION) {
341 // Schedule the location refresh if the country source is
342 // not more reliable than the location or no country is
345 // and start detecting the country.
356 * Find the country from LocationProvider.
363 Slog.d(TAG, "starts LocationBasedDetector to detect Country code via Location info "
392 * Notify the country change.
394 private void notifyIfCountryChanged(final Country country, final Country detectedCountry) {
396 && (country == null || !country.equals(detectedCountry))) {
398 Slog.d(TAG, "" + country + " --> " + detectedCountry);
418 Slog.d(TAG, "periodic location refresh event. Starts detecting Country code");
486 for (Country country : mDebugLogs) {
487 sb.append("\n " + country.toString());