Search in sources :

Example 66 with Country

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

the class CountryDetectorServiceTest method testNotifyListeners.

public void testNotifyListeners() throws RemoteException {
    CountryDetectorServiceTester serviceTester = new CountryDetectorServiceTester(getContext());
    CountryListenerTester listenerTesterA = new CountryListenerTester();
    CountryListenerTester listenerTesterB = new CountryListenerTester();
    Country country = new Country("US", Country.COUNTRY_SOURCE_NETWORK);
    serviceTester.systemRunning();
    waitForSystemReady(serviceTester);
    serviceTester.addCountryListener(listenerTesterA);
    serviceTester.addCountryListener(listenerTesterB);
    serviceTester.notifyReceivers(country);
    assertTrue(serviceTester.isListenerSet());
    assertTrue(listenerTesterA.isNotified());
    assertTrue(listenerTesterB.isNotified());
    serviceTester.removeCountryListener(listenerTesterA);
    serviceTester.removeCountryListener(listenerTesterB);
    assertFalse(serviceTester.isListenerSet());
}
Also used : Country(android.location.Country)

Example 67 with Country

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

the class ComprehensiveCountryDetectorTest method testDetectNetworkBasedCountry.

public void testDetectNetworkBasedCountry() {
    final Country resultCountry = new Country(TestCountryDetector.COUNTRY_ISO, Country.COUNTRY_SOURCE_NETWORK);
    TestCountryDetector countryDetector = new TestCountryDetector() {

        @Override
        protected Country getNetworkBasedCountry() {
            return resultCountry;
        }
    };
    CountryListenerImpl listener = new CountryListenerImpl();
    countryDetector.setCountryListener(listener);
    Country country = countryDetector.detectCountry();
    assertTrue(sameCountry(country, resultCountry));
    assertFalse(listener.notified());
    assertFalse(countryDetector.locationBasedDetectorStarted());
    assertFalse(countryDetector.locationRefreshStarted());
    countryDetector.stop();
}
Also used : Country(android.location.Country)

Example 68 with Country

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

the class ComprehensiveCountryDetectorTest method testLocaleBasedCountry.

public void testLocaleBasedCountry() {
    final Country resultCountry = new Country(TestCountryDetector.COUNTRY_ISO, Country.COUNTRY_SOURCE_LOCALE);
    TestCountryDetector countryDetector = new TestCountryDetector() {

        @Override
        protected Country getLocaleCountry() {
            return resultCountry;
        }
    };
    CountryListenerImpl listener = new CountryListenerImpl();
    countryDetector.setCountryListener(listener);
    Country country = countryDetector.detectCountry();
    assertTrue(sameCountry(country, resultCountry));
    assertFalse(listener.notified());
    assertTrue(countryDetector.locationBasedDetectorStarted());
    assertTrue(countryDetector.locationRefreshStarted());
    countryDetector.stop();
    assertTrue(countryDetector.locationRefreshCancelled());
}
Also used : Country(android.location.Country)

Example 69 with Country

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

the class ComprehensiveCountryDetectorTest method testNoCountryFound.

public void testNoCountryFound() {
    TestCountryDetector countryDetector = new TestCountryDetector();
    CountryListenerImpl listener = new CountryListenerImpl();
    countryDetector.setCountryListener(listener);
    Country country = countryDetector.detectCountry();
    assertTrue(sameCountry(country, null));
    assertTrue(countryDetector.locationBasedDetectorStarted());
    countryDetector.notifyLocationBasedListener(null);
    assertFalse(listener.notified());
    assertTrue(sameCountry(listener.getCountry(), null));
    assertTrue(countryDetector.locationBasedDetectorStopped());
    assertTrue(countryDetector.locationRefreshStarted());
    countryDetector.stop();
    assertTrue(countryDetector.locationRefreshCancelled());
}
Also used : Country(android.location.Country)

Example 70 with Country

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

the class ComprehensiveCountryDetectorTest method testLocationBasedCountryNotFound.

public void testLocationBasedCountryNotFound() {
    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.notifyLocationBasedListener(null);
    assertFalse(listener.notified());
    assertTrue(sameCountry(listener.getCountry(), null));
    assertTrue(countryDetector.locationBasedDetectorStopped());
    assertTrue(countryDetector.locationRefreshStarted());
    countryDetector.stop();
    assertTrue(countryDetector.locationRefreshCancelled());
}
Also used : 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