Change removeNetowrk to a synchronous channel call.
Change-ID: Iad0380d56972826615e044fa2aaee418b617d732
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user