/*
 * Derived from com.android.mms.MmsApp
 * (tag android-4.4.4_r2.0.1)
 */

package ca.bmaupin.merge.sms;

import android.app.Application;
import android.content.Context;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.util.Log;

public class MmsApp extends Application {
	private static MmsApp sMmsApp = null;
	
    @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());
        }

        sMmsApp = this;
    }
	
    synchronized public static MmsApp getApplication() {
        return sMmsApp;
    }
}

@@ -184,21 +184,24 @@
 oid.
-os.StrictMode
+location.Country
 ;%0Aim
@@ -217,105 +217,293 @@
 oid.
-preference.PreferenceManager;%0Aimport android.util.Log;%0A%0Apublic class MmsApp extends Application %7B
+location.CountryDetector;%0Aimport android.location.CountryListener;%0Aimport android.os.StrictMode;%0Aimport android.util.Log;%0A%0Apublic class MmsApp extends Application %7B%0A    private CountryDetector mCountryDetector;%0A    private CountryListener mCountryListener;%0A%09private String mCountryIso;
 %0A%09pr
@@ -1081,91 +1081,1035 @@
     
-%7D%0A%09%0A    synchronized public static MmsApp getApplication() %7B%0A        return sMmsApp
+    %0A        // Figure out the country *before* loading contacts and formatting numbers%0A        mCountryDetector = (CountryDetector) getSystemService(Context.COUNTRY_DETECTOR);%0A        mCountryListener = new CountryListener() %7B%0A            @Override%0A            public synchronized void onCountryDetected(Country country) %7B%0A                mCountryIso = country.getCountryIso();%0A            %7D%0A        %7D;%0A        mCountryDetector.addCountryListener(mCountryListener, getMainLooper());%0A    %7D%0A%09%0A    synchronized public static MmsApp getApplication() %7B%0A        return sMmsApp;%0A    %7D%0A    %0A    @Override%0A    public void onTerminate() %7B%0A        mCountryDetector.removeCountryListener(mCountryListener);%0A    %7D%0A    %0A    // This function CAN return null.%0A    public String getCurrentCountryIso() %7B%0A        if (mCountryIso == null) %7B%0A            Country country = mCountryDetector.detectCountry();%0A            if (country != null) %7B%0A                mCountryIso = country.getCountryIso();%0A            %7D%0A        %7D%0A        return mCountryIso
 ;%0A  

Add dependencies for Contact