summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/setupwizard/setup
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/cyanogenmod/setupwizard/setup')
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/WelcomePage.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
index 248420e..568f8f2 100644
--- a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
@@ -30,6 +30,8 @@ import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
@@ -37,6 +39,7 @@ import android.widget.ArrayAdapter;
import android.widget.NumberPicker;
import android.widget.Toast;
+import com.android.internal.telephony.MccTable;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
@@ -44,6 +47,7 @@ import com.cyanogenmod.setupwizard.ui.LocalePicker;
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
+import java.util.List;
import java.util.Locale;
public class WelcomePage extends SetupPage {
@@ -285,16 +289,34 @@ public class WelcomePage extends SetupPage {
private class FetchUpdateSimLocaleTask extends AsyncTask<Void, Void, Locale> {
@Override
protected Locale doInBackground(Void... params) {
+ Locale locale = null;
Activity activity = getActivity();
if (activity != null) {
- TelephonyManager telephonyManager = (TelephonyManager) activity.
- getSystemService(Context.TELEPHONY_SERVICE);
- String locale = telephonyManager.getLocaleFromDefaultSim();
- if (locale != null) {
- return Locale.forLanguageTag(locale);
+ final SubscriptionManager subscriptionManager =
+ SubscriptionManager.from(activity);
+ List<SubscriptionInfo> activeSubs =
+ subscriptionManager.getActiveSubscriptionInfoList();
+ if (activeSubs == null || activeSubs.isEmpty()) {
+ return null;
+ }
+
+ // Fetch locale for active sim's MCC
+ int mcc = activeSubs.get(0).getMcc();
+ locale = MccTable.getLocaleFromMcc(activity, mcc, null);
+
+ // If that fails, fall back to preferred languages reported
+ // by the sim
+ if (locale == null) {
+ TelephonyManager telephonyManager = (TelephonyManager) activity.
+ getSystemService(Context.TELEPHONY_SERVICE);
+ String localeString = telephonyManager.getLocaleFromDefaultSim();
+ if (localeString != null) {
+ locale = Locale.forLanguageTag(localeString);
+
+ }
}
}
- return null;
+ return locale;
}
@Override