Search in sources :

Example 6 with Country

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

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 7 with Country

use of android.location.Country in project qksms by moezbhatti.

the class QKSMSAppBase method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    if (Log.isLoggable(LogTag.STRICT_MODE_TAG, Log.DEBUG)) {
        // Log tag for enabling/disabling StrictMode violation log. This will dump a stack
        // in the log that shows the StrictMode violator.
        // To enable: adb shell setprop log.tag.Mms:strictmode DEBUG
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
    }
    sQKSMSApp = this;
    loadDefaultPreferenceValues();
    // Initialize analytics, leakcanary, and crittercism
    AnalyticsManager.getInstance().init(this);
    refWatcher = LeakCanary.install(this);
    // Figure out the country *before* loading contacts and formatting numbers
    Country country = new Country(Locale.getDefault().getCountry(), Country.COUNTRY_SOURCE_LOCALE);
    mCountryIso = country.getCountryIso();
    Context context = getApplicationContext();
    mPduLoaderManager = new PduLoaderManager(context);
    mThumbnailManager = new ThumbnailManager(context);
    registerActivityLifecycleCallbacks(new LifecycleHandler());
    ThemeManager.init(this);
    MmsConfig.init(this);
    Contact.init(this);
    DraftCache.init(this);
    Conversation.init(this);
    DownloadManager.init(this);
    RateController.init(this);
    LayoutManager.init(this);
    NotificationManager.init(this);
    LiveViewManager.init(this);
    QKPreferences.init(this);
    activePendingMessages();
}
Also used : Context(android.content.Context) StrictMode(android.os.StrictMode) ThumbnailManager(com.moez.QKSMS.common.google.ThumbnailManager) LifecycleHandler(com.moez.QKSMS.common.LifecycleHandler) Country(android.location.Country) PduLoaderManager(com.moez.QKSMS.common.google.PduLoaderManager)

Example 8 with Country

use of android.location.Country in project platform_frameworks_base by android.

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 9 with Country

use of android.location.Country in project platform_frameworks_base by android.

the class LocationBasedCountryDetector method queryCountryCode.

/**
     * Start a new thread to query the country from Geocoder.
     */
private synchronized void queryCountryCode(final Location location) {
    if (location == null) {
        notifyListener(null);
        return;
    }
    if (mQueryThread != null)
        return;
    mQueryThread = new Thread(new Runnable() {

        @Override
        public void run() {
            String countryIso = null;
            if (location != null) {
                countryIso = getCountryFromLocation(location);
            }
            if (countryIso != null) {
                mDetectedCountry = new Country(countryIso, Country.COUNTRY_SOURCE_LOCATION);
            } else {
                mDetectedCountry = null;
            }
            notifyListener(mDetectedCountry);
            mQueryThread = null;
        }
    });
    mQueryThread.start();
}
Also used : Country(android.location.Country)

Example 10 with Country

use of android.location.Country in project platform_frameworks_base by android.

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