am d0290ead: nexus: Fix SupplicantStatus decoding

Merge commit 'd0290eadc563f5a34fc1969f91621860d8756eff'

* commit 'd0290eadc563f5a34fc1969f91621860d8756eff':
  nexus: Fix SupplicantStatus decoding
  nexus: Less verbosity in TiwlanEventListener for now
diff --git a/nexus/SupplicantStatus.cpp b/nexus/SupplicantStatus.cpp
index 87f6c98..b3c560a 100644
--- a/nexus/SupplicantStatus.cpp
+++ b/nexus/SupplicantStatus.cpp
@@ -17,7 +17,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define LOG_TAG "SupplicantState"
+#define LOG_TAG "SupplicantStatus"
 #include <cutils/log.h>
 
 #include "SupplicantStatus.h"
@@ -52,18 +52,37 @@
     char *next = data;
     char *line;
     while((line = strsep(&next, "\n"))) {
-        char *token = strsep(&next, "=");
-        char *value = strsep(&next, "=");
-
+        char *line_next =  line;
+        char *token = strsep(&line_next, "=");
+        char *value = strsep(&line_next, "=");
         if (!strcmp(token, "bssid"))
             bssid = strdup(value);
         else if (!strcmp(token, "ssid"))
             ssid = strdup(value);
         else if (!strcmp(token, "id"))
             id = atoi(value);
-        else if (!strcmp(token, "wpa_state"))
-            state = atoi(value);
-        else
+        else if (!strcmp(token, "wpa_state")) {
+            if (!strcmp(value, "DISCONNECTED"))
+                state = SupplicantState::DISCONNECTED;
+            else if (!strcmp(value, "INACTIVE"))
+                state = SupplicantState::INACTIVE;
+            else if (!strcmp(value, "SCANNING"))
+                state = SupplicantState::SCANNING;
+            else if (!strcmp(value, "ASSOCIATING"))
+                state = SupplicantState::ASSOCIATING;
+            else if (!strcmp(value, "ASSOCIATED"))
+                state = SupplicantState::ASSOCIATED;
+            else if (!strcmp(value, "FOURWAY_HANDSHAKE"))
+                state = SupplicantState::FOURWAY_HANDSHAKE;
+            else if (!strcmp(value, "GROUP_HANDSHAKE"))
+                state = SupplicantState::GROUP_HANDSHAKE;
+            else if (!strcmp(value, "COMPLETED"))
+                state = SupplicantState::COMPLETED;
+            else if (!strcmp(value, "IDLE"))
+                state = SupplicantState::IDLE;
+            else 
+                LOGE("Unknown supplicant state '%s'", value);
+        } else
             LOGD("Ignoring unsupported status token '%s'", token);
     }
 
diff --git a/nexus/TiwlanEventListener.cpp b/nexus/TiwlanEventListener.cpp
index 76e6ec1..15e6930 100644
--- a/nexus/TiwlanEventListener.cpp
+++ b/nexus/TiwlanEventListener.cpp
@@ -45,13 +45,13 @@
     if (data->event_type == IPC_EVENT_LINK_SPEED) {
         uint32_t *spd = (uint32_t *) data->buffer;
         *spd /= 2;
-        LOGD("Link speed = %u MB/s", *spd);
+//        LOGD("Link speed = %u MB/s", *spd);
     } else if (data->event_type == IPC_EVENT_LOW_SNR) {
-        LOGD("Low signal/noise ratio");
+        LOGW("Low signal/noise ratio");
     } else if (data->event_type == IPC_EVENT_LOW_RSSI) {
-        LOGD("Low RSSI");
+        LOGW("Low RSSI");
     } else {
-        LOGD("Dropping unhandled driver event %d", data->event_type);
+//        LOGD("Dropping unhandled driver event %d", data->event_type);
     }
 
     // TODO: Tell WifiController about the event