DO NOT MERGE: Add UI toggle to control connections to carrier networks.

Bug: 31003437
Change-Id: Ieb6dfc0dc989068e151a1d0e376f56f67c9790b2
This commit is contained in:
pkanwar
2016-12-11 15:36:34 -08:00
parent f6b8321654
commit 675122ad51
3 changed files with 23 additions and 0 deletions

View File

@@ -1599,6 +1599,10 @@
<string name="wifi_setting_on_during_sleep_title">Wi\u2011Fi on during sleep</string>
<!-- Generic error message when the sleep policy could not be set. -->
<string name="wifi_setting_sleep_policy_error">There was a problem changing the setting</string>
<!-- Checkbox title for option to toggle connecting to carrier networks[CHAR LIMIT=30] -->
<string name="wifi_connect_carrier_networks">Connect to operator networks</string>
<!-- Checkbox title for option to toggle suspend power optimizations [CHAR LIMIT=30] -->
<string name="wifi_connect_carrier_networks_summary">Connect to operator networks when available</string>
<!-- Checkbox title for option to toggle suspend power optimizations [CHAR LIMIT=30] -->
<string name="wifi_suspend_efficiency_title">Improve efficiency</string>
<!-- Checkbox title for option to toggle suspend power optimizations -->

View File

@@ -29,6 +29,11 @@
android:title="@string/wifi_notify_open_networks"
android:summary="@string/wifi_notify_open_networks_summary" />
<SwitchPreference
android:key="connect_carrier_networks"
android:title="@string/wifi_connect_carrier_networks"
android:summary="@string/wifi_connect_carrier_networks_summary" />
<ListPreference
android:key="sleep_policy"
android:title="@string/wifi_setting_sleep_policy_title"

View File

@@ -54,6 +54,7 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
private static final String KEY_SLEEP_POLICY = "sleep_policy";
private static final String KEY_CELLULAR_FALLBACK = "wifi_cellular_data_fallback";
private static final String KEY_WIFI_ASSISTANT = "wifi_assistant";
private static final String KEY_CONNECT_CARRIER_NETWORKS = "connect_carrier_networks";
private WifiManager mWifiManager;
private NetworkScoreManager mNetworkScoreManager;
@@ -98,12 +99,21 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
removePreference(KEY_SAVED_NETWORKS);
}
if (!mWifiManager.hasCarrierConfiguredNetworks()){
removePreference(KEY_CONNECT_CARRIER_NETWORKS);
}
SwitchPreference notifyOpenNetworks =
(SwitchPreference) findPreference(KEY_NOTIFY_OPEN_NETWORKS);
notifyOpenNetworks.setChecked(Settings.Global.getInt(getContentResolver(),
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
notifyOpenNetworks.setEnabled(mWifiManager.isWifiEnabled());
SwitchPreference connectToCarrierNetworks =
(SwitchPreference) findPreference(KEY_CONNECT_CARRIER_NETWORKS);
connectToCarrierNetworks.setChecked(Settings.Global.getInt(getContentResolver(),
Settings.Global.WIFI_CONNECT_CARRIER_NETWORKS, 0) == 1);
final Context context = getActivity();
if (avoidBadWifiConfig()) {
// Hide preference toggle, always avoid bad wifi networks.
@@ -187,6 +197,10 @@ public class ConfigureWifiSettings extends SettingsPreferenceFragment
String settingName = Settings.Global.NETWORK_AVOID_BAD_WIFI;
Settings.Global.putString(getContentResolver(), settingName,
((SwitchPreference) preference).isChecked() ? "1" : null);
} else if (KEY_CONNECT_CARRIER_NETWORKS.equals(key)) {
Settings.Global.putInt(getContentResolver(),
Settings.Global.WIFI_CONNECT_CARRIER_NETWORKS,
((SwitchPreference) preference).isChecked() ? 1 : 0);
} else {
return super.onPreferenceTreeClick(preference);
}