Merge "Append log data to tombstones"
diff --git a/charger/charger.c b/charger/charger.c
index d3b414d..03280bf 100644
--- a/charger/charger.c
+++ b/charger/charger.c
@@ -224,7 +224,7 @@
 
         yoink = ptr[cnt];
         ptr[cnt] = '\0';
-        KLOG_INFO("", "%s", ptr);
+        klog_write(6, "<6>%s", ptr);
         ptr[cnt] = yoink;
 
         len -= cnt;
@@ -745,30 +745,44 @@
     }
 }
 
-static void update_input_state(struct charger *charger,
-                               struct input_event *ev,
-                               int64_t now)
+static int set_key_callback(int code, int value, void *data)
 {
-    int down = !!ev->value;
+    struct charger *charger = data;
+    int64_t now = curr_time_ms();
+    int down = !!value;
 
-    if (ev->type != EV_KEY || ev->code > KEY_MAX)
-        return;
+    if (code > KEY_MAX)
+        return -1;
+
+    /* ignore events that don't modify our state */
+    if (charger->keys[code].down == down)
+        return 0;
 
     /* only record the down even timestamp, as the amount
      * of time the key spent not being pressed is not useful */
     if (down)
-        charger->keys[ev->code].timestamp = now;
-    charger->keys[ev->code].down = down;
-    charger->keys[ev->code].pending = true;
+        charger->keys[code].timestamp = now;
+    charger->keys[code].down = down;
+    charger->keys[code].pending = true;
     if (down) {
-        LOGV("[%lld] key[%d] down\n", now, ev->code);
+        LOGV("[%lld] key[%d] down\n", now, code);
     } else {
-        int64_t duration = now - charger->keys[ev->code].timestamp;
+        int64_t duration = now - charger->keys[code].timestamp;
         int64_t secs = duration / 1000;
         int64_t msecs = duration - secs * 1000;
         LOGV("[%lld] key[%d] up (was down for %lld.%lldsec)\n", now,
-            ev->code, secs, msecs);
+            code, secs, msecs);
     }
+
+    return 0;
+}
+
+static void update_input_state(struct charger *charger,
+                               struct input_event *ev)
+{
+    if (ev->type != EV_KEY)
+        return;
+    set_key_callback(ev->code, ev->value, charger);
 }
 
 static void set_next_key_check(struct charger *charger,
@@ -876,7 +890,7 @@
     ret = ev_get_input(fd, revents, &ev);
     if (ret)
         return -1;
-    update_input_state(charger, &ev, curr_time_ms());
+    update_input_state(charger, &ev);
     return 0;
 }
 
@@ -949,6 +963,8 @@
         }
     }
 
+    ev_sync_key_state(set_key_callback, charger);
+
     gr_fb_blank(true);
 
     charger->next_screen_transition = now - 1;
diff --git a/include/cutils/compiler.h b/include/cutils/compiler.h
index 09112d5..70f884a 100644
--- a/include/cutils/compiler.h
+++ b/include/cutils/compiler.h
@@ -29,4 +29,16 @@
 #   define CC_UNLIKELY( exp )  (__builtin_expect( !!(exp), 0 ))
 #endif
 
+/**
+ * exports marked symbols
+ *
+ * if used on a C++ class declaration, this macro must be inserted
+ * after the "class" keyword. For instance:
+ *
+ * template <typename TYPE>
+ * class ANDROID_API Singleton { }
+ */
+
+#define ANDROID_API __attribute__((visibility("default")))
+
 #endif // ANDROID_CUTILS_COMPILER_H
diff --git a/include/system/camera.h b/include/system/camera.h
index 86b62b7..cdfa256 100644
--- a/include/system/camera.h
+++ b/include/system/camera.h
@@ -227,8 +227,7 @@
     int32_t number_of_faces;
 
     /**
-     * An array of the detected faces. The length is number_of_faces. The list
-     * is sorted by the score. The highest score is the first element.
+     * An array of the detected faces. The length is number_of_faces.
      */
     camera_face_t *faces;
 } camera_frame_metadata_t;