summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/jni/android_net_wifi_Wifi.cpp7
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 25670df9d373..9f93e2f042d1 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;
}