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
This commit is contained in:
@@ -35,12 +35,8 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
||||
|
||||
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 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
||||
@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 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
||||
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 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -167,7 +88,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user