Add feedback dialogs for WPS

Upon failure or an existing WPS session,
a dialog message is conveyed to the user

Bug: 3316078
Change-Id: Ibcf27e21058970f8f1667061c7654948c690d48e
This commit is contained in:
Irfan Sheriff
2011-01-13 13:58:39 -08:00
parent ec0be8ce2e
commit dee5b26892
2 changed files with 32 additions and 12 deletions

View File

@@ -946,10 +946,14 @@
<string name="wifi_network_setup">Network Setup</string> <string name="wifi_network_setup">Network Setup</string>
<!-- Label for the text view for WPS pin input [CHAR LIMIT=50] --> <!-- Label for the text view for WPS pin input [CHAR LIMIT=50] -->
<string name="wifi_wps_pin">Enter pin from access point</string> <string name="wifi_wps_pin">Enter pin from access point</string>
<!-- Title for the WPS pin display dialog [CHAR LIMIT=50] --> <!-- Title for the WPS setup dialog [CHAR LIMIT=50] -->
<string name="wifi_wps_pin_method_configuration">WPS pin method configuration</string> <string name="wifi_wps_setup_title">WPS Setup</string>
<!-- Text displayed in the WPS pin display dialog [CHAR LIMIT=50] --> <!-- Text displayed in the WPS pin display dialog [CHAR LIMIT=75] -->
<string name="wifi_wps_pin_output">Enter the pin <xliff:g id="wps_pin">%1$s</xliff:g> on the access point</string> <string name="wifi_wps_pin_output">Enter the pin <xliff:g id="wps_pin">%1$s</xliff:g> on the access point</string>
<!-- Text displayed when WPS setup is in progress [CHAR LIMIT=75] -->
<string name="wifi_wps_in_progress">WPS is already in progress and can take tens of seconds to complete</string>
<!-- Text displayed when WPS fails to start [CHAR LIMIT=75] -->
<string name="wifi_wps_failed">Failed to start WPS, please try again</string>
<!-- Label for the SSID of the network --> <!-- Label for the SSID of the network -->
<string name="wifi_ssid">Network SSID</string> <string name="wifi_ssid">Network SSID</string>
<!-- Label for the security of the connection --> <!-- Label for the security of the connection -->

View File

@@ -37,7 +37,9 @@ import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo; import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.net.wifi.WpsResult;
import android.net.wifi.WifiConfiguration.KeyMgmt; import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WpsConfiguration;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@@ -569,18 +571,32 @@ public class WifiSettings extends SettingsPreferenceFragment
} }
/* package */ void submit(WifiConfigController configController) { /* package */ void submit(WifiConfigController configController) {
switch(configController.chosenNetworkSetupMethod()) { int networkSetup = configController.chosenNetworkSetupMethod();
switch(networkSetup) {
case WifiConfigController.WPS_PBC: case WifiConfigController.WPS_PBC:
case WifiConfigController.WPS_PIN_FROM_ACCESS_POINT: case WifiConfigController.WPS_PIN_FROM_ACCESS_POINT:
mWifiManager.startWps(configController.getWpsConfig());
break;
case WifiConfigController.WPS_PIN_FROM_DEVICE: case WifiConfigController.WPS_PIN_FROM_DEVICE:
String pin = mWifiManager.startWps(configController.getWpsConfig()); WpsResult result = mWifiManager.startWps(configController.getWpsConfig());
new AlertDialog.Builder(getActivity()) AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity())
.setTitle(R.string.wifi_wps_pin_method_configuration) .setTitle(R.string.wifi_wps_setup_title)
.setMessage(getResources().getString(R.string.wifi_wps_pin_output, pin)) .setPositiveButton(android.R.string.ok, null);
.setPositiveButton(android.R.string.ok, null) switch (result.status) {
.show(); 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; break;
case WifiConfigController.MANUAL: case WifiConfigController.MANUAL:
final WifiConfiguration config = configController.getConfig(); final WifiConfiguration config = configController.getConfig();