Loading res/layout/icc_lock_tabs.xmldeleted 100644 → 0 +0 −60 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2014 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/tabs_container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none" android:fillViewport="true"> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" style="?android:attr/tabWidgetStyle" /> </HorizontalScrollView> <!-- give an empty content area to make tabhost happy --> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dip" android:layout_height="0dip" /> <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:clipChildren="false" android:clipToPadding="false" android:smoothScrollbar="false" /> </LinearLayout> </TabHost> res/values/cm_strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1044,6 +1044,11 @@ <string name="primary_sub_select_title">Default 3G/LTE subscription</string> <string name="select_sim_card">Select SIM card</string> <!-- MSIM SIM status --> <string name="sim_card_status_title">SIM %d status</string> <string name="sim_card_lock_settings_title">SIM %d lock settings</string> <string name="sim_card_summary_empty">SIM not inserted</string> <!-- Zen mode allowed event setting summary items --> <!-- [CHAR LIMIT=50] Like zen_mode_reminders, but part of a list, so lower case if needed--> <string name="zen_mode_summary_reminders">reminders</string> Loading res/xml/device_info_sim_status.xml +0 −12 Original line number Diff line number Diff line Loading @@ -65,16 +65,4 @@ android:summary="@string/device_info_not_available" android:persistent="false" /> <Preference android:key="imei" style="?android:attr/preferenceInformationStyle" android:title="@string/status_imei" android:summary="@string/device_info_not_available" android:persistent="false" /> <Preference android:key="imei_sv" style="?android:attr/preferenceInformationStyle" android:title="@string/status_imei_sv" android:summary="@string/device_info_not_available" android:persistent="false" /> </PreferenceScreen> src/com/android/settings/IccLockSettings.java +13 −61 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings; import android.app.ActionBar; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading @@ -35,11 +36,6 @@ import android.telephony.TelephonyManager; import android.util.Log; import android.view.View; import android.widget.ListView; import android.widget.TabHost; import android.widget.TabHost.OnTabChangeListener; import android.widget.TabHost.TabContentFactory; import android.widget.TabHost.TabSpec; import android.widget.TabWidget; import android.widget.Toast; import com.android.internal.logging.MetricsLogger; Loading Loading @@ -71,6 +67,9 @@ public class IccLockSettings extends InstrumentedPreferenceActivity // State when entering the new pin - second time private static final int ICC_REENTER_MODE = 4; static final String EXTRA_SUB_ID = "slot_id"; static final String EXTRA_SUB_DISPLAY_NAME = "sub_display_name"; // Keys in xml file private static final String PIN_DIALOG = "sim_pin"; private static final String PIN_TOGGLE = "sim_toggle"; Loading @@ -97,10 +96,6 @@ public class IccLockSettings extends InstrumentedPreferenceActivity // Are we trying to enable or disable ICC lock? private boolean mToState; private TabHost mTabHost; private TabWidget mTabWidget; private ListView mListView; private Phone mPhone; private EditPinPreference mPinDialog; Loading Loading @@ -201,32 +196,16 @@ public class IccLockSettings extends InstrumentedPreferenceActivity // Don't need any changes to be remembered getPreferenceScreen().setPersistent(false); if (numSims > 1) { setContentView(R.layout.icc_lock_tabs); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabWidget = (TabWidget) findViewById(android.R.id.tabs); mListView = (ListView) findViewById(android.R.id.list); mTabHost.setup(); mTabHost.setOnTabChangedListener(mTabListener); mTabHost.clearAllTabs(); SubscriptionManager sm = SubscriptionManager.from(this); for (int i = 0; i < numSims; ++i) { final SubscriptionInfo subInfo = sm.getActiveSubscriptionInfoForSimSlotIndex(i); mTabHost.addTab(buildTabSpec(String.valueOf(i), String.valueOf(subInfo == null ? context.getString(R.string.sim_editor_title, i + 1) : subInfo.getDisplayName()))); Intent intent = getIntent(); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setSubtitle(intent.getStringExtra(EXTRA_SUB_DISPLAY_NAME)); } final SubscriptionInfo sir = sm.getActiveSubscriptionInfoForSimSlotIndex(0); mPhone = (sir == null) ? null : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); } else { mPhone = PhoneFactory.getDefaultPhone(); } int subId = intent.getIntExtra(EXTRA_SUB_ID, SubscriptionManager.getDefaultSubId()); int phoneId = SubscriptionManager.getPhoneId(subId); mPhone = PhoneFactory.getPhone(phoneId); mRes = getResources(); updatePreferences(); } Loading Loading @@ -472,31 +451,4 @@ public class IccLockSettings extends InstrumentedPreferenceActivity setDialogValues(); mDialogState = OFF_MODE; } private OnTabChangeListener mTabListener = new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { final int slotId = Integer.parseInt(tabId); final SubscriptionInfo sir = SubscriptionManager.from(getBaseContext()) .getActiveSubscriptionInfoForSimSlotIndex(slotId); mPhone = (sir == null) ? null : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); // The User has changed tab; update the body. updatePreferences(); } }; private TabContentFactory mEmptyTabContent = new TabContentFactory() { @Override public View createTabContent(String tag) { return new View(mTabHost.getContext()); } }; private TabSpec buildTabSpec(String tag, String title) { return mTabHost.newTabSpec(tag).setIndicator(title).setContent( mEmptyTabContent); } } src/com/android/settings/SecuritySettings.java +55 −43 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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 { 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 { // Disable SIM lock if there is no ready SIM card. root.findPreference(KEY_SIM_LOCK).setEnabled(isSimReady()); 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( Loading Loading @@ -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>(); Loading Loading
res/layout/icc_lock_tabs.xmldeleted 100644 → 0 +0 −60 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2014 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/tabs_container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none" android:fillViewport="true"> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" style="?android:attr/tabWidgetStyle" /> </HorizontalScrollView> <!-- give an empty content area to make tabhost happy --> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dip" android:layout_height="0dip" /> <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:clipChildren="false" android:clipToPadding="false" android:smoothScrollbar="false" /> </LinearLayout> </TabHost>
res/values/cm_strings.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1044,6 +1044,11 @@ <string name="primary_sub_select_title">Default 3G/LTE subscription</string> <string name="select_sim_card">Select SIM card</string> <!-- MSIM SIM status --> <string name="sim_card_status_title">SIM %d status</string> <string name="sim_card_lock_settings_title">SIM %d lock settings</string> <string name="sim_card_summary_empty">SIM not inserted</string> <!-- Zen mode allowed event setting summary items --> <!-- [CHAR LIMIT=50] Like zen_mode_reminders, but part of a list, so lower case if needed--> <string name="zen_mode_summary_reminders">reminders</string> Loading
res/xml/device_info_sim_status.xml +0 −12 Original line number Diff line number Diff line Loading @@ -65,16 +65,4 @@ android:summary="@string/device_info_not_available" android:persistent="false" /> <Preference android:key="imei" style="?android:attr/preferenceInformationStyle" android:title="@string/status_imei" android:summary="@string/device_info_not_available" android:persistent="false" /> <Preference android:key="imei_sv" style="?android:attr/preferenceInformationStyle" android:title="@string/status_imei_sv" android:summary="@string/device_info_not_available" android:persistent="false" /> </PreferenceScreen>
src/com/android/settings/IccLockSettings.java +13 −61 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings; import android.app.ActionBar; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading @@ -35,11 +36,6 @@ import android.telephony.TelephonyManager; import android.util.Log; import android.view.View; import android.widget.ListView; import android.widget.TabHost; import android.widget.TabHost.OnTabChangeListener; import android.widget.TabHost.TabContentFactory; import android.widget.TabHost.TabSpec; import android.widget.TabWidget; import android.widget.Toast; import com.android.internal.logging.MetricsLogger; Loading Loading @@ -71,6 +67,9 @@ public class IccLockSettings extends InstrumentedPreferenceActivity // State when entering the new pin - second time private static final int ICC_REENTER_MODE = 4; static final String EXTRA_SUB_ID = "slot_id"; static final String EXTRA_SUB_DISPLAY_NAME = "sub_display_name"; // Keys in xml file private static final String PIN_DIALOG = "sim_pin"; private static final String PIN_TOGGLE = "sim_toggle"; Loading @@ -97,10 +96,6 @@ public class IccLockSettings extends InstrumentedPreferenceActivity // Are we trying to enable or disable ICC lock? private boolean mToState; private TabHost mTabHost; private TabWidget mTabWidget; private ListView mListView; private Phone mPhone; private EditPinPreference mPinDialog; Loading Loading @@ -201,32 +196,16 @@ public class IccLockSettings extends InstrumentedPreferenceActivity // Don't need any changes to be remembered getPreferenceScreen().setPersistent(false); if (numSims > 1) { setContentView(R.layout.icc_lock_tabs); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabWidget = (TabWidget) findViewById(android.R.id.tabs); mListView = (ListView) findViewById(android.R.id.list); mTabHost.setup(); mTabHost.setOnTabChangedListener(mTabListener); mTabHost.clearAllTabs(); SubscriptionManager sm = SubscriptionManager.from(this); for (int i = 0; i < numSims; ++i) { final SubscriptionInfo subInfo = sm.getActiveSubscriptionInfoForSimSlotIndex(i); mTabHost.addTab(buildTabSpec(String.valueOf(i), String.valueOf(subInfo == null ? context.getString(R.string.sim_editor_title, i + 1) : subInfo.getDisplayName()))); Intent intent = getIntent(); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setSubtitle(intent.getStringExtra(EXTRA_SUB_DISPLAY_NAME)); } final SubscriptionInfo sir = sm.getActiveSubscriptionInfoForSimSlotIndex(0); mPhone = (sir == null) ? null : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); } else { mPhone = PhoneFactory.getDefaultPhone(); } int subId = intent.getIntExtra(EXTRA_SUB_ID, SubscriptionManager.getDefaultSubId()); int phoneId = SubscriptionManager.getPhoneId(subId); mPhone = PhoneFactory.getPhone(phoneId); mRes = getResources(); updatePreferences(); } Loading Loading @@ -472,31 +451,4 @@ public class IccLockSettings extends InstrumentedPreferenceActivity setDialogValues(); mDialogState = OFF_MODE; } private OnTabChangeListener mTabListener = new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { final int slotId = Integer.parseInt(tabId); final SubscriptionInfo sir = SubscriptionManager.from(getBaseContext()) .getActiveSubscriptionInfoForSimSlotIndex(slotId); mPhone = (sir == null) ? null : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); // The User has changed tab; update the body. updatePreferences(); } }; private TabContentFactory mEmptyTabContent = new TabContentFactory() { @Override public View createTabContent(String tag) { return new View(mTabHost.getContext()); } }; private TabSpec buildTabSpec(String tag, String title) { return mTabHost.newTabSpec(tag).setIndicator(title).setContent( mEmptyTabContent); } }
src/com/android/settings/SecuritySettings.java +55 −43 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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 { 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 { // Disable SIM lock if there is no ready SIM card. root.findPreference(KEY_SIM_LOCK).setEnabled(isSimReady()); 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( Loading Loading @@ -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>(); Loading