use of android.location.Country in project android_frameworks_base by ParanoidAndroid.
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());
}
use of android.location.Country in project qksms by moezbhatti.
the class QKSMSAppBase method getCurrentCountryIso.
// This function CAN return null.
public String getCurrentCountryIso() {
if (mCountryIso == null) {
Country country = new Country(Locale.getDefault().getCountry(), Country.COUNTRY_SOURCE_LOCALE);
mCountryIso = country.getCountryIso();
}
return mCountryIso;
}
use of android.location.Country in project platform_frameworks_base by android.
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());
}
use of android.location.Country in project platform_frameworks_base by android.
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();
}
use of android.location.Country in project platform_frameworks_base by android.
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());
}
Aggregations