diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-08-19 11:29:22 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-08-19 12:23:13 -0700 |
commit | e498475b187277309c81b38240c7e71ec049e369 (patch) | |
tree | abed2311f412e72a43b80351d1b3c94f6f10d0fd /wifi | |
parent | 99b99495cfbcbb6e9cb0fd67f03839adc4a98c12 (diff) | |
download | frameworks_base-e498475b187277309c81b38240c7e71ec049e369.zip frameworks_base-e498475b187277309c81b38240c7e71ec049e369.tar.gz frameworks_base-e498475b187277309c81b38240c7e71ec049e369.tar.bz2 |
asynchronous driver commands
Make some of the common driver commands scan/disconnect/reconnect/reassociate
asynchronous. We already have broadcasts to indicate results.
Change-Id: I343c6be077fb11a3d488e586ab10ab2373b269d8
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 8 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 15 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 100 |
3 files changed, 35 insertions, 88 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index cd07f0e..1913fa0 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -40,15 +40,15 @@ interface IWifiManager boolean pingSupplicant(); - boolean startScan(boolean forceActive); + void startScan(boolean forceActive); List<ScanResult> getScanResults(); - boolean disconnect(); + void disconnect(); - boolean reconnect(); + void reconnect(); - boolean reassociate(); + void reassociate(); WifiInfo getConnectionInfo(); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 9156358..21671f1 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -524,7 +524,8 @@ public class WifiManager { */ public boolean disconnect() { try { - return mService.disconnect(); + mService.disconnect(); + return true; } catch (RemoteException e) { return false; } @@ -538,7 +539,8 @@ public class WifiManager { */ public boolean reconnect() { try { - return mService.reconnect(); + mService.reconnect(); + return true; } catch (RemoteException e) { return false; } @@ -552,7 +554,8 @@ public class WifiManager { */ public boolean reassociate() { try { - return mService.reassociate(); + mService.reassociate(); + return true; } catch (RemoteException e) { return false; } @@ -581,7 +584,8 @@ public class WifiManager { */ public boolean startScan() { try { - return mService.startScan(false); + mService.startScan(false); + return true; } catch (RemoteException e) { return false; } @@ -599,7 +603,8 @@ public class WifiManager { */ public boolean startScanActive() { try { - return mService.startScan(true); + mService.startScan(true); + return true; } catch (RemoteException e) { return false; } diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 360b642..1a5492d 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -495,9 +495,9 @@ public class WifiStateMachine extends HierarchicalStateMachine { /** * TODO: doc */ - public boolean startScan(boolean forceActive) { - return sendSyncMessage(obtainMessage(CMD_START_SCAN, forceActive ? - SCAN_ACTIVE : SCAN_PASSIVE, 0)).boolValue; + public void startScan(boolean forceActive) { + sendMessage(obtainMessage(CMD_START_SCAN, forceActive ? + SCAN_ACTIVE : SCAN_PASSIVE, 0)); } /** @@ -642,22 +642,22 @@ public class WifiStateMachine extends HierarchicalStateMachine { /** * Disconnect from Access Point */ - public boolean disconnectCommand() { - return sendSyncMessage(CMD_DISCONNECT).boolValue; + public void disconnectCommand() { + sendMessage(CMD_DISCONNECT); } /** * Initiate a reconnection to AP */ - public boolean reconnectCommand() { - return sendSyncMessage(CMD_RECONNECT).boolValue; + public void reconnectCommand() { + sendMessage(CMD_RECONNECT); } /** * Initiate a re-association to AP */ - public boolean reassociateCommand() { - return sendSyncMessage(CMD_REASSOCIATE).boolValue; + public void reassociateCommand() { + sendMessage(CMD_REASSOCIATE); } /** @@ -2056,10 +2056,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { switch (message.what) { /* Synchronous call returns */ case CMD_PING_SUPPLICANT: - case CMD_START_SCAN: - case CMD_DISCONNECT: - case CMD_RECONNECT: - case CMD_REASSOCIATE: case CMD_REMOVE_NETWORK: case CMD_ENABLE_NETWORK: case CMD_DISABLE_NETWORK: @@ -2093,6 +2089,10 @@ public class WifiStateMachine extends HierarchicalStateMachine { case CMD_STOP_DRIVER: case CMD_START_AP: case CMD_STOP_AP: + case CMD_START_SCAN: + case CMD_DISCONNECT: + case CMD_RECONNECT: + case CMD_REASSOCIATE: case CMD_RECONFIGURE_IP: case SUP_CONNECTION_EVENT: case SUP_DISCONNECTION_EVENT: @@ -2647,16 +2647,11 @@ public class WifiStateMachine extends HierarchicalStateMachine { case CMD_SET_NUM_ALLOWED_CHANNELS: case CMD_START_PACKET_FILTERING: case CMD_STOP_PACKET_FILTERING: - deferMessage(message); - break; - /* Queue the asynchronous version of these commands */ case CMD_START_SCAN: case CMD_DISCONNECT: case CMD_REASSOCIATE: case CMD_RECONNECT: - if (message.arg2 != SYNCHRONOUS_CALL) { - deferMessage(message); - } + deferMessage(message); break; default: return NOT_HANDLED; @@ -2781,16 +2776,11 @@ public class WifiStateMachine extends HierarchicalStateMachine { case CMD_SET_NUM_ALLOWED_CHANNELS: case CMD_START_PACKET_FILTERING: case CMD_STOP_PACKET_FILTERING: - deferMessage(message); - break; - /* Queue the asynchronous version of these commands */ case CMD_START_SCAN: case CMD_DISCONNECT: case CMD_REASSOCIATE: case CMD_RECONNECT: - if (message.arg2 != SYNCHRONOUS_CALL) { - deferMessage(message); - } + deferMessage(message); break; default: return NOT_HANDLED; @@ -2836,15 +2826,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { } break; case CMD_START_SCAN: - if (message.arg2 == SYNCHRONOUS_CALL) { - syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = WifiNative.scanCommand( - message.arg1 == SCAN_ACTIVE); - notifyOnMsgObject(message); - } else { - /* asynchronous handling */ - WifiNative.scanCommand(message.arg1 == SCAN_ACTIVE); - } + WifiNative.scanCommand(message.arg1 == SCAN_ACTIVE); break; /* Ignore */ case CMD_DISCONNECT: @@ -2882,11 +2864,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { mSupplicantStateTracker.handleEvent(stateChangeResult); break; case CMD_START_SCAN: - if (message.arg2 == SYNCHRONOUS_CALL) { - syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = true; - notifyOnMsgObject(message); - } /* We need to set scan type in completed state */ Message newMsg = obtainMessage(); newMsg.copyFrom(message); @@ -2894,34 +2871,13 @@ public class WifiStateMachine extends HierarchicalStateMachine { break; /* Do a redundant disconnect without transition */ case CMD_DISCONNECT: - if (message.arg2 == SYNCHRONOUS_CALL) { - syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = WifiNative.disconnectCommand(); - notifyOnMsgObject(message); - } else { - /* asynchronous handling */ - WifiNative.disconnectCommand(); - } + WifiNative.disconnectCommand(); break; case CMD_RECONNECT: - if (message.arg2 == SYNCHRONOUS_CALL) { - syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = WifiNative.reconnectCommand(); - notifyOnMsgObject(message); - } else { - /* asynchronous handling */ - WifiNative.reconnectCommand(); - } + WifiNative.reconnectCommand(); break; case CMD_REASSOCIATE: - if (message.arg2 == SYNCHRONOUS_CALL) { - syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = WifiNative.reassociateCommand(); - notifyOnMsgObject(message); - } else { - /* asynchronous handling */ - WifiNative.reassociateCommand(); - } + WifiNative.reassociateCommand(); break; case CMD_CONNECT_NETWORK: int netId = message.arg1; @@ -3125,14 +3081,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { transitionTo(mDisconnectingState); break; case CMD_DISCONNECT: - if (message.arg2 == SYNCHRONOUS_CALL) { - SyncParams syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = WifiNative.disconnectCommand(); - notifyOnMsgObject(message); - } else { - /* asynchronous handling */ - WifiNative.disconnectCommand(); - } + WifiNative.disconnectCommand(); transitionTo(mDisconnectingState); break; /* Ignore */ @@ -3187,14 +3136,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); switch (message.what) { case CMD_DISCONNECT: - if (message.arg2 == SYNCHRONOUS_CALL) { - SyncParams syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = WifiNative.disconnectCommand(); - notifyOnMsgObject(message); - } else { - /* asynchronous handling */ - WifiNative.disconnectCommand(); - } + WifiNative.disconnectCommand(); transitionTo(mDisconnectingState); break; case CMD_RECONFIGURE_IP: |