Home | History | Annotate | Download | only in location

Lines Matching refs:country

20 import android.location.Country;
37 * This class is used to detect the country where the user is. The sources of
38 * country are queried in order of reliability, like
42 * <li>SIM's country</li>
46 * Call the {@link #detectCountry()} to get the available country immediately.
48 * To be notified of the future country change, using the
51 * Using the {@link #stop()} to stop listening to the country change.
53 * The country information will be refreshed every
54 * {@link #LOCATION_REFRESH_INTERVAL} once the location based country is used.
69 * The refresh interval when the location based country was used
76 private Country mCountry;
78 private Country mCountryFromLocation;
84 * List of the most recent country state changes for debugging. This should have
87 private final ConcurrentLinkedQueue<Country> mDebugLogs = new ConcurrentLinkedQueue<Country>();
90 * Most recent {@link Country} result that was added to the debug logs {@link #mDebugLogs}.
91 * We keep track of this value to help prevent adding many of the same {@link Country} objects
94 private Country mLastCountryAddedToLogs;
134 public void onCountryDetected(Country country) {
135 if (DEBUG) Slog.d(TAG, "Country detected via LocationBasedCountryDetector");
136 mCountryFromLocation = country;
149 public Country detectCountry() {
166 * Get the country from different sources in order of the reliability.
168 private Country getCountry() {
169 Country result = null;
185 * Attempt to add this {@link Country} to the debug logs.
187 private void addToLogs(Country country) {
188 if (country == null) {
191 // If the country (ISO and source) are the same as before, then there is no
192 // need to add this country as another entry in the logs. Synchronize access to this
195 if (mLastCountryAddedToLogs != null && mLastCountryAddedToLogs.equals(country)) {
198 mLastCountryAddedToLogs = country;
205 Slog.d(TAG, country.toString());
207 mDebugLogs.add(country);
211 // On CDMA TelephonyManager.getNetworkCountryIso() just returns SIM country. We don't want
212 // to prioritize it over location based country, so ignore it.
219 * @return the country from the mobile network.
221 protected Country getNetworkBasedCountry() {
226 return new Country(countryIso, Country.COUNTRY_SOURCE_NETWORK);
233 * @return the cached location based country.
235 protected Country getLastKnownLocationBasedCountry() {
240 * @return the country from SIM card
242 protected Country getSimBasedCountry() {
246 return new Country(countryIso, Country.COUNTRY_SOURCE_SIM);
252 * @return the country from the system's locale.
254 protected Country getLocaleCountry() {
257 return new Country(defaultLocale.getCountry(), Country.COUNTRY_SOURCE_LOCALE);
265 * country
267 * be started if the current country source is less reliable than the location.
270 private Country detectCountry(boolean notifyChange, boolean startLocationBasedDetection) {
271 Country country = getCountry();
272 runAfterDetectionAsync(mCountry != null ? new Country(mCountry) : mCountry, country,
274 mCountry = country;
281 protected void runAfterDetectionAsync(final Country country, final Country detectedCountry,
287 country, detectedCountry, notifyChange, startLocationBasedDetection);
312 void runAfterDetection(final Country country, final Country detectedCountry,
315 notifyIfCountryChanged(country, detectedCountry);
328 || detectedCountry.getSource() > Country.COUNTRY_SOURCE_LOCATION)
339 || detectedCountry.getSource() >= Country.COUNTRY_SOURCE_LOCATION) {
340 // Schedule the location refresh if the country source is
341 // not more reliable than the location or no country is
344 // and start detecting the country.
355 * Find the country from LocationProvider.
362 Slog.d(TAG, "starts LocationBasedDetector to detect Country code via Location info "
391 * Notify the country change.
393 private void notifyIfCountryChanged(final Country country, final Country detectedCountry) {
395 && (country == null || !country.equals(detectedCountry))) {
397 Slog.d(TAG, "" + country + " --> " + detectedCountry);
417 Slog.d(TAG, "periodic location refresh event. Starts detecting Country code");
485 for (Country country : mDebugLogs) {
486 sb.append("\n " + country.toString());