Merge changes Idcb48155,Iecb8c3db,I4924134b into ics-mr0
* changes:
charger: ignore key event if value didn't change
charger: sync with the current key state on boot
charger: print last_kmsg directly using klog_write
diff --git a/charger/charger.c b/charger/charger.c
index d3b414d..aface7e 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 -1;
/* 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;