summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/wifi/WifiSettings.java47
1 files changed, 36 insertions, 11 deletions
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index e47660a..ffe48a9 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -37,7 +37,9 @@ import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
+import android.net.wifi.WpsResult;
import android.net.wifi.WifiConfiguration.KeyMgmt;
+import android.net.wifi.WpsConfiguration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -126,11 +128,12 @@ public class WifiSettings extends SettingsPreferenceFragment
mFilter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
mFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
+ mFilter.addAction(WifiManager.ERROR_ACTION);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- handleEvent(intent);
+ handleEvent(context, intent);
}
};
@@ -428,7 +431,7 @@ public class WifiSettings extends SettingsPreferenceFragment
return accessPoints;
}
- private void handleEvent(Intent intent) {
+ private void handleEvent(Context context, Intent intent) {
String action = intent.getAction();
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
updateWifiState(intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
@@ -460,6 +463,14 @@ public class WifiSettings extends SettingsPreferenceFragment
updateConnectionState(info.getDetailedState());
} else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {
updateConnectionState(null);
+ } else if (WifiManager.ERROR_ACTION.equals(action)) {
+ int errorCode = intent.getIntExtra(WifiManager.EXTRA_ERROR_CODE, 0);
+ switch (errorCode) {
+ case WifiManager.WPS_OVERLAP_ERROR:
+ Toast.makeText(context, R.string.wifi_wps_overlap_error,
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
}
}
@@ -571,18 +582,32 @@ public class WifiSettings extends SettingsPreferenceFragment
}
/* package */ void submit(WifiConfigController configController) {
- switch(configController.chosenNetworkSetupMethod()) {
+ int networkSetup = configController.chosenNetworkSetupMethod();
+ switch(networkSetup) {
case WifiConfigController.WPS_PBC:
case WifiConfigController.WPS_PIN_FROM_ACCESS_POINT:
- mWifiManager.startWps(configController.getWpsConfig());
- break;
case WifiConfigController.WPS_PIN_FROM_DEVICE:
- String pin = mWifiManager.startWps(configController.getWpsConfig());
- new AlertDialog.Builder(getActivity())
- .setTitle(R.string.wifi_wps_pin_method_configuration)
- .setMessage(getResources().getString(R.string.wifi_wps_pin_output, pin))
- .setPositiveButton(android.R.string.ok, null)
- .show();
+ WpsResult result = mWifiManager.startWps(configController.getWpsConfig());
+ AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.wifi_wps_setup_title)
+ .setPositiveButton(android.R.string.ok, null);
+ switch (result.status) {
+ case FAILURE:
+ dialog.setMessage(R.string.wifi_wps_failed);
+ dialog.show();
+ break;
+ case IN_PROGRESS:
+ dialog.setMessage(R.string.wifi_wps_in_progress);
+ dialog.show();
+ break;
+ default:
+ if (networkSetup == WifiConfigController.WPS_PIN_FROM_DEVICE) {
+ dialog.setMessage(getResources().getString(R.string.wifi_wps_pin_output,
+ result.pin));
+ dialog.show();
+ }
+ break;
+ }
break;
case WifiConfigController.MANUAL:
final WifiConfiguration config = configController.getConfig();