Remove channel control from debug builds
We dont need this in the UI now that
channel settings is gone. The country
code setting can be done from CLI
for debug purposes.
Bug: 2936741
Change-Id: Ic61abac30af99611af4d67662355068cea6dd4ed
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d510018..2d1a599 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -999,14 +999,6 @@
<!-- Wi-Fi Advanced Settings --> <skip />
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. -->
<string name="wifi_advanced_titlebar">Advanced</string>
- <!-- Wi-Fi settings screen, setting title for choosing the number of channels to be used -->
- <string name="wifi_setting_num_channels_title">Regulatory domain</string>
- <!-- Wi-Fi settings screen, setting summary for choosing the number of channels to be used -->
- <string name="wifi_setting_num_channels_summary">Set the number of channels to use</string>
- <!-- Wi-Fi settings screen, generic error message when the regulatory domain could not be set. -->
- <string name="wifi_setting_num_channels_error">There was a problem setting the regulatory domain.</string>
- <!-- Wi-Fi settings screen, label to be appended to the count in displaying the list of valid channel counts -->
- <string name="wifi_setting_num_channels_channel_phrase"><xliff:g id="num_channels">%1$d</xliff:g> channels</string>
<!-- Wi-Fi settings screen, setting title for setting the wifi sleep policy -->
<string name="wifi_setting_sleep_policy_title">Wi-Fi sleep policy</string>
<!-- Wi-Fi settings screen, setting summary for setting the wifi sleep policy -->
diff --git a/res/xml/wifi_advanced_settings.xml b/res/xml/wifi_advanced_settings.xml
index 8496428..7ccd588 100644
--- a/res/xml/wifi_advanced_settings.xml
+++ b/res/xml/wifi_advanced_settings.xml
@@ -18,13 +18,6 @@
android:title="@string/wifi_advanced_titlebar">
<ListPreference
- android:key="num_channels"
- android:title="@string/wifi_setting_num_channels_title"
- android:summary="@string/wifi_setting_num_channels_summary"
- android:persistent="false"
- />
-
- <ListPreference
android:key="sleep_policy"
android:title="@string/wifi_setting_sleep_policy_title"
android:summary="@string/wifi_setting_sleep_policy_summary"
diff --git a/src/com/android/settings/wifi/AdvancedSettings.java b/src/com/android/settings/wifi/AdvancedSettings.java
index c88073d..0d33a10 100644
--- a/src/com/android/settings/wifi/AdvancedSettings.java
+++ b/src/com/android/settings/wifi/AdvancedSettings.java
@@ -35,12 +35,8 @@
private static final String KEY_MAC_ADDRESS = "mac_address";
private static final String KEY_CURRENT_IP_ADDRESS = "current_ip_address";
- private static final String KEY_NUM_CHANNELS = "num_channels";
private static final String KEY_SLEEP_POLICY = "sleep_policy";
- //Tracks ro.debuggable (1 on userdebug builds)
- private static int DEBUGGABLE;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -50,77 +46,16 @@
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
-
- DEBUGGABLE = SystemProperties.getInt("ro.debuggable", 0);
-
- /**
- * Remove user control of regulatory domain
- * channel count settings in non userdebug builds
- */
- if (DEBUGGABLE == 1) {
- /*
- * Fix the Run-time IllegalStateException that ListPreference requires an entries
- * array and an entryValues array, this exception occurs when user open/close the
- * slider in the Regulatory domain dialog.
- */
- initNumChannelsPreference();
- } else {
- Preference chanPref = findPreference(KEY_NUM_CHANNELS);
- if (chanPref != null) {
- getPreferenceScreen().removePreference(chanPref);
- }
- }
}
-
+
@Override
public void onResume() {
super.onResume();
- /**
- * Remove user control of regulatory domain
- * channel count settings in non userdebug builds
- */
- if (DEBUGGABLE == 1) {
- initNumChannelsPreference();
- }
initSleepPolicyPreference();
refreshWifiInfo();
}
- private void initNumChannelsPreference() {
- ListPreference pref = (ListPreference) findPreference(KEY_NUM_CHANNELS);
- pref.setOnPreferenceChangeListener(this);
-
- WifiManager wifiManager = (WifiManager) getSystemService(Activity.WIFI_SERVICE);
- /*
- * Generate the list of valid channel counts to show in the ListPreference.
- * The values are numerical, so the only text to be localized is the
- * "channel_word" resource.
- */
- int[] validChannelCounts = wifiManager.getValidChannelCounts();
- if (validChannelCounts == null) {
- Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error,
- Toast.LENGTH_SHORT).show();
- pref.setEnabled(false);
- return;
- }
- String[] entries = new String[validChannelCounts.length];
- String[] entryValues = new String[validChannelCounts.length];
-
- for (int i = 0; i < validChannelCounts.length; i++) {
- entryValues[i] = String.valueOf(validChannelCounts[i]);
- entries[i] = getActivity().getString(R.string.wifi_setting_num_channels_channel_phrase,
- validChannelCounts[i]);
- }
- pref.setEntries(entries);
- pref.setEntryValues(entryValues);
- pref.setEnabled(true);
- int numChannels = wifiManager.getNumAllowedChannels();
- if (numChannels >= 0) {
- pref.setValue(String.valueOf(numChannels));
- }
- }
-
private void initSleepPolicyPreference() {
ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
pref.setOnPreferenceChangeListener(this);
@@ -133,21 +68,7 @@
String key = preference.getKey();
if (key == null) return true;
- if (key.equals(KEY_NUM_CHANNELS)) {
- try {
- int numChannels = Integer.parseInt((String) newValue);
- WifiManager wifiManager = (WifiManager) getSystemService(Activity.WIFI_SERVICE);
- if (!wifiManager.setNumAllowedChannels(numChannels, true)) {
- Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error,
- Toast.LENGTH_SHORT).show();
- }
- } catch (NumberFormatException e) {
- Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error,
- Toast.LENGTH_SHORT).show();
- return false;
- }
-
- } else if (key.equals(KEY_SLEEP_POLICY)) {
+ if (key.equals(KEY_SLEEP_POLICY)) {
try {
Settings.System.putInt(getContentResolver(),
Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
@@ -157,7 +78,7 @@
return false;
}
}
-
+
return true;
}
@@ -167,7 +88,7 @@
Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS);
String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
- wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress
+ wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress
: getActivity().getString(R.string.status_unavailable));
Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS);