diff options
author | Wink Saville <wink@google.com> | 2010-10-20 15:37:41 -0700 |
---|---|---|
committer | Wink Saville <wink@google.com> | 2010-10-20 15:52:42 -0700 |
commit | 4b7ba09c8bf773dbd045b4bbe7831fa16e33653d (patch) | |
tree | e512599cd36aaa8ae7fdd93f2d8332442c48206e /wifi/java | |
parent | 1b35f942ec659fa843e531e207e5e90b0544504a (diff) | |
download | frameworks_base-4b7ba09c8bf773dbd045b4bbe7831fa16e33653d.zip frameworks_base-4b7ba09c8bf773dbd045b4bbe7831fa16e33653d.tar.gz frameworks_base-4b7ba09c8bf773dbd045b4bbe7831fa16e33653d.tar.bz2 |
Change removeNetowrk to a synchronous channel call.
Change-ID: Iad0380d56972826615e044fa2aaee418b617d732
Diffstat (limited to 'wifi/java')
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index f2fdbad..65b910b 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -70,6 +70,7 @@ import android.bluetooth.BluetoothProfile; import android.content.Intent; import android.content.Context; import com.android.internal.app.IBatteryStats; +import com.android.internal.util.AsyncChannel; import com.android.internal.util.HierarchicalState; import com.android.internal.util.HierarchicalStateMachine; @@ -148,6 +149,9 @@ public class WifiStateMachine extends HierarchicalStateMachine { * and load configuration afterwards */ private boolean mWpsStarted = false; + // Channel for sending replies. + private AsyncChannel mReplyChannel = new AsyncChannel(); + // Event log tags (must be in sync with event-log-tags) private static final int EVENTLOG_WIFI_STATE_CHANGED = 50021; private static final int EVENTLOG_WIFI_EVENT_HANDLED = 50022; @@ -301,7 +305,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { /* Start Wi-Fi protected setup */ private static final int CMD_START_WPS = 93; - /** * Interval in milliseconds between polling for connection * status items that are not sent via asynchronous events. @@ -699,8 +702,21 @@ public class WifiStateMachine extends HierarchicalStateMachine { * * @param networkId id of the network to be removed */ - public boolean syncRemoveNetwork(int networkId) { - return sendSyncMessage(obtainMessage(CMD_REMOVE_NETWORK, networkId, 0)).boolValue; + public boolean syncRemoveNetwork(AsyncChannel channel, int networkId) { + Message resultMsg = channel.sendMessageSynchronously(CMD_REMOVE_NETWORK, networkId); + boolean result = resultMsg.arg1 != 0; + resultMsg.recycle(); + return result; + } + + /** + * Return the result of a removeNetwork + * + * @param srcMsg is the original message + * @param result is true if successfully removed + */ + private void removeNetworkReply(Message srcMsg, boolean result) { + mReplyChannel.replyToMessage(srcMsg, CMD_REMOVE_NETWORK, result ? 1 : 0); } private class EnableNetParams { @@ -1583,7 +1599,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { break; /* Synchronous call returns */ case CMD_PING_SUPPLICANT: - case CMD_REMOVE_NETWORK: case CMD_ENABLE_NETWORK: case CMD_DISABLE_NETWORK: case CMD_ADD_OR_UPDATE_NETWORK: @@ -1598,6 +1613,9 @@ public class WifiStateMachine extends HierarchicalStateMachine { syncParams.mSyncReturn.stringValue = null; notifyOnMsgObject(message); break; + case CMD_REMOVE_NETWORK: + removeNetworkReply(message, false); + break; case CMD_ENABLE_RSSI_POLL: mEnableRssiPolling = (message.arg1 == 1); mSupplicantStateTracker.sendMessage(CMD_ENABLE_RSSI_POLL); @@ -2023,10 +2041,8 @@ public class WifiStateMachine extends HierarchicalStateMachine { break; case CMD_REMOVE_NETWORK: EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what); - syncParams = (SyncParams) message.obj; - syncParams.mSyncReturn.boolValue = WifiConfigStore.removeNetwork( - message.arg1); - notifyOnMsgObject(message); + boolean ok = WifiConfigStore.removeNetwork(message.arg1); + removeNetworkReply(message, ok); break; case CMD_ENABLE_NETWORK: EventLog.writeEvent(EVENTLOG_WIFI_EVENT_HANDLED, message.what); |