diff options
author | Mike Lockwood <lockwood@android.com> | 2009-05-25 22:34:20 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-05-25 22:34:20 -0400 |
commit | c5ad0f47251199b0d137bfdb085f189afbe3ddd2 (patch) | |
tree | 6b301dc2a21b78af2e68186d856141fd79c03d4c /core | |
parent | 04561a55df693e7bd8d3047ccc4fbef504ac07cf (diff) | |
download | frameworks_base-c5ad0f47251199b0d137bfdb085f189afbe3ddd2.zip frameworks_base-c5ad0f47251199b0d137bfdb085f189afbe3ddd2.tar.gz frameworks_base-c5ad0f47251199b0d137bfdb085f189afbe3ddd2.tar.bz2 |
wifi: Fix problem parsing RSSI when the AP name contains a space.
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/android_net_wifi_Wifi.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp index 25670df..9f93e2f 100644 --- a/core/jni/android_net_wifi_Wifi.cpp +++ b/core/jni/android_net_wifi_Wifi.cpp @@ -317,8 +317,13 @@ static jint android_net_wifi_getRssiCommand(JNIEnv* env, jobject clazz) } // reply comes back in the form "<SSID> rssi XX" where XX is the // number we're interested in. if we're associating, it returns "OK". + // beware - <SSID> can contain spaces. if (strcmp(reply, "OK") != 0) { - sscanf(reply, "%*s %*s %d", &rssi); + char* lastSpace = strrchr(reply, ' '); + // lastSpace should be preceded by "rssi" and followed by the value + if (lastSpace && !strncmp(lastSpace - 4, "rssi", 4)) { + sscanf(lastSpace + 1, "%d", &rssi); + } } return (jint)rssi; } |