diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-10-21 16:44:48 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-10-26 10:48:11 -0700 |
commit | f235c5ab91b040b88ceb61beb819e15f1b19e9e4 (patch) | |
tree | e3b6900632ca6f14b874d6f2be2ac4a52dc5bcd3 /wifi | |
parent | 48c9daac20dcae18bf45e528fd073612bc0122e1 (diff) | |
download | frameworks_base-f235c5ab91b040b88ceb61beb819e15f1b19e9e4.zip frameworks_base-f235c5ab91b040b88ceb61beb819e15f1b19e9e4.tar.gz frameworks_base-f235c5ab91b040b88ceb61beb819e15f1b19e9e4.tar.bz2 |
add wps pin from device capability
Bug: 3119043
Bug: 3112178
Change-Id: Iaae6bcf53e11f7fac82b3c604ddc27ff05e00542
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 4 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 22 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 21 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 4 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 55 |
5 files changed, 82 insertions, 24 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index f760d27..720f6ac 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -108,6 +108,8 @@ interface IWifiManager void startWpsPbc(String bssid); - void startWpsPin(String bssid, int apPin); + void startWpsWithPinFromAccessPoint(String bssid, int apPin); + + int startWpsWithPinFromDevice(String bssid); } diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index be5fab4..04b3891 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -361,10 +361,11 @@ class WifiConfigStore { } /** - * Start WPS pin method configuration + * Start WPS pin method configuration with pin obtained + * from the access point */ - static boolean startWpsPin(String bssid, int apPin) { - if (WifiNative.startWpsPinCommand(bssid, apPin)) { + static boolean startWpsWithPinFromAccessPoint(String bssid, int apPin) { + if (WifiNative.startWpsWithPinFromAccessPointCommand(bssid, apPin)) { /* WPS leaves all networks disabled */ markAllNetworksDisabled(); return true; @@ -374,6 +375,21 @@ class WifiConfigStore { } /** + * Start WPS pin method configuration with pin obtained + * from the device + */ + static int startWpsWithPinFromDevice(String bssid) { + int pin = WifiNative.startWpsWithPinFromDeviceCommand(bssid); + /* WPS leaves all networks disabled */ + if (pin != -1) { + markAllNetworksDisabled(); + } else { + Log.e(TAG, "Failed to start WPS pin method configuration"); + } + return pin; + } + + /** * Start WPS push button configuration */ static boolean startWpsPbc(String bssid) { diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 0b3a782..84d615c 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1050,19 +1050,36 @@ public class WifiManager { /** * Start Wi-fi Protected Setup pin method configuration + * with pin obtained from the access point * * @param bssid BSSID of the access point * @param apPin PIN issued by the access point * * @hide */ - public void startWpsPin(String bssid, int apPin) { + public void startWpsWithPinFromAccessPoint(String bssid, int apPin) { try { - mService.startWpsPin(bssid, apPin); + mService.startWpsWithPinFromAccessPoint(bssid, apPin); } catch (RemoteException e) { } } /** + * Start Wi-fi Protected Setup pin method configuration + * with pin obtained from the device + * + * @param bssid BSSID of the access point + * @return pin generated by device + * @hide + */ + public int startWpsWithPinFromDevice(String bssid) { + try { + return mService.startWpsWithPinFromDevice(bssid); + } catch (RemoteException e) { + return -1; + } + } + + /** * Allows an application to keep the Wi-Fi radio awake. * Normally the Wi-Fi radio may turn off when the user has not used the device in a while. * Acquiring a WifiLock will keep the radio on until the lock is released. Multiple diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 1251a25..313ae0b 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -153,7 +153,9 @@ public class WifiNative { public native static boolean startWpsPbcCommand(String bssid); - public native static boolean startWpsPinCommand(String bssid, int apPin); + public native static boolean startWpsWithPinFromAccessPointCommand(String bssid, int apPin); + + public native static int startWpsWithPinFromDeviceCommand(String bssid); public native static boolean doDhcpRequest(DhcpInfo results); diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index e3deeb3..faafb7a 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -301,9 +301,10 @@ public class WifiStateMachine extends HierarchicalStateMachine { * supplicant config. */ private static final int CMD_FORGET_NETWORK = 92; - /* Start Wi-Fi protected setup */ - private static final int CMD_START_WPS = 93; - + /* Start Wi-Fi protected setup push button configuration */ + private static final int CMD_START_WPS_PBC = 93; + /* Start Wi-Fi protected setup pin method configuration */ + private static final int CMD_START_WPS_PIN = 94; /** * Interval in milliseconds between polling for connection * status items that are not sent via asynchronous events. @@ -787,11 +788,18 @@ public class WifiStateMachine extends HierarchicalStateMachine { } public void startWpsPbc(String bssid) { - sendMessage(obtainMessage(CMD_START_WPS, bssid)); + sendMessage(obtainMessage(CMD_START_WPS_PBC, bssid)); + } + + public void startWpsWithPinFromAccessPoint(String bssid, int apPin) { + sendMessage(obtainMessage(CMD_START_WPS_PIN, apPin, 0, bssid)); } - public void startWpsPin(String bssid, int apPin) { - sendMessage(obtainMessage(CMD_START_WPS, apPin, 0, bssid)); + public int syncStartWpsWithPinFromDevice(AsyncChannel channel, String bssid) { + Message resultMsg = channel.sendMessageSynchronously(CMD_START_WPS_PIN, bssid); + int result = resultMsg.arg1; + resultMsg.recycle(); + return result; } public void enableRssiPolling(boolean enabled) { @@ -1654,7 +1662,8 @@ public class WifiStateMachine extends HierarchicalStateMachine { case CMD_CONNECT_NETWORK: case CMD_SAVE_NETWORK: case CMD_FORGET_NETWORK: - case CMD_START_WPS: + case CMD_START_WPS_PBC: + case CMD_START_WPS_PIN: break; default: Log.e(TAG, "Error! unhandled message" + message); @@ -2395,17 +2404,11 @@ public class WifiStateMachine extends HierarchicalStateMachine { /* Expect a disconnection from the old connection */ transitionTo(mDisconnectingState); break; - case CMD_START_WPS: + case CMD_START_WPS_PBC: String bssid = (String) message.obj; - int apPin = message.arg1; - boolean success; - if (apPin != 0) { - /* WPS pin method configuration */ - success = WifiConfigStore.startWpsPin(bssid, apPin); - } else { - /* WPS push button configuration */ - success = WifiConfigStore.startWpsPbc(bssid); - } + /* WPS push button configuration */ + boolean success = WifiConfigStore.startWpsPbc(bssid); + /* During WPS setup, all other networks are disabled. After * a successful connect a new config is created in the supplicant. * @@ -2422,6 +2425,24 @@ public class WifiStateMachine extends HierarchicalStateMachine { transitionTo(mDisconnectingState); } break; + case CMD_START_WPS_PIN: + bssid = (String) message.obj; + int apPin = message.arg1; + int pin; + if (apPin != 0) { + /* WPS pin from access point */ + success = WifiConfigStore.startWpsWithPinFromAccessPoint(bssid, apPin); + } else { + pin = WifiConfigStore.startWpsWithPinFromDevice(bssid); + success = (pin != -1); + mReplyChannel.replyToMessage(message, CMD_START_WPS_PIN, pin); + } + if (success) { + mWpsStarted = true; + /* Expect a disconnection from the old connection */ + transitionTo(mDisconnectingState); + } + break; case SCAN_RESULTS_EVENT: /* Set the scan setting back to "connect" mode */ WifiNative.setScanResultHandlingCommand(CONNECT_MODE); |