From 0b8788aae47932db56bf71869c5d58e0338420a4 Mon Sep 17 00:00:00 2001 From: PauloftheWest Date: Mon, 8 Dec 2014 13:49:35 -0800 Subject: [PATCH] Fixed a SIM Lock UI issue + The SIM lock option will now appear if there is any SIM with locking capabilities. + Also, if the first slot does not have a SIM in it, then the SIM lock screen will disable the ability to lock the first slot. Bug: 18473536 Change-Id: Ib4e0ed6e94b00bc07c9febdad433fdb3c55294b8 --- src/com/android/settings/IccLockSettings.java | 8 ++++++-- src/com/android/settings/SecuritySettings.java | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java index 520137503a..c389f5ee2a 100644 --- a/src/com/android/settings/IccLockSettings.java +++ b/src/com/android/settings/IccLockSettings.java @@ -221,9 +221,13 @@ public class IccLockSettings extends PreferenceActivity ? context.getString(R.string.sim_editor_title, i + 1) : subInfo.getDisplayName()))); } - } + final SubscriptionInfo sir = Utils.findRecordBySlotId(getBaseContext(), 0); - mPhone = PhoneFactory.getDefaultPhone(); + mPhone = (sir == null) ? null + : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); + } else { + mPhone = PhoneFactory.getDefaultPhone(); + } mRes = getResources(); updatePreferences(); } diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 5f74ff65b8..2a1fc826ad 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -298,7 +298,7 @@ public class SecuritySettings extends SettingsPreferenceFragment // Do not display SIM lock for devices without an Icc card TelephonyManager tm = TelephonyManager.getDefault(); - if (!mIsPrimary || !tm.hasIccCard()) { + if (!mIsPrimary || !isSimIccReady()) { root.removePreference(root.findPreference(KEY_SIM_LOCK)); } else { // Disable SIM lock if there is no ready SIM card. @@ -370,6 +370,24 @@ public class SecuritySettings extends SettingsPreferenceFragment return root; } + /* Return true if a there is a Slot that has Icc. + */ + private boolean isSimIccReady() { + TelephonyManager tm = TelephonyManager.getDefault(); + final List subInfoList = + mSubscriptionManager.getActiveSubscriptionInfoList(); + + if (subInfoList != null) { + for (SubscriptionInfo subInfo : subInfoList) { + if (tm.hasIccCard(subInfo.getSubscriptionId())) { + return true; + } + } + } + + return false; + } + /* Return true if a SIM is ready for locking. * TODO: consider adding to TelephonyManager or SubscritpionManasger. */ -- 2.11.0