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
This commit is contained in:
parent
228ffe700a
commit
d6b937a567
@ -186,6 +186,8 @@ public class WelcomePage extends SetupPage {
|
|||||||
private LocalePicker mLanguagePicker;
|
private LocalePicker mLanguagePicker;
|
||||||
private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
|
private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
|
private boolean mPendingLocaleUpdate;
|
||||||
|
private boolean mPaused = true;
|
||||||
|
|
||||||
private final Runnable mUpdateLocale = new Runnable() {
|
private final Runnable mUpdateLocale = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -279,6 +281,10 @@ public class WelcomePage extends SetupPage {
|
|||||||
if (mIgnoreSimLocale || isDetached()) {
|
if (mIgnoreSimLocale || isDetached()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (mPaused) {
|
||||||
|
mPendingLocaleUpdate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mFetchUpdateSimLocaleTask != null) {
|
if (mFetchUpdateSimLocaleTask != null) {
|
||||||
mFetchUpdateSimLocaleTask.cancel(true);
|
mFetchUpdateSimLocaleTask.cancel(true);
|
||||||
}
|
}
|
||||||
@ -292,6 +298,15 @@ public class WelcomePage extends SetupPage {
|
|||||||
Locale locale = null;
|
Locale locale = null;
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
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 =
|
final SubscriptionManager subscriptionManager =
|
||||||
SubscriptionManager.from(activity);
|
SubscriptionManager.from(activity);
|
||||||
List<SubscriptionInfo> activeSubs =
|
List<SubscriptionInfo> activeSubs =
|
||||||
@ -307,8 +322,6 @@ public class WelcomePage extends SetupPage {
|
|||||||
// If that fails, fall back to preferred languages reported
|
// If that fails, fall back to preferred languages reported
|
||||||
// by the sim
|
// by the sim
|
||||||
if (locale == null) {
|
if (locale == null) {
|
||||||
TelephonyManager telephonyManager = (TelephonyManager) activity.
|
|
||||||
getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
String localeString = telephonyManager.getLocaleFromDefaultSim();
|
String localeString = telephonyManager.getLocaleFromDefaultSim();
|
||||||
if (localeString != null) {
|
if (localeString != null) {
|
||||||
locale = Locale.forLanguageTag(localeString);
|
locale = Locale.forLanguageTag(localeString);
|
||||||
@ -327,10 +340,27 @@ public class WelcomePage extends SetupPage {
|
|||||||
simLocale.getDisplayName());
|
simLocale.getDisplayName());
|
||||||
Toast.makeText(getActivity(), label, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), label, Toast.LENGTH_SHORT).show();
|
||||||
onLocaleChanged(simLocale);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user