Merge "Fix ssid fetch"

This commit is contained in:
Irfan Sheriff
2012-04-16 19:25:03 -07:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 24 deletions

View File

@@ -23,12 +23,15 @@
* @hide
*/
public class StateChangeResult {
StateChangeResult(int networkId, String BSSID, SupplicantState state) {
StateChangeResult(int networkId, String SSID, String BSSID, SupplicantState state) {
this.state = state;
this.SSID = SSID;
this.BSSID = BSSID;
this.networkId = networkId;
}
int networkId;
String SSID;
String BSSID;
SupplicantState state;
}

View File

@@ -637,6 +637,9 @@ public class WifiMonitor {
* id=network-id state=new-state
*/
private void handleSupplicantStateChange(String dataString) {
String SSID = null;
int index = dataString.indexOf("SSID=");
if (index != -1) SSID = dataString.substring(index);
String[] dataTokens = dataString.split(" ");
String BSSID = null;
@@ -657,7 +660,6 @@ public class WifiMonitor {
try {
value = Integer.parseInt(nameValue[1]);
} catch (NumberFormatException e) {
Log.w(TAG, "STATE-CHANGE non-integer parameter: " + token);
continue;
}
@@ -680,7 +682,7 @@ public class WifiMonitor {
if (newSupplicantState == SupplicantState.INVALID) {
Log.w(TAG, "Invalid supplicant state: " + newState);
}
notifySupplicantStateChange(networkId, BSSID, newSupplicantState);
notifySupplicantStateChange(networkId, SSID, BSSID, newSupplicantState);
}
}
@@ -729,11 +731,13 @@ public class WifiMonitor {
* Send the state machine a notification that the state of the supplicant
* has changed.
* @param networkId the configured network on which the state change occurred
* @param SSID network name
* @param BSSID network address
* @param newState the new {@code SupplicantState}
*/
void notifySupplicantStateChange(int networkId, String BSSID, SupplicantState newState) {
void notifySupplicantStateChange(int networkId, String SSID, String BSSID, SupplicantState newState) {
mStateMachine.sendMessage(mStateMachine.obtainMessage(SUPPLICANT_STATE_CHANGE_EVENT,
new StateChangeResult(networkId, BSSID, newState)));
new StateChangeResult(networkId, SSID, BSSID, newState)));
}
/**

View File

@@ -1441,23 +1441,6 @@ public class WifiStateMachine extends StateMachine {
mScanResults = scanList;
}
private String fetchSSID() {
String status = mWifiNative.status();
if (status == null) {
return null;
}
// extract ssid from a series of "name=value"
String[] lines = status.split("\n");
for (String line : lines) {
String[] prop = line.split(" *= *");
if (prop.length < 2) continue;
String name = prop[0];
String value = prop[1];
if (name.equalsIgnoreCase("ssid")) return value;
}
return null;
}
/*
* Fetch RSSI and linkspeed on current connection
*/
@@ -1618,6 +1601,7 @@ public class WifiStateMachine extends StateMachine {
/* BSSID is valid only in ASSOCIATING state */
mWifiInfo.setBSSID(stateChangeResult.BSSID);
}
mWifiInfo.setSSID(stateChangeResult.SSID);
mSupplicantStateTracker.sendMessage(Message.obtain(message));
@@ -2935,8 +2919,6 @@ public class WifiStateMachine extends StateMachine {
mLastNetworkId = message.arg1;
mLastBssid = (String) message.obj;
//TODO: make supplicant modification to push this in events
mWifiInfo.setSSID(fetchSSID());
mWifiInfo.setBSSID(mLastBssid);
mWifiInfo.setNetworkId(mLastNetworkId);
/* send event to CM & network change broadcast */