<item>600000</item>
</string-array>
+ <!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi region code. -->
+ <string-array name="wifi_countrycode_entries">
+ <item>United States</item>
+ <item>Canada, Taiwan</item>
+ <item>Germany</item>
+ <item>Europe</item>
+ <item>Japan, Russia</item>
+ <item>Australia</item>
+ <item>China</item>
+ <item>Korea</item>
+ <item>South Africa, Turkey</item>
+ <item>Israel, Singapore</item>
+ <item>Brazil</item>
+ <item>India</item>
+ </string-array>
+
+ <string-array name="wifi_countrycode_values" translatable="false">
+ <item>US</item>
+ <item>CA</item>
+ <item>DE</item>
+ <item>GB</item>
+ <item>JP</item>
+ <item>AU</item>
+ <item>CN</item>
+ <item>KR</item>
+ <item>TR</item>
+ <item>SG</item>
+ <item>BR</item>
+ <item>IN</item>
+ </string-array>
</resources>
<string name="security_settings_fingerprint_sensor_location_left">left side</string>
<string name="security_settings_fingerprint_sensor_location_right">right side</string>
+ <!-- Wi-Fi region code -->
+ <string name="wifi_setting_countrycode_title">Wi\u2011Fi region code</string>
+ <!-- Wi-Fi settings screen, setting summary for setting the wifi frequency band [CHAR LIMIT=50]-->
+ <string name="wifi_setting_countrycode_summary">Specify the region code for Wi\u2011Fi</string>
+ <!-- Wi-Fi settings screen, error message when the frequency band could not be set [CHAR LIMIT=50]. -->
+ <string name="wifi_setting_countrycode_error">There was a problem setting the region code.</string>
+
<!-- Wake on plug -->
<string name="wake_when_plugged_or_unplugged_title">Wake on plug</string>
<string name="wake_when_plugged_or_unplugged_summary">Turn the screen on when connecting or disconnecting a power source</string>
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
android:key="install_credentials"
android:title="@string/wifi_install_credentials"
import android.app.DialogFragment;
import android.content.Context;
import android.content.Intent;
+import android.net.wifi.WifiManager;
import android.net.wifi.WpsInfo;
import android.os.Bundle;
import android.os.UserManager;
private static final String KEY_PRIORITY_SETTINGS = "wifi_priority_settings";
+ private static final String KEY_COUNTRY_CODE = "wifi_countrycode";
+
private static final String KEY_AUTO_CONNECT_ENABLE = "auto_connect_type";
private static final String WIFI_AUTO_CONNECT_TYPE = "wifi_auto_connect_type";
private static final int AUTO_CONNECT_ENABLED = 0;
private ListPreference mCellularToWlanPref;
private boolean mUnavailable;
+ private WifiManager mWifiManager;
public AdvancedWifiSettings() {
super(UserManager.DISALLOW_CONFIG_WIFI);
getEmptyTextView().setText(R.string.wifi_advanced_not_available);
if (mUnavailable) {
getPreferenceScreen().removeAll();
+ } else {
+ mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
}
}
Log.d(TAG, "Fail to get priority pref...");
}
+ ListPreference ccodePref = (ListPreference) findPreference(KEY_COUNTRY_CODE);
+ if (ccodePref != null) {
+ ccodePref.setOnPreferenceChangeListener(this);
+ String value = mWifiManager.getCountryCode();
+ if (value != null) {
+ ccodePref.setValue(value);
+ } else {
+ Log.e(TAG, "Failed to fetch country code");
+ }
+ }
+
mAutoConnectEnablePref =
(CheckBoxPreference) findPreference(KEY_AUTO_CONNECT_ENABLE);
if (mAutoConnectEnablePref != null) {
final Context context = getActivity();
String key = preference.getKey();
+ if (KEY_COUNTRY_CODE.equals(key)) {
+ try {
+ mWifiManager.setCountryCode((String) newValue, true);
+ } catch (IllegalArgumentException e) {
+ Toast.makeText(getActivity(), R.string.wifi_setting_countrycode_error,
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ }
+
if (KEY_WLAN_TO_CELLULAR_HINT.equals(key)) {
boolean checked = ((Boolean) newValue).booleanValue();
setWlanToCellularHintEnable(checked);