OSDN Git Service

Fixed a SIM Lock UI issue
authorPauloftheWest <paulofthewest@google.com>
Mon, 8 Dec 2014 21:49:35 +0000 (13:49 -0800)
committerPauloftheWest <paulofthewest@google.com>
Mon, 8 Dec 2014 21:51:25 +0000 (13:51 -0800)
+ 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
src/com/android/settings/SecuritySettings.java

index 5201375..c389f5e 100644 (file)
@@ -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();
     }
index 5f74ff6..2a1fc82 100644 (file)
@@ -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<SubscriptionInfo> 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.
      */