Search in sources :

Example 36 with Country

use of android.location.Country in project android_frameworks_base by crdroidandroid.

the class ComprehensiveCountryDetectorTest method testStoppingDetector.

public void testStoppingDetector() {
    // Test stopping detector when LocationBasedCountryDetector was started
    final Country resultCountry = new Country(TestCountryDetector.COUNTRY_ISO, Country.COUNTRY_SOURCE_SIM);
    TestCountryDetector countryDetector = new TestCountryDetector() {

        @Override
        protected Country getSimBasedCountry() {
            return resultCountry;
        }
    };
    CountryListenerImpl listener = new CountryListenerImpl();
    countryDetector.setCountryListener(listener);
    Country country = countryDetector.detectCountry();
    assertTrue(sameCountry(country, resultCountry));
    assertTrue(countryDetector.locationBasedDetectorStarted());
    countryDetector.stop();
    // The LocationBasedDetector should be stopped.
    assertTrue(countryDetector.locationBasedDetectorStopped());
    // The location refresh should not running.
    assertTrue(countryDetector.locationRefreshCancelled());
}
Also used : Country(android.location.Country)

Example 37 with Country

use of android.location.Country in project android_frameworks_base by AOSPA.

the class CountryDetectorService method initialize.

private void initialize() {
    mCountryDetector = new ComprehensiveCountryDetector(mContext);
    mLocationBasedDetectorListener = new CountryListener() {

        public void onCountryDetected(final Country country) {
            mHandler.post(new Runnable() {

                public void run() {
                    notifyReceivers(country);
                }
            });
        }
    };
}
Also used : ComprehensiveCountryDetector(com.android.server.location.ComprehensiveCountryDetector) ICountryListener(android.location.ICountryListener) CountryListener(android.location.CountryListener) Country(android.location.Country)

Example 38 with Country

use of android.location.Country in project android_frameworks_base by AOSPA.

the class ComprehensiveCountryDetector method getCountry.

/**
     * Get the country from different sources in order of the reliability.
     */
private Country getCountry() {
    Country result = null;
    result = getNetworkBasedCountry();
    if (result == null) {
        result = getLastKnownLocationBasedCountry();
    }
    if (result == null) {
        result = getSimBasedCountry();
    }
    if (result == null) {
        result = getLocaleCountry();
    }
    addToLogs(result);
    return result;
}
Also used : Country(android.location.Country)

Example 39 with Country

use of android.location.Country in project android_frameworks_base by AOSPA.

the class ComprehensiveCountryDetector method detectCountry.

/**
     * @param notifyChange indicates whether the listener should be notified the change of the
     * country
     * @param startLocationBasedDetection indicates whether the LocationBasedCountryDetector could
     * be started if the current country source is less reliable than the location.
     * @return the current available UserCountry
     */
private Country detectCountry(boolean notifyChange, boolean startLocationBasedDetection) {
    Country country = getCountry();
    runAfterDetectionAsync(mCountry != null ? new Country(mCountry) : mCountry, country, notifyChange, startLocationBasedDetection);
    mCountry = country;
    return mCountry;
}
Also used : Country(android.location.Country)

Example 40 with Country

use of android.location.Country in project android_frameworks_base by crdroidandroid.

the class CountryDetectorService method initialize.

private void initialize() {
    mCountryDetector = new ComprehensiveCountryDetector(mContext);
    mLocationBasedDetectorListener = new CountryListener() {

        public void onCountryDetected(final Country country) {
            mHandler.post(new Runnable() {

                public void run() {
                    notifyReceivers(country);
                }
            });
        }
    };
}
Also used : ComprehensiveCountryDetector(com.android.server.location.ComprehensiveCountryDetector) ICountryListener(android.location.ICountryListener) CountryListener(android.location.CountryListener) Country(android.location.Country)

Aggregations

Country (android.location.Country)71 CountryListener (android.location.CountryListener)6 ICountryListener (android.location.ICountryListener)6 ComprehensiveCountryDetector (com.android.server.location.ComprehensiveCountryDetector)6 CountryDetector (android.location.CountryDetector)4 Context (android.content.Context)1 StrictMode (android.os.StrictMode)1 LifecycleHandler (com.moez.QKSMS.common.LifecycleHandler)1 PduLoaderManager (com.moez.QKSMS.common.google.PduLoaderManager)1 ThumbnailManager (com.moez.QKSMS.common.google.ThumbnailManager)1