summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2016-02-02 23:03:19 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-02-03 16:25:26 -0800
commitd6b937a5676f6c1319f057d11bc7758c6c49aa2b (patch)
tree4ea12b5c874f015af6117fd52232fecb773be2ee /src
parent228ffe700a0754f180e51b24c447655daa1a7286 (diff)
downloadpackages_apps_SetupWizard-d6b937a5676f6c1319f057d11bc7758c6c49aa2b.zip
packages_apps_SetupWizard-d6b937a5676f6c1319f057d11bc7758c6c49aa2b.tar.gz
packages_apps_SetupWizard-d6b937a5676f6c1319f057d11bc7758c6c49aa2b.tar.bz2
SetupWizard : Don't update locale if sim locked
If the sim is locked, or the setup wizard is not visible, don't change the locale as it creates a unpleasant experience for the user. CYNGNOS-1797 Change-Id: Ib696e83cfcdaef18bcf24ef649e6268b7142961a
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/WelcomePage.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
index 568f8f2..e09c2a1 100644
--- a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
@@ -186,6 +186,8 @@ public class WelcomePage extends SetupPage {
private LocalePicker mLanguagePicker;
private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
private final Handler mHandler = new Handler();
+ private boolean mPendingLocaleUpdate;
+ private boolean mPaused = true;
private final Runnable mUpdateLocale = new Runnable() {
public void run() {
@@ -279,6 +281,10 @@ public class WelcomePage extends SetupPage {
if (mIgnoreSimLocale || isDetached()) {
return;
}
+ if (mPaused) {
+ mPendingLocaleUpdate = true;
+ return;
+ }
if (mFetchUpdateSimLocaleTask != null) {
mFetchUpdateSimLocaleTask.cancel(true);
}
@@ -292,6 +298,15 @@ public class WelcomePage extends SetupPage {
Locale locale = null;
Activity activity = getActivity();
if (activity != null) {
+ // If the sim is currently pin locked, return
+ TelephonyManager telephonyManager = (TelephonyManager)
+ activity.getSystemService(Context.TELEPHONY_SERVICE);
+ int state = telephonyManager.getSimState();
+ if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED ||
+ state == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
+ return null;
+ }
+
final SubscriptionManager subscriptionManager =
SubscriptionManager.from(activity);
List<SubscriptionInfo> activeSubs =
@@ -307,8 +322,6 @@ public class WelcomePage extends SetupPage {
// 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);
@@ -327,10 +340,27 @@ public class WelcomePage extends SetupPage {
simLocale.getDisplayName());
Toast.makeText(getActivity(), label, Toast.LENGTH_SHORT).show();
onLocaleChanged(simLocale);
+ mIgnoreSimLocale = true;
}
}
}
}
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mPaused = true;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mPaused = false;
+ if (mPendingLocaleUpdate) {
+ mPendingLocaleUpdate = false;
+ fetchAndUpdateSimLocale();
+ }
+ }
}
}