diff options
author | Mike Lockwood <lockwood@android.com> | 2009-08-04 11:32:52 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2009-08-04 11:32:52 -0400 |
commit | b20148b806037f15a909604651edd14165c07238 (patch) | |
tree | c497863f00e7eab49cf809ed16dcbc4c824bb713 /core/jni/android_net_wifi_Wifi.cpp | |
parent | cd9e8d49071d10ad2d64530070a5c82fe2f49902 (diff) | |
download | frameworks_base-b20148b806037f15a909604651edd14165c07238.zip frameworks_base-b20148b806037f15a909604651edd14165c07238.tar.gz frameworks_base-b20148b806037f15a909604651edd14165c07238.tar.bz2 |
wifi: Strip trailing spaces before parsing RSSI results.
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'core/jni/android_net_wifi_Wifi.cpp')
-rw-r--r-- | core/jni/android_net_wifi_Wifi.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp index 70b7da1..38f3fda 100644 --- a/core/jni/android_net_wifi_Wifi.cpp +++ b/core/jni/android_net_wifi_Wifi.cpp @@ -324,6 +324,13 @@ static jint android_net_wifi_getRssiHelper(const char *cmd) // number we're interested in. if we're associating, it returns "OK". // beware - <SSID> can contain spaces. if (strcmp(reply, "OK") != 0) { + // beware of trailing spaces + char* end = reply + strlen(reply); + while (end > reply && end[-1] == ' ') { + end--; + } + *end = 0; + char* lastSpace = strrchr(reply, ' '); // lastSpace should be preceded by "rssi" and followed by the value if (lastSpace && !strncmp(lastSpace - 4, "rssi", 4)) { |