diff options
author | Danny Baumann <dannybaumann@web.de> | 2016-01-05 09:44:58 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-01-06 15:17:24 -0800 |
commit | 507838a671cd2a293dca6732f1b6199c73cef425 (patch) | |
tree | 972717548975c6fcbe49c9ce5ee11040be501938 /src/com/android/settings/SecuritySettings.java | |
parent | d4cc883c7b42ca1e5ae6bf887fdc0cc22152326f (diff) | |
download | packages_apps_Settings-507838a671cd2a293dca6732f1b6199c73cef425.zip packages_apps_Settings-507838a671cd2a293dca6732f1b6199c73cef425.tar.gz packages_apps_Settings-507838a671cd2a293dca6732f1b6199c73cef425.tar.bz2 |
Remove a few MSIM tab hosts.
Change-Id: Idd0b7738685ba05fc7c6a85306fcf5e5b08203ff
Diffstat (limited to 'src/com/android/settings/SecuritySettings.java')
-rw-r--r-- | src/com/android/settings/SecuritySettings.java | 98 |
1 files changed, 55 insertions, 43 deletions
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index bc0bcac..a500520 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -99,6 +99,7 @@ public class SecuritySettings extends SettingsPreferenceFragment // Misc Settings private static final String KEY_SIM_LOCK = "sim_lock"; + private static final String KEY_SIM_LOCK_SETTINGS = "sim_lock_settings"; private static final String KEY_SHOW_PASSWORD = "show_password"; private static final String KEY_CREDENTIAL_STORAGE_TYPE = "credential_storage_type"; private static final String KEY_RESET_CREDENTIALS = "credentials_reset"; @@ -295,17 +296,65 @@ public class SecuritySettings extends SettingsPreferenceFragment addPreferencesFromResource(R.xml.security_settings_misc); // Do not display SIM lock for devices without an Icc card - TelephonyManager tm = TelephonyManager.getDefault(); CarrierConfigManager cfgMgr = (CarrierConfigManager) getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE); PersistableBundle b = cfgMgr.getConfig(); - if (!mIsPrimary || !isSimIccReady() || - b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) { - root.removePreference(root.findPreference(KEY_SIM_LOCK)); + PreferenceGroup iccLockGroup = (PreferenceGroup) root.findPreference(KEY_SIM_LOCK); + Preference iccLock = root.findPreference(KEY_SIM_LOCK_SETTINGS); + + if (!mIsPrimary + || b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) { + root.removePreference(iccLockGroup); } else { - // Disable SIM lock if there is no ready SIM card. - root.findPreference(KEY_SIM_LOCK).setEnabled(isSimReady()); + SubscriptionManager subMgr = SubscriptionManager.from(getActivity()); + TelephonyManager tm = TelephonyManager.getDefault(); + int numPhones = tm.getPhoneCount(); + boolean hasAnySim = false; + + for (int i = 0; i < numPhones; i++) { + final Preference pref; + + if (numPhones > 1) { + SubscriptionInfo sir = subMgr.getActiveSubscriptionInfoForSimSlotIndex(i); + if (sir == null) { + continue; + } + + pref = new Preference(getActivity()); + pref.setOrder(iccLock.getOrder()); + pref.setTitle(getString(R.string.sim_card_lock_settings_title, i + 1)); + pref.setSummary(sir.getDisplayName()); + + Intent intent = new Intent(getActivity(), IccLockSettings.class); + intent.putExtra(IccLockSettings.EXTRA_SUB_ID, sir.getSubscriptionId()); + intent.putExtra(IccLockSettings.EXTRA_SUB_DISPLAY_NAME, + sir.getDisplayName()); + pref.setIntent(intent); + + iccLockGroup.addPreference(pref); + } else { + pref = iccLock; + } + + // Do not display SIM lock for devices without an Icc card + hasAnySim |= tm.hasIccCard(i); + + int simState = tm.getSimState(i); + boolean simPresent = simState != TelephonyManager.SIM_STATE_ABSENT + && simState != TelephonyManager.SIM_STATE_UNKNOWN + && simState != TelephonyManager.SIM_STATE_CARD_IO_ERROR; + if (!simPresent) { + pref.setEnabled(false); + } + } + + if (!hasAnySim) { + root.removePreference(iccLockGroup); + } else if (numPhones > 1) { + iccLockGroup.removePreference(iccLock); + } } + if (Settings.System.getInt(getContentResolver(), Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) { root.findPreference(KEY_SCREEN_PINNING).setSummary( @@ -440,43 +489,6 @@ public class SecuritySettings extends SettingsPreferenceFragment } } - /* 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.getSimSlotIndex())) { - return true; - } - } - } - - return false; - } - - /* Return true if a SIM is ready for locking. - * TODO: consider adding to TelephonyManager or SubscritpionManasger. - */ - private boolean isSimReady() { - int simState = TelephonyManager.SIM_STATE_UNKNOWN; - final List<SubscriptionInfo> subInfoList = - mSubscriptionManager.getActiveSubscriptionInfoList(); - if (subInfoList != null) { - for (SubscriptionInfo subInfo : subInfoList) { - simState = TelephonyManager.getDefault().getSimState(subInfo.getSimSlotIndex()); - if((simState != TelephonyManager.SIM_STATE_ABSENT) && - (simState != TelephonyManager.SIM_STATE_UNKNOWN)){ - return true; - } - } - } - return false; - } - private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents( PackageManager pm, LockPatternUtils utils, DevicePolicyManager dpm) { ArrayList<TrustAgentComponentInfo> result = new ArrayList<TrustAgentComponentInfo>(); |