Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
xmlns:cm="http://schemas.android.com/apk/res/cyanogenmod.platform"
android:title="@string/settings_label"> android:title="@string/settings_label">
<com.android.settings.TimeoutListPreference <com.android.settings.TimeoutListPreference
...@@ -30,10 +31,51 @@ ...@@ -30,10 +31,51 @@
android:key="power_button_instantly_locks" android:key="power_button_instantly_locks"
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
<SwitchPreference
android:key="directly_show_lock"
android:title="@string/lock_directly_show_pin"
android:persistent="false" />
<com.android.settings.SingleLineSummaryPreference <com.android.settings.SingleLineSummaryPreference
android:key="owner_info_settings" android:key="owner_info_settings"
android:title="@string/owner_info_settings_title" android:title="@string/owner_info_settings_title"
android:summary="@string/owner_info_settings_summary"/> android:summary="@string/owner_info_settings_summary"/>
<cyanogenmod.preference.CMSystemSettingSwitchPreference
android:key="lockscreen_scramble_pin_layout"
android:title="@string/unlock_scramble_pin_layout_title"
android:summary="@string/unlock_scramble_pin_layout_summary" />
<PreferenceScreen
android:title="@string/lockscreen_targets_message" >
<intent
android:targetPackage="com.android.systemui"
android:targetClass="com.android.systemui.cm.LockscreenShortcutsActivity" />
</PreferenceScreen>
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lockscreen_visualizer"
android:title="@string/lockscreen_visualizer_title"
android:defaultValue="true"/>
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lockscreen_media_metadata"
android:title="@string/lockscreen_media_art_title"
android:defaultValue="true" />
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="double_tap_sleep_anywhere"
android:title="@string/double_tap_sleep_anywhere_title"
android:defaultValue="false" />
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lock_screen_weather_enabled"
android:title="@string/lockscreen_weather_enabled_title"
android:defaultValue="false"/>
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lock_screen_blur_enabled"
android:title="@string/lockscreen_blur_enabled_title"
cm:requiresConfig="@*android:bool/config_uiBlurEnabled" />
</PreferenceScreen> </PreferenceScreen>
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
xmlns:cm="http://schemas.android.com/apk/res/cyanogenmod.platform"
android:title="@string/settings_label"> android:title="@string/settings_label">
<com.android.settings.SingleLineSummaryPreference <com.android.settings.SingleLineSummaryPreference
...@@ -24,4 +25,36 @@ ...@@ -24,4 +25,36 @@
android:title="@string/owner_info_settings_title" android:title="@string/owner_info_settings_title"
android:summary="@string/owner_info_settings_summary"/> android:summary="@string/owner_info_settings_summary"/>
<PreferenceScreen
android:title="@string/lockscreen_targets_message" >
<intent
android:targetPackage="com.android.systemui"
android:targetClass="com.android.systemui.cm.LockscreenShortcutsActivity" />
</PreferenceScreen>
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lockscreen_visualizer"
android:title="@string/lockscreen_visualizer_title"
android:defaultValue="true"/>
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lockscreen_media_metadata"
android:title="@string/lockscreen_media_art_title"
android:defaultValue="true" />
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="double_tap_sleep_anywhere"
android:title="@string/double_tap_sleep_anywhere_title"
android:defaultValue="false" />
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lock_screen_weather_enabled"
android:title="@string/lockscreen_weather_enabled_title"
android:defaultValue="false"/>
<cyanogenmod.preference.CMSecureSettingSwitchPreference
android:key="lock_screen_blur_enabled"
android:title="@string/lockscreen_blur_enabled_title"
cm:requiresConfig="@*android:bool/config_uiBlurEnabled" />
</PreferenceScreen> </PreferenceScreen>
...@@ -15,9 +15,12 @@ ...@@ -15,9 +15,12 @@
--> -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="sim_cards"
android:title="@string/sim_settings_title"> android:title="@string/sim_settings_title">
<PreferenceCategory
android:key="sim_cards"
android:title="@string/sim_settings_title"/>
<PreferenceCategory <PreferenceCategory
android:key="sim_activities" android:key="sim_activities"
android:title="@string/sim_pref_divider" > android:title="@string/sim_pref_divider" >
...@@ -33,5 +36,8 @@ ...@@ -33,5 +36,8 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory
android:key="mobile_network"
android:title="@string/sim_mobile_network_settings_category_title" />
</PreferenceScreen> </PreferenceScreen>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<!-- Ring volume --> <!-- Ring volume -->
<com.android.settings.notification.VolumeSeekBarPreference <com.android.settings.notification.VolumeSeekBarPreference
android:key="ring_volume" android:key="ring_volume"
android:icon="@*android:drawable/ic_audio_ring_notif" android:icon="@drawable/ic_audio_ring"
android:title="@string/ring_volume_option_title" /> android:title="@string/ring_volume_option_title" />
<!-- Notification volume --> <!-- Notification volume -->
...@@ -44,6 +44,23 @@ ...@@ -44,6 +44,23 @@
android:icon="@*android:drawable/ic_audio_ring_notif" android:icon="@*android:drawable/ic_audio_ring_notif"
android:title="@string/notification_volume_option_title" /> android:title="@string/notification_volume_option_title" />
<!-- Link ringtone and notification volumes -->
<cyanogenmod.preference.SecureSettingSwitchPreference
android:key="volume_link_notification"
android:title="@string/volume_link_notification_title"
android:defaultValue="true" />
<!-- Increasing ring -->
<cyanogenmod.preference.CMSystemSettingSwitchPreference
android:key="increasing_ring"
android:title="@string/increasing_ring_volume_option_title" />
<!-- Increasing ring volume -->
<com.android.settings.notification.IncreasingRingVolumePreference
android:key="increasing_ring_volume"
android:icon="@drawable/ring_notif_increasing"
android:dependency="increasing_ring" />
<!-- Also vibrate for calls --> <!-- Also vibrate for calls -->
<SwitchPreference <SwitchPreference
android:key="vibrate_when_ringing" android:key="vibrate_when_ringing"
...@@ -80,15 +97,11 @@ ...@@ -80,15 +97,11 @@
android:persistent="false" android:persistent="false"
android:ringtoneType="alarm" /> android:ringtoneType="alarm" />
<com.android.settingslib.RestrictedPreference <!-- Launch music player when headset is connected -->
android:key="cell_broadcast_settings" <cyanogenmod.preference.CMSystemSettingSwitchPreference
android:title="@string/cell_broadcast_settings" android:key="headset_connect_player"
settings:useAdminDisabledSummary="true"> android:title="@string/headset_connect_player_title"
<intent android:summary="@string/headset_connect_player_summary" />
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.cellbroadcastreceiver"
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings" />
</com.android.settingslib.RestrictedPreference>
<!-- Other sounds --> <!-- Other sounds -->
<Preference <Preference
......
...@@ -17,26 +17,50 @@ ...@@ -17,26 +17,50 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"> xmlns:settings="http://schemas.android.com/apk/res-auto">
<SwitchPreference
android:key="usb_tether_settings"
android:title="@string/usb_tethering_button_text" />
<SwitchPreference <SwitchPreference
android:key="enable_wifi_ap" android:key="enable_wifi_ap"
android:title="@string/wifi_tether_checkbox_text" /> android:title="@string/wifi_tether_checkbox_text" />
<com.android.settings.HotspotPreference
android:key="enable_wifi_ap_ext"
android:title="@string/wifi_tether_checkbox_text"
android:layout="@layout/hotspot_checkbox"
android:persistent="false" />
<Preference <Preference
android:key="wifi_ap_ssid_and_security" android:key="wifi_ap_ssid_and_security"
android:title="@string/wifi_tether_configure_ap_text" android:title="@string/wifi_tether_configure_ap_text"
android:persistent="false" /> android:persistent="false" />
<SwitchPreference <ListPreference
android:key="enable_bluetooth_tethering" android:key="hotstpot_inactivity_timeout"
android:title="@string/bluetooth_tether_checkbox_text" /> android:title="@string/hotstpot_inactivity_timeout_text"
android:entries="@array/hotstpot_inactivity_timeout_entries"
android:entryValues="@array/hotstpot_inactivity_timeout_values"
android:persistent="false" />
<com.android.settings.DividerPreference <com.android.settings.DividerPreference
android:key="disabled_on_data_saver" android:key="disabled_on_data_saver"
android:summary="@string/tether_settings_disabled_on_data_saver" android:summary="@string/tether_settings_disabled_on_data_saver"
android:selectable="false" android:selectable="false"
settings:allowDividerAbove="true" /> settings:allowDividerAbove="true" />
<PreferenceScreen
android:key="tethering_help"
android:title="@string/tethering_help_button_text" >
</PreferenceScreen>
<PreferenceCategory
android:title="@string/tethering_other_category_text">
<SwitchPreference
android:key="usb_tether_settings"
android:title="@string/usb_tethering_button_text"
android:persistent="false" />
<SwitchPreference
android:key="enable_bluetooth_tethering"
android:title="@string/bluetooth_tether_checkbox_text"
android:persistent="false" />
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
...@@ -17,11 +17,66 @@ ...@@ -17,11 +17,66 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/wifi_advanced_titlebar"> android:title="@string/wifi_advanced_titlebar">
<!-- Wifi extension requirement -->
<PreferenceScreen
android:key="wifi_priority_settings"
android:title="@string/wifi_set_priority_settings_title"
android:summary="@string/wifi_set_priority_settings_summary" >
<intent android:action="com.qti.wifi.priority"
android:targetPackage="com.qti.extwifi" />
</PreferenceScreen>
<ListPreference
android:key="cellular_to_wlan"
android:title="@string/cellular_to_wlan_title"
android:persistent="false"
android:entries="@array/cellcular2wifi_entries"
android:entryValues="@array/cellcular2wifi_values" />
<CheckBoxPreference
android:key="auto_connect_type"
android:title="@string/wifi_auto_connect_type_title"
android:summary="@string/wifi_auto_connect_type_summary"
android:disableDependentsState="true"
android:persistent="false" />
<CheckBoxPreference
android:key="cellular_to_wlan_hint"
android:title="@string/cellular_to_wlan_hint_title"
android:summary="@string/cellular_to_wlan_hint_summary"
android:persistent="false"
android:dependency="auto_connect_type" />
<CheckBoxPreference
android:key="wlan_to_cellular_hint"
android:title="@string/wlan_to_cellular_hint_title"
android:persistent="false" />
<CheckBoxPreference
android:key="notify_ap_connected"
android:title="@string/notify_connect"
android:summary="@string/notify_connect_summary"
android:persistent="false"/>
<ListPreference
android:key="wifi_countrycode"
android:title="@string/wifi_setting_countrycode_title"
android:summary="@string/wifi_setting_countrycode_summary"
android:persistent="false"
android:entries="@array/wifi_countrycode_entries"
android:entryValues="@array/wifi_countrycode_values" />
<Preference <Preference
android:key="install_credentials" android:key="install_credentials"
android:title="@string/wifi_install_credentials" android:title="@string/wifi_install_credentials"
android:persistent="false" /> android:persistent="false" />
<!-- android:dependency="enable_wifi" -->
<SwitchPreference
android:key="enable_hs2"
android:title="@string/wifi_enable_hs2_title"
android:persistent="false" />
<Preference <Preference
android:key="wifi_direct" android:key="wifi_direct"
android:title="@string/wifi_menu_p2p" android:title="@string/wifi_menu_p2p"
......
...@@ -62,4 +62,14 @@ ...@@ -62,4 +62,14 @@
android:title="@string/wifi_advanced_ip_address_title" android:title="@string/wifi_advanced_ip_address_title"
android:layout="@layout/wifi_advance_layout" /> android:layout="@layout/wifi_advance_layout" />
<Preference
android:key="current_gateway"
android:title="@string/wifi_advanced_gateway"
android:layout="@layout/wifi_advance_layout" />
<Preference
android:key="current_netmask"
android:title="@string/wifi_advanced_network_netmask"
android:layout="@layout/wifi_advance_layout" />
</PreferenceScreen> </PreferenceScreen>
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -23,22 +23,12 @@ ...@@ -23,22 +23,12 @@
android:title="@string/airplane_mode" android:title="@string/airplane_mode"
android:disableDependentsState="true" /> android:disableDependentsState="true" />
<SwitchPreference
android:key="toggle_nfc"
android:title="@string/nfc_quick_toggle_title"
android:summary="@string/nfc_quick_toggle_summary" />
<PreferenceScreen <PreferenceScreen
android:key="wifi_calling_settings" android:key="wifi_calling_settings"
android:title="@string/wifi_calling_settings_title" android:title="@string/wifi_calling_settings_title"
settings:keywords="@string/keywords_wifi_calling" settings:keywords="@string/keywords_wifi_calling"
android:fragment="com.android.settings.WifiCallingSettings" /> android:fragment="com.android.settings.WifiCallingSettings" />
<com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.nfc.AndroidBeam"
android:key="android_beam_settings"
android:title="@string/android_beam_settings_title" />
<com.android.settingslib.RestrictedPreference <com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.TetherSettings" android:fragment="com.android.settings.TetherSettings"
android:key="tether_settings" android:key="tether_settings"
...@@ -73,6 +63,16 @@ ...@@ -73,6 +63,16 @@
settings:userRestriction="no_config_mobile_networks" settings:userRestriction="no_config_mobile_networks"
settings:useAdminDisabledSummary="true" /> settings:useAdminDisabledSummary="true" />
<com.android.settingslib.RestrictedPreference
android:key="cell_broadcast_settings"
android:title="@string/cell_broadcast_settings"
settings:useAdminDisabledSummary="true">
<!--intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.cellbroadcastreceiver"
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings" /-->
</com.android.settingslib.RestrictedPreference>
<com.android.settingslib.RestrictedPreference <com.android.settingslib.RestrictedPreference
android:key="wimax_settings" android:key="wimax_settings"
android:title="@string/wimax_settings" android:title="@string/wimax_settings"
...@@ -98,4 +98,23 @@ ...@@ -98,4 +98,23 @@
settings:useAdminDisabledSummary="true" settings:useAdminDisabledSummary="true"
android:fragment="com.android.settings.ResetNetwork" /> android:fragment="com.android.settings.ResetNetwork" />
<PreferenceCategory
android:key="nfc_category_settings"
android:title="@string/nfc_title_category" >
<SwitchPreference
android:key="toggle_nfc"
android:title="@string/nfc_quick_toggle_title"
android:summary="@string/nfc_quick_toggle_summary" />
<com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.nfc.AndroidBeam"
android:key="android_beam_settings"
android:title="@string/android_beam_settings_title" />
<PreferenceScreen
android:key="nfc_payment_settings"
android:title="@string/nfc_payment_settings_title"
android:fragment="com.android.settings.nfc.PaymentSettings" />
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
...@@ -53,4 +53,12 @@ ...@@ -53,4 +53,12 @@
android:key="repeat_callers" android:key="repeat_callers"
android:title="@string/zen_mode_repeat_callers"/> android:title="@string/zen_mode_repeat_callers"/>
<cyanogenmod.preference.CMSystemSettingDropDownPreference
android:key="zen_priority_vibration_mode"
android:title="@string/zen_mode_vibration"
android:summary="%s"
android:entries="@array/zen_vibration_mode_entries"
android:entryValues="@array/zen_vibration_mode_values"
android:defaultValue="0" />
</PreferenceScreen> </PreferenceScreen>
...@@ -78,6 +78,10 @@ public class ActivityPicker extends AlertActivity implements ...@@ -78,6 +78,10 @@ public class ActivityPicker extends AlertActivity implements
Parcelable parcel = intent.getParcelableExtra(Intent.EXTRA_INTENT); Parcelable parcel = intent.getParcelableExtra(Intent.EXTRA_INTENT);
if (parcel instanceof Intent) { if (parcel instanceof Intent) {
mBaseIntent = (Intent) parcel; mBaseIntent = (Intent) parcel;
mBaseIntent.setFlags(mBaseIntent.getFlags() & ~(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION));
} else { } else {
mBaseIntent = new Intent(Intent.ACTION_MAIN, null); mBaseIntent = new Intent(Intent.ACTION_MAIN, null);
mBaseIntent.addCategory(Intent.CATEGORY_DEFAULT); mBaseIntent.addCategory(Intent.CATEGORY_DEFAULT);
......
...@@ -101,11 +101,13 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -101,11 +101,13 @@ public class ApnEditor extends SettingsPreferenceFragment
private String mCurMnc; private String mCurMnc;
private String mCurMcc; private String mCurMcc;
private boolean mDisableEditor = false;
private Uri mUri; private Uri mUri;
private Cursor mCursor; private Cursor mCursor;
private boolean mNewApn; private boolean mNewApn;
private boolean mFirstTime; private boolean mFirstTime;
private boolean mApnDisable = false;
private int mSubId; private int mSubId;
private Resources mRes; private Resources mRes;
private TelephonyManager mTelephonyManager; private TelephonyManager mTelephonyManager;
...@@ -170,6 +172,8 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -170,6 +172,8 @@ public class ApnEditor extends SettingsPreferenceFragment
private static final int MVNO_MATCH_DATA_INDEX = 22; private static final int MVNO_MATCH_DATA_INDEX = 22;
private static final int EDITED_INDEX = 23; private static final int EDITED_INDEX = 23;
private static final int DEFAULT_IPV4V6_INDEX = 2;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
...@@ -216,6 +220,7 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -216,6 +220,7 @@ public class ApnEditor extends SettingsPreferenceFragment
final String action = intent.getAction(); final String action = intent.getAction();
mSubId = intent.getIntExtra(ApnSettings.SUB_ID, mSubId = intent.getIntExtra(ApnSettings.SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID); SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mDisableEditor = intent.getBooleanExtra("DISABLE_EDITOR", false);
mFirstTime = icicle == null; mFirstTime = icicle == null;
mReadOnlyApn = false; mReadOnlyApn = false;
...@@ -499,9 +504,13 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -499,9 +504,13 @@ public class ApnEditor extends SettingsPreferenceFragment
} else { } else {
mAuthType.setValue(null); mAuthType.setValue(null);
} }
if (mNewApn && getResources().getBoolean(R.bool.config_default_apn_for_new)) {
mProtocol.setValue(mCursor.getString(PROTOCOL_INDEX)); mProtocol.setValueIndex(DEFAULT_IPV4V6_INDEX);
mRoamingProtocol.setValue(mCursor.getString(ROAMING_PROTOCOL_INDEX)); mRoamingProtocol.setValueIndex(DEFAULT_IPV4V6_INDEX);
} else {
mProtocol.setValue(mCursor.getString(PROTOCOL_INDEX));
mRoamingProtocol.setValue(mCursor.getString(ROAMING_PROTOCOL_INDEX));
}
mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1); mCarrierEnabled.setChecked(mCursor.getInt(CARRIER_ENABLED_INDEX)==1);
mBearerInitialVal = mCursor.getInt(BEARER_INDEX); mBearerInitialVal = mCursor.getInt(BEARER_INDEX);
...@@ -535,6 +544,10 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -535,6 +544,10 @@ public class ApnEditor extends SettingsPreferenceFragment
mMvnoType.setValue(mMvnoTypeStr); mMvnoType.setValue(mMvnoTypeStr);
mMvnoMatchData.setText(mMvnoMatchDataStr); mMvnoMatchData.setText(mMvnoMatchDataStr);
} }
String localizedName = ApnSettings.getLocalizedName(getActivity(), mCursor,NAME_INDEX);
if (!TextUtils.isEmpty(localizedName)) {
mName.setText(localizedName);
}
} }
mName.setSummary(checkNull(mName.getText())); mName.setSummary(checkNull(mName.getText()));
...@@ -578,6 +591,24 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -578,6 +591,24 @@ public class ApnEditor extends SettingsPreferenceFragment
} else { } else {
mCarrierEnabled.setEnabled(false); mCarrierEnabled.setEnabled(false);
} }
String mccMnc = mMcc.getText() + mMnc.getText();
for (String plmn : getResources().getStringArray(R.array.plmn_list_for_apn_disable)) {
if (plmn.equals(mccMnc) && !mNewApn) {
mApnDisable = true;
Log.d(TAG, "APN is China Telecom's.");
break;
}
}
if (mDisableEditor) {
if (mApnDisable) {
mApn.setEnabled(false);
Log.d(TAG, "Apn Name can't be edited.");
} else {
getPreferenceScreen().setEnabled(false);
Log.d(TAG, "ApnEditor form is disabled.");
}
}
} }
/** /**
...@@ -654,6 +685,11 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -654,6 +685,11 @@ public class ApnEditor extends SettingsPreferenceFragment
mMvnoMatchData.setText(numeric + "x"); mMvnoMatchData.setText(numeric + "x");
} else if (values[mvnoIndex].equals("GID")) { } else if (values[mvnoIndex].equals("GID")) {
mMvnoMatchData.setText(mTelephonyManager.getGroupIdLevel1()); mMvnoMatchData.setText(mTelephonyManager.getGroupIdLevel1());
} else if (values[mvnoIndex].equals("ICCID")) {
if (mMvnoMatchDataStr != null) {
Log.d(TAG, "mMvnoMatchDataStr: " + mMvnoMatchDataStr);
mMvnoMatchData.setText(mMvnoMatchDataStr);
}
} }
} }
...@@ -705,10 +741,9 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -705,10 +741,9 @@ public class ApnEditor extends SettingsPreferenceFragment
} }
mMvnoType.setValue((String) newValue); mMvnoType.setValue((String) newValue);
mMvnoType.setSummary(mvno); mMvnoType.setSummary(mvno);
} } else if (preference.equals(mPassword)) {
if (preference.equals(mPassword)) {
preference.setSummary(starify(newValue != null ? String.valueOf(newValue) : "")); preference.setSummary(starify(newValue != null ? String.valueOf(newValue) : ""));
} else if (preference.equals(mCarrierEnabled) || preference.equals(mBearerMulti)) { } else if (preference.equals(mCarrierEnabled)) {
// do nothing // do nothing
} else { } else {
preference.setSummary(checkNull(newValue != null ? String.valueOf(newValue) : null)); preference.setSummary(checkNull(newValue != null ? String.valueOf(newValue) : null));
...@@ -720,8 +755,12 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -720,8 +755,12 @@ public class ApnEditor extends SettingsPreferenceFragment
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (mDisableEditor && !mApnDisable) {
Log.d(TAG, "Form is disabled. Do not create the options menu.");
return;
}
// If it's a new APN, then cancel will delete the new entry in onPause // If it's a new APN, then cancel will delete the new entry in onPause
if (!mNewApn && !mReadOnlyApn) { if (!mNewApn && !mDisableEditor && !mReadOnlyApn) {
menu.add(0, MENU_DELETE, 0, R.string.menu_delete) menu.add(0, MENU_DELETE, 0, R.string.menu_delete)
.setIcon(R.drawable.ic_menu_delete); .setIcon(R.drawable.ic_menu_delete);
} }
...@@ -786,6 +825,13 @@ public class ApnEditor extends SettingsPreferenceFragment ...@@ -786,6 +825,13 @@ public class ApnEditor extends SettingsPreferenceFragment
* @return true if the data was saved * @return true if the data was saved
*/ */
private boolean validateAndSave(boolean force) { private boolean validateAndSave(boolean force) {
// If the form is not editable, do nothing and return.
if (mDisableEditor && !mApnDisable){
Log.d(TAG, "Form is disabled. Nothing to save.");
return true;
}
String name = checkNotSet(mName.getText()); String name = checkNotSet(mName.getText());
String apn = checkNotSet(mApn.getText()); String apn = checkNotSet(mApn.getText());
String mcc = checkNotSet(mMcc.getText()); String mcc = checkNotSet(mMcc.getText());
......
...@@ -51,6 +51,7 @@ public class ApnPreference extends Preference implements ...@@ -51,6 +51,7 @@ public class ApnPreference extends Preference implements
private static CompoundButton mCurrentChecked = null; private static CompoundButton mCurrentChecked = null;
private boolean mProtectFromCheckedChange = false; private boolean mProtectFromCheckedChange = false;
private boolean mSelectable = true; private boolean mSelectable = true;
private boolean mApnReadOnly = false;
@Override @Override
public void onBindViewHolder(PreferenceViewHolder view) { public void onBindViewHolder(PreferenceViewHolder view) {
...@@ -116,7 +117,9 @@ public class ApnPreference extends Preference implements ...@@ -116,7 +117,9 @@ public class ApnPreference extends Preference implements
if (context != null) { if (context != null) {
int pos = Integer.parseInt(getKey()); int pos = Integer.parseInt(getKey());
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos); Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
context.startActivity(new Intent(Intent.ACTION_EDIT, url)); Intent intent = new Intent(Intent.ACTION_EDIT, url);
intent.putExtra("DISABLE_EDITOR", mApnReadOnly);
context.startActivity(intent);
} }
} }
} }
...@@ -128,4 +131,12 @@ public class ApnPreference extends Preference implements ...@@ -128,4 +131,12 @@ public class ApnPreference extends Preference implements
public boolean getSelectable() { public boolean getSelectable() {
return mSelectable; return mSelectable;
} }
public void setApnReadOnly(boolean apnReadOnly) {
mApnReadOnly = apnReadOnly;
}
public boolean getApnReadOnly() {
return mApnReadOnly;
}
} }
...@@ -26,6 +26,7 @@ import android.content.ContentValues; ...@@ -26,6 +26,7 @@ import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
...@@ -34,6 +35,7 @@ import android.os.HandlerThread; ...@@ -34,6 +35,7 @@ import android.os.HandlerThread;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.os.SystemProperties;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.provider.Telephony; import android.provider.Telephony;
...@@ -41,6 +43,7 @@ import android.support.v7.preference.Preference; ...@@ -41,6 +43,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceScreen;
import android.telephony.CarrierConfigManager; import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
...@@ -62,6 +65,8 @@ import com.android.internal.telephony.uicc.UiccController; ...@@ -62,6 +65,8 @@ import com.android.internal.telephony.uicc.UiccController;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
public class ApnSettings extends RestrictedSettingsFragment implements public class ApnSettings extends RestrictedSettingsFragment implements
Preference.OnPreferenceChangeListener { Preference.OnPreferenceChangeListener {
...@@ -78,12 +83,17 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -78,12 +83,17 @@ public class ApnSettings extends RestrictedSettingsFragment implements
public static final String MVNO_TYPE = "mvno_type"; public static final String MVNO_TYPE = "mvno_type";
public static final String MVNO_MATCH_DATA = "mvno_match_data"; public static final String MVNO_MATCH_DATA = "mvno_match_data";
private static final String APN_NAME_DM = "CMCC DM";
private static final int ID_INDEX = 0; private static final int ID_INDEX = 0;
private static final int NAME_INDEX = 1; private static final int NAME_INDEX = 1;
private static final int APN_INDEX = 2; private static final int APN_INDEX = 2;
private static final int TYPES_INDEX = 3; private static final int TYPES_INDEX = 3;
private static final int MVNO_TYPE_INDEX = 4; private static final int MVNO_TYPE_INDEX = 4;
private static final int MVNO_MATCH_DATA_INDEX = 5; private static final int MVNO_MATCH_DATA_INDEX = 5;
private static final int RO_INDEX = 6;
private static final int BEARER_INDEX = 7;
private static final int BEARER_BITMASK_INDEX = 8;
private static final int MENU_NEW = Menu.FIRST; private static final int MENU_NEW = Menu.FIRST;
private static final int MENU_RESTORE = Menu.FIRST + 1; private static final int MENU_RESTORE = Menu.FIRST + 1;
...@@ -115,11 +125,14 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -115,11 +125,14 @@ public class ApnSettings extends RestrictedSettingsFragment implements
private boolean mHideImsApn; private boolean mHideImsApn;
private boolean mAllowAddingApns; private boolean mAllowAddingApns;
private boolean mApnSettingsHidden;
public ApnSettings() { public ApnSettings() {
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS); super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
} }
private HashSet mIccidSet;
private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() { private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
...@@ -130,8 +143,6 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -130,8 +143,6 @@ public class ApnSettings extends RestrictedSettingsFragment implements
case CONNECTED: case CONNECTED:
if (!mRestoreDefaultApnMode) { if (!mRestoreDefaultApnMode) {
fillList(); fillList();
} else {
showDialog(DIALOG_RESTORE_DEFAULTAPN);
} }
break; break;
} }
...@@ -159,6 +170,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -159,6 +170,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements
final Activity activity = getActivity(); final Activity activity = getActivity();
final int subId = activity.getIntent().getIntExtra(SUB_ID, final int subId = activity.getIntent().getIntExtra(SUB_ID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID); SubscriptionManager.INVALID_SUBSCRIPTION_ID);
fillOperatorIccidset();
Log.d(TAG, "onCreate: subId = " + subId);
mMobileStateFilter = new IntentFilter( mMobileStateFilter = new IntentFilter(
TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
...@@ -192,6 +206,12 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -192,6 +206,12 @@ public class ApnSettings extends RestrictedSettingsFragment implements
addPreferencesFromResource(R.xml.apn_settings); addPreferencesFromResource(R.xml.apn_settings);
} }
@Override
public void onStop() {
super.onStop();
mApnSettingsHidden = true;
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
...@@ -205,6 +225,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -205,6 +225,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
if (!mRestoreDefaultApnMode) { if (!mRestoreDefaultApnMode) {
fillList(); fillList();
} }
mApnSettingsHidden = false;
} }
@Override @Override
...@@ -238,21 +259,86 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -238,21 +259,86 @@ public class ApnSettings extends RestrictedSettingsFragment implements
return null; return null;
} }
private void fillOperatorIccidset(){
mIccidSet = new HashSet<String>();
mIccidSet.add("8991840");
mIccidSet.add("8991854");
mIccidSet.add("8991855");
mIccidSet.add("8991856");
mIccidSet.add("8991857");
mIccidSet.add("8991858");
mIccidSet.add("8991859");
mIccidSet.add("899186");
mIccidSet.add("8991870");
mIccidSet.add("8991871");
mIccidSet.add("8991872");
mIccidSet.add("8991873");
mIccidSet.add("8991874");
}
private void fillList() { private void fillList() {
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
final String mccmnc = mSubscriptionInfo == null ? "" final String mccmnc = mSubscriptionInfo == null ? ""
: tm.getSimOperator(mSubscriptionInfo.getSubscriptionId()); : tm.getSimOperator(mSubscriptionInfo.getSubscriptionId());
Log.d(TAG, "mccmnc = " + mccmnc); Log.d(TAG, "mccmnc = " + mccmnc);
StringBuilder where = new StringBuilder("numeric=\"" + mccmnc + StringBuilder where = new StringBuilder("numeric=\"" + mccmnc +
"\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND user_visible!=0"); "\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND user_visible!=0");
if (SystemProperties.getBoolean("persist.sys.hideapn", true)) {
Log.d(TAG, "hiden apn feature enable.");
// remove the filtered items, no need to show in UI
if(getResources().getBoolean(R.bool.config_hide_ims_apns)){
mHideImsApn = true;
}
// Filer fota and dm for specail carrier
if (getResources().getBoolean(R.bool.config_hide_dm_enabled)) {
for (String plmn : getResources().getStringArray(R.array.hidedm_plmn_list)) {
if (plmn.equals(mccmnc)) {
where.append(" and name <>\"" + APN_NAME_DM + "\"");
break;
}
}
}
if (getResources().getBoolean(R.bool.config_hidesupl_enable)) {
boolean needHideSupl = false;
for (String plmn : getResources().getStringArray(R.array.hidesupl_plmn_list)) {
if (plmn.equals(mccmnc)) {
needHideSupl = true;
break;
}
}
if (needHideSupl) {
where.append(" and type <>\"" + PhoneConstants.APN_TYPE_SUPL + "\"");
}
}
// Hide mms if config is true
if (getResources().getBoolean(R.bool.config_hide_mms_enable)) {
where.append( " and type <>\"" + PhoneConstants.APN_TYPE_MMS + "\"");
}
}
if(getResources().getBoolean(R.bool.config_regional_hide_ims_and_dun_apns)){
where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_DUN + "\"");
where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_IMS + "\"");
}
if (mHideImsApn) { if (mHideImsApn) {
where.append(" AND NOT (type='ims')"); where.append(" AND NOT (type='ims')");
} }
if (isOperatorIccId()) {
where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_EMERGENCY + "\"");
where.append(" AND type <>\"" + PhoneConstants.APN_TYPE_IMS + "\"");
}
Log.d(TAG, "where---" + where);
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] { Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
"_id", "name", "apn", "type", "mvno_type", "mvno_match_data"}, where.toString(), "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only", "bearer",
null, Telephony.Carriers.DEFAULT_SORT_ORDER); "bearer_bitmask"}, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (cursor != null) { if (cursor != null) {
IccRecords r = null; IccRecords r = null;
...@@ -277,9 +363,30 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -277,9 +363,30 @@ public class ApnSettings extends RestrictedSettingsFragment implements
String type = cursor.getString(TYPES_INDEX); String type = cursor.getString(TYPES_INDEX);
String mvnoType = cursor.getString(MVNO_TYPE_INDEX); String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX); String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
boolean readOnly = (cursor.getInt(RO_INDEX) == 1);
String localizedName = getLocalizedName(getActivity(), cursor, NAME_INDEX);
if (!TextUtils.isEmpty(localizedName)) {
name = localizedName;
}
int bearer = cursor.getInt(BEARER_INDEX);
int bearerBitMask = cursor.getInt(BEARER_BITMASK_INDEX);
int fullBearer = ServiceState.getBitmaskForTech(bearer) | bearerBitMask;
int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
: SubscriptionManager.INVALID_SUBSCRIPTION_ID;
int radioTech = networkTypeToRilRidioTechnology(TelephonyManager.getDefault()
.getDataNetworkType(subId));
if (!ServiceState.bitmaskHasTech(fullBearer, radioTech)
&& (bearer != 0 || bearerBitMask != 0)) {
// In OOS, show APN with bearer as default
if ((radioTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) || (bearer == 0
&& radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) {
cursor.moveToNext();
continue;
}
}
ApnPreference pref = new ApnPreference(getPrefContext()); ApnPreference pref = new ApnPreference(getPrefContext());
pref.setApnReadOnly(readOnly);
pref.setKey(key); pref.setKey(key);
pref.setTitle(name); pref.setTitle(name);
pref.setSummary(apn); pref.setSummary(apn);
...@@ -316,6 +423,78 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -316,6 +423,78 @@ public class ApnSettings extends RestrictedSettingsFragment implements
} }
} }
private boolean isOperatorIccId(){
final String iccid = mSubscriptionInfo == null ? ""
: mSubscriptionInfo.getIccId();
Iterator<String> itr = mIccidSet.iterator();
while (itr.hasNext()) {
if (iccid.contains(itr.next())) {
return true;
}
}
return false;
}
private int networkTypeToRilRidioTechnology(int nt) {
switch(nt) {
case TelephonyManager.NETWORK_TYPE_GPRS:
return ServiceState.RIL_RADIO_TECHNOLOGY_GPRS;
case TelephonyManager.NETWORK_TYPE_EDGE:
return ServiceState.RIL_RADIO_TECHNOLOGY_EDGE;
case TelephonyManager.NETWORK_TYPE_UMTS:
return ServiceState.RIL_RADIO_TECHNOLOGY_UMTS;
case TelephonyManager.NETWORK_TYPE_HSDPA:
return ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA;
case TelephonyManager.NETWORK_TYPE_HSUPA:
return ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA;
case TelephonyManager.NETWORK_TYPE_HSPA:
return ServiceState.RIL_RADIO_TECHNOLOGY_HSPA;
case TelephonyManager.NETWORK_TYPE_CDMA:
return ServiceState.RIL_RADIO_TECHNOLOGY_IS95B;
case TelephonyManager.NETWORK_TYPE_1xRTT:
return ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
case TelephonyManager.NETWORK_TYPE_EVDO_0:
return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0;
case TelephonyManager.NETWORK_TYPE_EVDO_A:
return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A;
case TelephonyManager.NETWORK_TYPE_EVDO_B:
return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B;
case TelephonyManager.NETWORK_TYPE_EHRPD:
return ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD;
case TelephonyManager.NETWORK_TYPE_LTE:
return ServiceState.RIL_RADIO_TECHNOLOGY_LTE;
case TelephonyManager.NETWORK_TYPE_HSPAP:
return ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP;
case TelephonyManager.NETWORK_TYPE_GSM:
return ServiceState.RIL_RADIO_TECHNOLOGY_GSM;
case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
return ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA;
case TelephonyManager.NETWORK_TYPE_IWLAN:
return ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN;
case TelephonyManager.NETWORK_TYPE_LTE_CA:
return ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA;
default:
return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
}
}
public static String getLocalizedName(Context context, Cursor cursor, int index) {
// If can find a localized name, replace the APN name with it
String resName = cursor.getString(index);
String localizedName = null;
if (resName != null && !resName.isEmpty()) {
int resId = context.getResources().getIdentifier(resName, "string",
context.getPackageName());
try {
localizedName = context.getResources().getString(resId);
Log.d(TAG, "Replaced apn name with localized name");
} catch (NotFoundException e) {
Log.e(TAG, "Got execption while getting the localized apn name.", e);
}
}
return localizedName;
}
private void addApnToList(ApnPreference pref, ArrayList<ApnPreference> mnoList, private void addApnToList(ApnPreference pref, ArrayList<ApnPreference> mnoList,
ArrayList<ApnPreference> mvnoList, IccRecords r, String mvnoType, ArrayList<ApnPreference> mvnoList, IccRecords r, String mvnoType,
String mvnoMatchData) { String mvnoMatchData) {
...@@ -337,7 +516,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -337,7 +516,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
if (mAllowAddingApns) { if (mAllowAddingApns) {
menu.add(0, MENU_NEW, 0, menu.add(0, MENU_NEW, 0,
getResources().getString(R.string.menu_new)) getResources().getString(R.string.menu_new))
.setIcon(android.R.drawable.ic_menu_add) .setIcon(R.drawable.ic_menu_add_white)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
} }
menu.add(0, MENU_RESTORE, 0, menu.add(0, MENU_RESTORE, 0,
...@@ -358,6 +537,10 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -358,6 +537,10 @@ public class ApnSettings extends RestrictedSettingsFragment implements
case MENU_RESTORE: case MENU_RESTORE:
restoreDefaultApn(); restoreDefaultApn();
return true; return true;
case android.R.id.home:
getActivity().onBackPressed();
return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
...@@ -378,7 +561,11 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -378,7 +561,11 @@ public class ApnSettings extends RestrictedSettingsFragment implements
public boolean onPreferenceTreeClick(Preference preference) { public boolean onPreferenceTreeClick(Preference preference) {
int pos = Integer.parseInt(preference.getKey()); int pos = Integer.parseInt(preference.getKey());
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos); Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
startActivity(new Intent(Intent.ACTION_EDIT, url)); Intent intent = new Intent(Intent.ACTION_EDIT, url);
if (preference instanceof ApnPreference) {
intent.putExtra("DISABLE_EDITOR", ((ApnPreference) preference).getApnReadOnly());
}
startActivity(intent);
return true; return true;
} }
...@@ -399,13 +586,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -399,13 +586,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(APN_ID, mSelectedKey); values.put(APN_ID, mSelectedKey);
resolver.update(PREFERAPN_URI, values, null, null); resolver.update(getUri(PREFERAPN_URI), values, null, null);
} }
private String getSelectedApnKey() { private String getSelectedApnKey() {
String key = null; String key = null;
Cursor cursor = getContentResolver().query(PREFERAPN_URI, new String[] {"_id"}, Cursor cursor = getContentResolver().query(getUri(PREFERAPN_URI), new String[] {"_id"},
null, null, Telephony.Carriers.DEFAULT_SORT_ORDER); null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
if (cursor.getCount() > 0) { if (cursor.getCount() > 0) {
cursor.moveToFirst(); cursor.moveToFirst();
...@@ -450,7 +637,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -450,7 +637,9 @@ public class ApnSettings extends RestrictedSettingsFragment implements
fillList(); fillList();
getPreferenceScreen().setEnabled(true); getPreferenceScreen().setEnabled(true);
mRestoreDefaultApnMode = false; mRestoreDefaultApnMode = false;
removeDialog(DIALOG_RESTORE_DEFAULTAPN); // if current fragment is not visible, in background or Homekey is pressed,
// dismiss the dialog with state loss.
removeDialog(DIALOG_RESTORE_DEFAULTAPN, mApnSettingsHidden);
Toast.makeText( Toast.makeText(
activity, activity,
getResources().getString( getResources().getString(
...@@ -474,7 +663,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -474,7 +663,7 @@ public class ApnSettings extends RestrictedSettingsFragment implements
switch (msg.what) { switch (msg.what) {
case EVENT_RESTORE_DEFAULTAPN_START: case EVENT_RESTORE_DEFAULTAPN_START:
ContentResolver resolver = getContentResolver(); ContentResolver resolver = getContentResolver();
resolver.delete(DEFAULTAPN_URI, null, null); resolver.delete(getUri(DEFAULTAPN_URI), null, null);
mRestoreApnUiHandler mRestoreApnUiHandler
.sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_COMPLETE); .sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_COMPLETE);
break; break;
...@@ -496,4 +685,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements ...@@ -496,4 +685,13 @@ public class ApnSettings extends RestrictedSettingsFragment implements
} }
return null; return null;
} }
private Uri getUri(Uri uri) {
int subId = SubscriptionManager.getDefaultDataSubscriptionId();
if (mSubscriptionInfo != null && SubscriptionManager.isValidSubscriptionId(
mSubscriptionInfo.getSubscriptionId())) {
subId = mSubscriptionInfo.getSubscriptionId();
}
return Uri.withAppendedPath(uri, "/subId/" + subId);
}
} }
...@@ -53,6 +53,8 @@ import java.util.List; ...@@ -53,6 +53,8 @@ import java.util.List;
public class AppListPreference extends CustomListPreference { public class AppListPreference extends CustomListPreference {
public static final String ITEM_NONE_VALUE = ""; public static final String ITEM_NONE_VALUE = "";
public static final int TYPE_PACKAGE = 0;
public static final int TYPE_COMPONENT = 1;
protected final boolean mForWork; protected final boolean mForWork;
protected final int mUserId; protected final int mUserId;
...@@ -61,6 +63,7 @@ public class AppListPreference extends CustomListPreference { ...@@ -61,6 +63,7 @@ public class AppListPreference extends CustomListPreference {
private boolean mShowItemNone = false; private boolean mShowItemNone = false;
private CharSequence[] mSummaries; private CharSequence[] mSummaries;
private int mSystemAppIndex = -1; private int mSystemAppIndex = -1;
private int mType = TYPE_PACKAGE;
public class AppArrayAdapter extends ArrayAdapter<CharSequence> { public class AppArrayAdapter extends ArrayAdapter<CharSequence> {
private Drawable[] mImageDrawables = null; private Drawable[] mImageDrawables = null;
...@@ -190,6 +193,8 @@ public class AppListPreference extends CustomListPreference { ...@@ -190,6 +193,8 @@ public class AppListPreference extends CustomListPreference {
public void setComponentNames(ComponentName[] componentNames, ComponentName defaultCN, public void setComponentNames(ComponentName[] componentNames, ComponentName defaultCN,
CharSequence[] summaries) { CharSequence[] summaries) {
mSummaries = summaries; mSummaries = summaries;
mType = TYPE_COMPONENT;
// Look up all package names in PackageManager. Skip ones we can't find. // Look up all package names in PackageManager. Skip ones we can't find.
PackageManager pm = getContext().getPackageManager(); PackageManager pm = getContext().getPackageManager();
final int entryCount = componentNames.length + (mShowItemNone ? 1 : 0); final int entryCount = componentNames.length + (mShowItemNone ? 1 : 0);
...@@ -258,7 +263,18 @@ public class AppListPreference extends CustomListPreference { ...@@ -258,7 +263,18 @@ public class AppListPreference extends CustomListPreference {
if (state instanceof SavedState) { if (state instanceof SavedState) {
SavedState savedState = (SavedState) state; SavedState savedState = (SavedState) state;
mShowItemNone = savedState.showItemNone; mShowItemNone = savedState.showItemNone;
setPackageNames(savedState.entryValues, savedState.value); if (mType == TYPE_PACKAGE) {
setPackageNames(savedState.entryValues, savedState.value);
} else if (mType == TYPE_COMPONENT) {
int len = savedState.entryValues.length;
ComponentName[] entryValues = new ComponentName[len];
for(int i = 0; i < len; i++) {
entryValues[i] = ComponentName.unflattenFromString(
savedState.entryValues[i]+"");
}
setComponentNames(entryValues,
ComponentName.unflattenFromString(savedState.value+""));
}
mSummaries = savedState.summaries; mSummaries = savedState.summaries;
super.onRestoreInstanceState(savedState.superState); super.onRestoreInstanceState(savedState.superState);
} else { } else {
......
...@@ -161,21 +161,23 @@ public class BandMode extends Activity { ...@@ -161,21 +161,23 @@ public class BandMode extends Activity {
return; return;
} }
int size = bands[0]; // Always show Band 0, ie Automatic
item = new BandListItem(0);
if (size > 0) { mBandListAdapter.add(item);
mBandListAdapter.add( if (DBG) log("Add " + item.toString());
new BandListItem(Phone.BM_UNSPECIFIED)); //Always include AUTOMATIC
for (int i=1; i<=size; i++) { for (int i=0; i<bands.length; i++) {
if (bands[i] == Phone.BM_UNSPECIFIED) { if (i == 1)
continue; mBandListAdapter.add(
} new BandListItem(Phone.BM_UNSPECIFIED)); //Always include AUTOMATIC
item = new BandListItem(bands[i]); if (i > 0 && bands[i] == Phone.BM_UNSPECIFIED) {
mBandListAdapter.add(item); continue;
if (DBG) log("Add " + item.toString());
} }
addBandSuccess = true; item = new BandListItem(bands[i]);
mBandListAdapter.add(item);
if (DBG) log("Add " + item.toString());
} }
addBandSuccess = true;
} }
if (addBandSuccess == false) { if (addBandSuccess == false) {
......
/*
* Copyright (C) 2014-2016 The CyanogenMod Project
* Copyright (C) 2017 The LineageOS 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.
*/
package com.android.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class CarrierSelection extends Activity {
public static final String EXTRA_SUB_ID = "sub_id";
public static final int INVALID_SUB_ID = -1000;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final SubscriptionManager subscriptionManager = SubscriptionManager.from(this);
final List<SubscriptionInfo> subInfoList =
subscriptionManager.getActiveSubscriptionInfoList();
if (subInfoList == null) {
startNetworkSelection(INVALID_SUB_ID);
} else if (subInfoList.size() == 1) {
startNetworkSelection(subInfoList.get(0).getSubscriptionId());
} else {
createDialog(this, subInfoList).show();
}
}
public Dialog createDialog(final Context context, final List<SubscriptionInfo> subInfoList) {
final ArrayList<String> list = new ArrayList<String>();
final int selectableSubInfoLength = subInfoList == null ? 0 : subInfoList.size();
final DialogInterface.OnClickListener selectionListener =
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int value) {
final SubscriptionInfo sir = subInfoList.get(value);
startNetworkSelection(sir.getSubscriptionId());
}
};
Dialog.OnKeyListener keyListener = new Dialog.OnKeyListener() {
@Override
public boolean onKey(DialogInterface arg0, int keyCode,
KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
}
return true;
}
};
for (int i = 0; i < selectableSubInfoLength; ++i) {
final SubscriptionInfo sir = subInfoList.get(i);
CharSequence displayName = sir.getDisplayName();
if (displayName == null) {
displayName = "";
}
list.add(displayName.toString());
}
String[] arr = list.toArray(new String[0]);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
ListAdapter adapter = new CarrierSelection.SelectAccountListAdapter(
subInfoList,
builder.getContext(),
R.layout.select_account_list_item,
arr);
builder.setTitle(R.string.sim_select_card);
Dialog dialog = builder.setAdapter(adapter, selectionListener).create();
dialog.setOnKeyListener(keyListener);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
finish();
}
});
return dialog;
}
private void startNetworkSelection(int subId) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.phone",
"com.android.phone.NetworkSetting"));
if (subId != INVALID_SUB_ID) {
intent.putExtra(EXTRA_SUB_ID, subId);
}
startActivity(intent);
finish();
}
private class SelectAccountListAdapter extends ArrayAdapter<String> {
private Context mContext;
private int mResId;
private final float OPACITY = 0.54f;
private List<SubscriptionInfo> mSubInfoList;
public SelectAccountListAdapter(List<SubscriptionInfo> subInfoList,
Context context, int resource, String[] arr) {
super(context, resource, arr);
mContext = context;
mResId = resource;
mSubInfoList = subInfoList;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView;
final CarrierSelection.SelectAccountListAdapter.ViewHolder holder;
if (convertView == null) {
// Cache views for faster scrolling
rowView = inflater.inflate(mResId, null);
holder = new CarrierSelection.SelectAccountListAdapter.ViewHolder();
holder.title = (TextView) rowView.findViewById(R.id.title);
holder.summary = (TextView) rowView.findViewById(R.id.summary);
holder.icon = (ImageView) rowView.findViewById(R.id.icon);
rowView.setTag(holder);
} else {
rowView = convertView;
holder = (CarrierSelection.SelectAccountListAdapter.ViewHolder) rowView.getTag();
}
final SubscriptionInfo sir = mSubInfoList.get(position);
if (sir == null) {
holder.title.setText(getItem(position));
holder.summary.setText("");
holder.icon.setImageDrawable(getResources()
.getDrawable(R.drawable.ic_live_help));
holder.icon.setAlpha(OPACITY);
} else {
holder.title.setText(sir.getDisplayName());
holder.summary.setText(sir.getNumber());
holder.icon.setImageBitmap(sir.createIconBitmap(mContext));
}
return rowView;
}
private class ViewHolder {
TextView title;
TextView summary;
ImageView icon;
}
}
}
...@@ -33,6 +33,7 @@ import android.content.Context; ...@@ -33,6 +33,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.UserInfo; import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.hardware.fingerprint.Fingerprint; import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintManager.RemovalCallback; import android.hardware.fingerprint.FingerprintManager.RemovalCallback;
...@@ -43,18 +44,25 @@ import android.os.storage.StorageManager; ...@@ -43,18 +44,25 @@ import android.os.storage.StorageManager;
import android.security.KeyStore; import android.security.KeyStore;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen; import android.support.v7.preference.PreferenceScreen;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.EventLog; import android.util.EventLog;
import android.util.Log; import android.util.Log;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.settings.utils.SettingsDividerItemDecoration;
import com.android.settings.fingerprint.FingerprintEnrollBase; import com.android.settings.fingerprint.FingerprintEnrollBase;
import com.android.settings.fingerprint.FingerprintEnrollFindSensor; import com.android.settings.fingerprint.FingerprintEnrollFindSensor;
import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreference; import com.android.settingslib.RestrictedPreference;
import com.android.setupwizardlib.GlifPreferenceLayout;
import java.util.List; import java.util.List;
...@@ -80,6 +88,13 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -80,6 +88,13 @@ public class ChooseLockGeneric extends SettingsActivity {
return false; return false;
} }
@Override
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
layout.setFitsSystemWindows(false);
}
/* package */ Class<? extends Fragment> getFragmentClass() { /* package */ Class<? extends Fragment> getFragmentClass() {
return ChooseLockGenericFragment.class; return ChooseLockGenericFragment.class;
} }
...@@ -140,6 +155,11 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -140,6 +155,11 @@ public class ChooseLockGeneric extends SettingsActivity {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
final Activity activity = getActivity();
if (!Utils.isDeviceProvisioned(activity) && !canRunBeforeDeviceProvisioned()) {
activity.finish();
return;
}
String chooseLockAction = getActivity().getIntent().getAction(); String chooseLockAction = getActivity().getIntent().getAction();
mFingerprintManager = mFingerprintManager =
...@@ -148,6 +168,8 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -148,6 +168,8 @@ public class ChooseLockGeneric extends SettingsActivity {
mKeyStore = KeyStore.getInstance(); mKeyStore = KeyStore.getInstance();
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this.getActivity()); mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this.getActivity());
mLockPatternUtils = new LockPatternUtils(getActivity()); mLockPatternUtils = new LockPatternUtils(getActivity());
mLockPatternUtils.sanitizePassword();
mIsSetNewPassword = ACTION_SET_NEW_PARENT_PROFILE_PASSWORD.equals(chooseLockAction) mIsSetNewPassword = ACTION_SET_NEW_PARENT_PROFILE_PASSWORD.equals(chooseLockAction)
|| ACTION_SET_NEW_PASSWORD.equals(chooseLockAction); || ACTION_SET_NEW_PASSWORD.equals(chooseLockAction);
...@@ -167,16 +189,6 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -167,16 +189,6 @@ public class ChooseLockGeneric extends SettingsActivity {
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false); ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
mForChangeCredRequiredForBoot = getArguments() != null && getArguments().getBoolean( mForChangeCredRequiredForBoot = getArguments() != null && getArguments().getBoolean(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT); ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT);
if (mIsSetNewPassword) {
// In ACTION_SET_NEW_PARENT_PROFILE_PASSWORD or ACTION_SET_NEW_PASSWORD, the user
// will be asked to confirm the password if one has been set.
// On fingerprint supported device, fingerprint options are represented in the
// options. If the user chooses to skip fingerprint setup, ChooseLockGeneric is
// relaunched to only show options without fingerprint. In this case, we shouldn't
// ask the user to confirm the password again.
mPasswordConfirmed = getActivity().getIntent().getBooleanExtra(
PASSWORD_CONFIRMED, false);
}
if (savedInstanceState != null) { if (savedInstanceState != null) {
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED); mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
...@@ -227,6 +239,10 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -227,6 +239,10 @@ public class ChooseLockGeneric extends SettingsActivity {
addHeaderView(); addHeaderView();
} }
protected boolean canRunBeforeDeviceProvisioned() {
return false;
}
protected void addHeaderView() { protected void addHeaderView() {
if (mForFingerprint) { if (mForFingerprint) {
setHeaderView(R.layout.choose_lock_generic_fingerprint_header); setHeaderView(R.layout.choose_lock_generic_fingerprint_header);
...@@ -237,6 +253,32 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -237,6 +253,32 @@ public class ChooseLockGeneric extends SettingsActivity {
} }
} }
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (mForFingerprint) {
GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
layout.setDividerItemDecoration(new SettingsDividerItemDecoration(getContext()));
layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
layout.setHeaderText(getActivity().getTitle());
// Use the dividers in SetupWizardRecyclerLayout. Suppress the dividers in
// PreferenceFragment.
setDivider(null);
}
}
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
Bundle savedInstanceState) {
if (mForFingerprint) {
GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
}
return super.onCreateRecyclerView(inflater, parent, savedInstanceState);
}
@Override @Override
public boolean onPreferenceTreeClick(Preference preference) { public boolean onPreferenceTreeClick(Preference preference) {
final String key = preference.getKey(); final String key = preference.getKey();
...@@ -247,11 +289,12 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -247,11 +289,12 @@ public class ChooseLockGeneric extends SettingsActivity {
showFactoryResetProtectionWarningDialog(key); showFactoryResetProtectionWarningDialog(key);
return true; return true;
} else if (KEY_SKIP_FINGERPRINT.equals(key)) { } else if (KEY_SKIP_FINGERPRINT.equals(key)) {
Intent chooseLockGenericIntent = new Intent(getActivity(), ChooseLockGeneric.class); Intent chooseLockGenericIntent = new Intent(getActivity(),
ChooseLockGeneric.InternalActivity.class);
chooseLockGenericIntent.setAction(getIntent().getAction()); chooseLockGenericIntent.setAction(getIntent().getAction());
// Forward the target user id to ChooseLockGeneric. // Forward the target user id to ChooseLockGeneric.
chooseLockGenericIntent.putExtra(Intent.EXTRA_USER_ID, mUserId); chooseLockGenericIntent.putExtra(Intent.EXTRA_USER_ID, mUserId);
chooseLockGenericIntent.putExtra(PASSWORD_CONFIRMED, mPasswordConfirmed); chooseLockGenericIntent.putExtra(CONFIRM_CREDENTIALS, !mPasswordConfirmed);
startActivityForResult(chooseLockGenericIntent, SKIP_FINGERPRINT_REQUEST); startActivityForResult(chooseLockGenericIntent, SKIP_FINGERPRINT_REQUEST);
return true; return true;
} else { } else {
...@@ -405,12 +448,16 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -405,12 +448,16 @@ public class ChooseLockGeneric extends SettingsActivity {
final String key[] = { KEY_UNLOCK_SET_PATTERN, final String key[] = { KEY_UNLOCK_SET_PATTERN,
KEY_UNLOCK_SET_PIN, KEY_UNLOCK_SET_PIN,
KEY_UNLOCK_SET_PASSWORD }; KEY_UNLOCK_SET_PASSWORD };
final int icon[] = { R.drawable.ic_security_pattern,
R.drawable.ic_security_pin,
R.drawable.ic_security_pwd};
final int res[] = { R.string.fingerprint_unlock_set_unlock_pattern, final int res[] = { R.string.fingerprint_unlock_set_unlock_pattern,
R.string.fingerprint_unlock_set_unlock_pin, R.string.fingerprint_unlock_set_unlock_pin,
R.string.fingerprint_unlock_set_unlock_password }; R.string.fingerprint_unlock_set_unlock_password };
for (int i = 0; i < key.length; i++) { for (int i = 0; i < key.length; i++) {
Preference pref = findPreference(key[i]); Preference pref = findPreference(key[i]);
if (pref != null) { // can be removed by device admin if (pref != null) { // can be removed by device admin
pref.setIcon(icon[i]);
pref.setTitle(res[i]); pref.setTitle(res[i]);
} }
} }
...@@ -774,6 +821,7 @@ public class ChooseLockGeneric extends SettingsActivity { ...@@ -774,6 +821,7 @@ public class ChooseLockGeneric extends SettingsActivity {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
mLockPatternUtils.sanitizePassword();
} }
@Override @Override
......
...@@ -75,7 +75,7 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -75,7 +75,7 @@ public class ChooseLockPattern extends SettingsActivity {
public static Intent createIntent(Context context, public static Intent createIntent(Context context,
boolean requirePassword, boolean confirmCredentials, int userId) { boolean requirePassword, boolean confirmCredentials, int userId) {
Intent intent = new Intent(context, ChooseLockPattern.class); Intent intent = new Intent(context, ChooseLockPatternSize.class);
intent.putExtra("key_lock_method", "pattern"); intent.putExtra("key_lock_method", "pattern");
intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials); intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials);
intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword); intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword);
...@@ -151,16 +151,12 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -151,16 +151,12 @@ public class ChooseLockPattern extends SettingsActivity {
protected List<LockPatternView.Cell> mChosenPattern = null; protected List<LockPatternView.Cell> mChosenPattern = null;
private boolean mHideDrawer = false; private boolean mHideDrawer = false;
private byte mPatternSize = LockPatternUtils.PATTERN_SIZE_DEFAULT;
/** /**
* The patten used during the help screen to show how to draw a pattern. * The patten used during the help screen to show how to draw a pattern.
*/ */
private final List<LockPatternView.Cell> mAnimatePattern = private List<LockPatternView.Cell> mAnimatePattern;
Collections.unmodifiableList(Lists.newArrayList(
LockPatternView.Cell.of(0, 0),
LockPatternView.Cell.of(0, 1),
LockPatternView.Cell.of(1, 1),
LockPatternView.Cell.of(2, 1)
));
@Override @Override
public void onActivityResult(int requestCode, int resultCode, public void onActivityResult(int requestCode, int resultCode,
...@@ -209,7 +205,13 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -209,7 +205,13 @@ public class ChooseLockPattern extends SettingsActivity {
if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) { if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) {
if (mChosenPattern == null) throw new IllegalStateException( if (mChosenPattern == null) throw new IllegalStateException(
"null chosen pattern in stage 'need to confirm"); "null chosen pattern in stage 'need to confirm");
if (mChosenPattern.equals(pattern)) {
final String chosenPatternStr = LockPatternUtils.patternToString(
mChosenPattern, mPatternSize);
final String potentialPatternStr = LockPatternUtils.patternToString(
pattern, mPatternSize);
if (chosenPatternStr.equals(potentialPatternStr)) {
updateStage(Stage.ChoiceConfirmed); updateStage(Stage.ChoiceConfirmed);
} else { } else {
updateStage(Stage.ConfirmWrong); updateStage(Stage.ConfirmWrong);
...@@ -386,7 +388,8 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -386,7 +388,8 @@ public class ChooseLockPattern extends SettingsActivity {
w.setBlocking(true); w.setBlocking(true);
w.setListener(this); w.setListener(this);
w.start(mChooseLockSettingsHelper.utils(), required, w.start(mChooseLockSettingsHelper.utils(), required,
false, 0, LockPatternUtils.stringToPattern(current), current, mUserId); false, 0, LockPatternUtils.stringToPattern(current, mPatternSize),
current, mUserId, mPatternSize);
} }
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false); mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
} }
...@@ -394,6 +397,16 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -394,6 +397,16 @@ public class ChooseLockPattern extends SettingsActivity {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
mPatternSize = getActivity().getIntent().getByteExtra("pattern_size",
LockPatternUtils.PATTERN_SIZE_DEFAULT);
LockPatternView.Cell.updateSize(mPatternSize);
mAnimatePattern = Collections.unmodifiableList(Lists.newArrayList(
LockPatternView.Cell.of(0, 0, mPatternSize),
LockPatternView.Cell.of(0, 1, mPatternSize),
LockPatternView.Cell.of(1, 1, mPatternSize),
LockPatternView.Cell.of(2, 1, mPatternSize)
));
final GlifLayout layout = (GlifLayout) inflater.inflate( final GlifLayout layout = (GlifLayout) inflater.inflate(
R.layout.choose_lock_pattern, container, false); R.layout.choose_lock_pattern, container, false);
layout.setHeaderText(getActivity().getTitle()); layout.setHeaderText(getActivity().getTitle());
...@@ -408,6 +421,8 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -408,6 +421,8 @@ public class ChooseLockPattern extends SettingsActivity {
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener); mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
mLockPatternView.setTactileFeedbackEnabled( mLockPatternView.setTactileFeedbackEnabled(
mChooseLockSettingsHelper.utils().isTactileFeedbackEnabled()); mChooseLockSettingsHelper.utils().isTactileFeedbackEnabled());
mLockPatternView.setLockPatternUtils(mChooseLockSettingsHelper.utils());
mLockPatternView.setLockPatternSize(mPatternSize);
mFooterText = (TextView) view.findViewById(R.id.footerText); mFooterText = (TextView) view.findViewById(R.id.footerText);
...@@ -452,7 +467,9 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -452,7 +467,9 @@ public class ChooseLockPattern extends SettingsActivity {
// restore from previous state // restore from previous state
final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE); final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE);
if (patternString != null) { if (patternString != null) {
mChosenPattern = LockPatternUtils.stringToPattern(patternString); mChosenPattern = LockPatternUtils.stringToPattern(patternString,
mPatternSize);
mLockPatternView.setPattern(DisplayMode.Correct, mChosenPattern);
} }
if (mCurrentPattern == null) { if (mCurrentPattern == null) {
...@@ -555,7 +572,7 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -555,7 +572,7 @@ public class ChooseLockPattern extends SettingsActivity {
outState.putInt(KEY_UI_STAGE, mUiStage.ordinal()); outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
if (mChosenPattern != null) { if (mChosenPattern != null) {
outState.putString(KEY_PATTERN_CHOICE, outState.putString(KEY_PATTERN_CHOICE,
LockPatternUtils.patternToString(mChosenPattern)); LockPatternUtils.patternToString(mChosenPattern, mPatternSize));
} }
if (mCurrentPattern != null) { if (mCurrentPattern != null) {
...@@ -672,7 +689,8 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -672,7 +689,8 @@ public class ChooseLockPattern extends SettingsActivity {
final boolean required = getActivity().getIntent().getBooleanExtra( final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true); EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
mSaveAndFinishWorker.start(mChooseLockSettingsHelper.utils(), required, mSaveAndFinishWorker.start(mChooseLockSettingsHelper.utils(), required,
mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern, mUserId); mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern,
mUserId, mPatternSize);
} }
@Override @Override
...@@ -695,15 +713,18 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -695,15 +713,18 @@ public class ChooseLockPattern extends SettingsActivity {
private List<LockPatternView.Cell> mChosenPattern; private List<LockPatternView.Cell> mChosenPattern;
private String mCurrentPattern; private String mCurrentPattern;
private boolean mLockVirgin; private boolean mLockVirgin;
private byte mPatternSize;
public void start(LockPatternUtils utils, boolean credentialRequired, public void start(LockPatternUtils utils, boolean credentialRequired,
boolean hasChallenge, long challenge, boolean hasChallenge, long challenge,
List<LockPatternView.Cell> chosenPattern, String currentPattern, int userId) { List<LockPatternView.Cell> chosenPattern, String currentPattern, int userId,
byte patternSize) {
prepare(utils, credentialRequired, hasChallenge, challenge, userId); prepare(utils, credentialRequired, hasChallenge, challenge, userId);
mCurrentPattern = currentPattern; mCurrentPattern = currentPattern;
mChosenPattern = chosenPattern; mChosenPattern = chosenPattern;
mUserId = userId; mUserId = userId;
mPatternSize = patternSize;
mLockVirgin = !mUtils.isPatternEverChosen(mUserId); mLockVirgin = !mUtils.isPatternEverChosen(mUserId);
...@@ -714,6 +735,7 @@ public class ChooseLockPattern extends SettingsActivity { ...@@ -714,6 +735,7 @@ public class ChooseLockPattern extends SettingsActivity {
protected Intent saveAndVerifyInBackground() { protected Intent saveAndVerifyInBackground() {
Intent result = null; Intent result = null;
final int userId = mUserId; final int userId = mUserId;
mUtils.setLockPatternSize(mPatternSize, userId);
mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId); mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId);
if (mHasChallenge) { if (mHasChallenge) {
......
/*
* Copyright (C) 2012-2013 The CyanogenMod 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.
*/
package com.android.settings;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.utils.SettingsDividerItemDecoration;
import com.android.setupwizardlib.GlifPreferenceLayout;
import org.cyanogenmod.internal.logging.CMMetricsLogger;
public class ChooseLockPatternSize extends PreferenceActivity {
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternSizeFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
@Override
protected boolean isValidFragment(String fragmentName) {
if (ChooseLockPatternSizeFragment.class.getName().equals(fragmentName)) return true;
return false;
}
public static class ChooseLockPatternSizeFragment extends SettingsPreferenceFragment {
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this.getActivity());
if (!(getActivity() instanceof ChooseLockPatternSize)) {
throw new SecurityException("Fragment contained in wrong activity");
}
addPreferencesFromResource(R.xml.security_settings_pattern_size);
setHeaderView(R.layout.choose_lock_pattern_size_header);
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
final String key = preference.getKey();
byte patternSize;
if ("lock_pattern_size_4".equals(key)) {
patternSize = 4;
} else if ("lock_pattern_size_5".equals(key)) {
patternSize = 5;
} else if ("lock_pattern_size_6".equals(key)) {
patternSize = 6;
} else {
patternSize = 3;
}
final boolean isFallback = getActivity().getIntent()
.getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
Intent intent = new Intent(getActivity(), ChooseLockPattern.class);
intent.putExtra("pattern_size", patternSize);
intent.putExtra("key_lock_method", "pattern");
intent.putExtra("confirm_credentials", false);
intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK,
isFallback);
Intent originatingIntent = getActivity().getIntent();
// Forward the challenge extras if available in originating intent.
if (originatingIntent.hasExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE)) {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE,
originatingIntent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false));
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE,
originatingIntent.getLongExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0));
}
// Forward the Encryption interstitial required password selection
if (originatingIntent.hasExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD)) {
intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, originatingIntent
.getBooleanExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true));
}
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent);
finish();
return true;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
layout.setDividerItemDecoration(new SettingsDividerItemDecoration(getContext()));
layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
// Use the dividers in SetupWizardRecyclerLayout. Suppress the dividers in
// PreferenceFragment.
setDivider(null);
}
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
Bundle savedInstanceState) {
GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
}
@Override
protected int getMetricsCategory() {
return CMMetricsLogger.CHOOSE_LOCK_PATTERN_SIZE;
}
}
}
...@@ -27,6 +27,8 @@ import android.os.UserManager; ...@@ -27,6 +27,8 @@ import android.os.UserManager;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import org.cyanogenmod.internal.util.CmLockPatternUtils;
public final class ChooseLockSettingsHelper { public final class ChooseLockSettingsHelper {
static final String EXTRA_KEY_TYPE = "type"; static final String EXTRA_KEY_TYPE = "type";
...@@ -40,12 +42,14 @@ public final class ChooseLockSettingsHelper { ...@@ -40,12 +42,14 @@ public final class ChooseLockSettingsHelper {
@VisibleForTesting LockPatternUtils mLockPatternUtils; @VisibleForTesting LockPatternUtils mLockPatternUtils;
private CmLockPatternUtils mCmLockPatternUtils;
private Activity mActivity; private Activity mActivity;
private Fragment mFragment; private Fragment mFragment;
public ChooseLockSettingsHelper(Activity activity) { public ChooseLockSettingsHelper(Activity activity) {
mActivity = activity; mActivity = activity;
mLockPatternUtils = new LockPatternUtils(activity); mLockPatternUtils = new LockPatternUtils(activity);
mCmLockPatternUtils = new CmLockPatternUtils(activity);
} }
public ChooseLockSettingsHelper(Activity activity, Fragment fragment) { public ChooseLockSettingsHelper(Activity activity, Fragment fragment) {
...@@ -57,6 +61,10 @@ public final class ChooseLockSettingsHelper { ...@@ -57,6 +61,10 @@ public final class ChooseLockSettingsHelper {
return mLockPatternUtils; return mLockPatternUtils;
} }
public CmLockPatternUtils cmUtils() {
return mCmLockPatternUtils;
}
/** /**
* If a pattern, password or PIN exists, prompt the user before allowing them to change it. * If a pattern, password or PIN exists, prompt the user before allowing them to change it.
* *
......