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:
@@ -999,14 +999,6 @@
|
|||||||
<!-- Wi-Fi Advanced Settings --> <skip />
|
<!-- Wi-Fi Advanced Settings --> <skip />
|
||||||
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. -->
|
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. -->
|
||||||
<string name="wifi_advanced_titlebar">Advanced</string>
|
<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 -->
|
<!-- Wi-Fi settings screen, setting title for setting the wifi sleep policy -->
|
||||||
<string name="wifi_setting_sleep_policy_title">Wi-Fi sleep policy</string>
|
<string name="wifi_setting_sleep_policy_title">Wi-Fi sleep policy</string>
|
||||||
<!-- Wi-Fi settings screen, setting summary for setting the wifi sleep policy -->
|
<!-- Wi-Fi settings screen, setting summary for setting the wifi sleep policy -->
|
||||||
|
@@ -17,13 +17,6 @@
|
|||||||
<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">
|
||||||
|
|
||||||
<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
|
<ListPreference
|
||||||
android:key="sleep_policy"
|
android:key="sleep_policy"
|
||||||
android:title="@string/wifi_setting_sleep_policy_title"
|
android:title="@string/wifi_setting_sleep_policy_title"
|
||||||
|
@@ -35,12 +35,8 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private static final String KEY_MAC_ADDRESS = "mac_address";
|
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_CURRENT_IP_ADDRESS = "current_ip_address";
|
||||||
private static final String KEY_NUM_CHANNELS = "num_channels";
|
|
||||||
private static final String KEY_SLEEP_POLICY = "sleep_policy";
|
private static final String KEY_SLEEP_POLICY = "sleep_policy";
|
||||||
|
|
||||||
//Tracks ro.debuggable (1 on userdebug builds)
|
|
||||||
private static int DEBUGGABLE;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -50,77 +46,16 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove user control of regulatory domain
|
|
||||||
* channel count settings in non userdebug builds
|
|
||||||
*/
|
|
||||||
if (DEBUGGABLE == 1) {
|
|
||||||
initNumChannelsPreference();
|
|
||||||
}
|
|
||||||
initSleepPolicyPreference();
|
initSleepPolicyPreference();
|
||||||
refreshWifiInfo();
|
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() {
|
private void initSleepPolicyPreference() {
|
||||||
ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
||||||
pref.setOnPreferenceChangeListener(this);
|
pref.setOnPreferenceChangeListener(this);
|
||||||
@@ -133,21 +68,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
String key = preference.getKey();
|
String key = preference.getKey();
|
||||||
if (key == null) return true;
|
if (key == null) return true;
|
||||||
|
|
||||||
if (key.equals(KEY_NUM_CHANNELS)) {
|
if (key.equals(KEY_SLEEP_POLICY)) {
|
||||||
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)) {
|
|
||||||
try {
|
try {
|
||||||
Settings.System.putInt(getContentResolver(),
|
Settings.System.putInt(getContentResolver(),
|
||||||
Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
|
Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
|
||||||
@@ -157,7 +78,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +88,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS);
|
Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS);
|
||||||
String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
|
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));
|
: getActivity().getString(R.string.status_unavailable));
|
||||||
|
|
||||||
Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS);
|
Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS);
|
||||||
|
Reference in New Issue
Block a user