aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Ribbers <bribbers@disroot.org>2022-05-02 11:29:08 +0200
committerBart Ribbers <bribbers@disroot.org>2022-05-02 11:41:54 +0000
commit0a5430dd1ecefab23a4e9e7510f24a04872d0b8a (patch)
tree08f5b77cea39f98a2e3ec66dfe8032a3938b962a
parent8af3d8bd7375e3ff34b93020f47ca658a830a8a7 (diff)
downloadaports-0a5430dd1ecefab23a4e9e7510f24a04872d0b8a.tar.gz
aports-0a5430dd1ecefab23a4e9e7510f24a04872d0b8a.tar.bz2
aports-0a5430dd1ecefab23a4e9e7510f24a04872d0b8a.tar.xz
community/mce: upgrade to 1.111.0
Using AsteroidOS patches
-rw-r--r--community/mce/0001-Double-tap-emulation-Adapts-the-state-machine-to-a-s.patch413
-rw-r--r--community/mce/0001-Keep-screen-on-by-default-on-emulator.patch22
-rw-r--r--community/mce/0002-tilt-to-wake-Wake-screen-when-wrist-gesture-arrives.patch592
-rw-r--r--community/mce/0003-inactivity-Allow-activities-in-lockscreen-mode.-aste.patch58
-rw-r--r--community/mce/0004-Ambient-mode-Adapt-low-power-mode-to-allow-for-actua.patch631
-rw-r--r--community/mce/0005-Ambient-Mode-Wait-for-compositor-when-sending-enable.patch55
-rw-r--r--community/mce/0006-Ambient-Mode-Exit-ambient-mode-when-touch-is-detecte.patch61
-rw-r--r--community/mce/0007-powerkey-Also-suspend-on-palm-reports.patch156
-rw-r--r--community/mce/0008-fix-32bit-build.patch14
-rw-r--r--community/mce/APKBUILD47
-rw-r--r--community/mce/fix-build.patch99
11 files changed, 2039 insertions, 109 deletions
diff --git a/community/mce/0001-Double-tap-emulation-Adapts-the-state-machine-to-a-s.patch b/community/mce/0001-Double-tap-emulation-Adapts-the-state-machine-to-a-s.patch
new file mode 100644
index 0000000000..a3b9d098d3
--- /dev/null
+++ b/community/mce/0001-Double-tap-emulation-Adapts-the-state-machine-to-a-s.patch
@@ -0,0 +1,413 @@
+From 0d9b783200489136804e8b9cea6a1f48d67f939b Mon Sep 17 00:00:00 2001
+From: Florent Revest <revestflo@gmail.com>
+Date: Wed, 21 Feb 2018 18:01:02 +0100
+Subject: [PATCH] Double-tap emulation: Adapts the state machine to a single
+ tap to unlock behavior (after 200ms the screen is unlocked)
+
+---
+ event-input.c | 17 +---
+ multitouch.c | 236 +++++++++++++++++++-------------------------------
+ multitouch.h | 2 +-
+ 3 files changed, 94 insertions(+), 161 deletions(-)
+
+diff --git a/event-input.c b/event-input.c
+index 49726f3..de0d19c 100644
+--- a/event-input.c
++++ b/event-input.c
+@@ -295,7 +295,7 @@ static evin_iomon_extra_t *evin_iomon_extra_create (int fd, const c
+
+ // common rate limited activity generation
+
+-static void evin_iomon_generate_activity (struct input_event *ev, bool cooked, bool raw);
++void evin_iomon_generate_activity (struct input_event *ev, bool cooked, bool raw);
+
+ // event handling by device type
+
+@@ -2024,7 +2024,7 @@ evin_iomon_device_rem_all(void)
+ * @param cooked True, if generic activity should be sent
+ * @param raw True, if non-synthetized activity should be sent
+ */
+-static void
++void
+ evin_iomon_generate_activity(struct input_event *ev, bool cooked, bool raw)
+ {
+ static time_t t_cooked = 0;
+@@ -2128,27 +2128,16 @@ evin_iomon_touchscreen_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
+
+ bool grabbed = touch_grab_wanted;
+
+- bool doubletap = false;
+-
+ evin_iomon_extra_t *extra = mce_io_mon_get_user_data(iomon);
+ if( extra && extra->ex_mt_state ) {
+ bool touching_prev = mt_state_touching(extra->ex_mt_state);
+- doubletap = mt_state_handle_event(extra->ex_mt_state, ev);
++ mt_state_handle_event(extra->ex_mt_state, ev);
+ bool touching_curr = mt_state_touching(extra->ex_mt_state);
+
+ if( touching_prev != touching_curr )
+ evin_touchstate_schedule_update();
+ }
+
+-#ifdef ENABLE_DOUBLETAP_EMULATION
+- if( doubletap && evin_iomon_sw_gestures_allowed() ) {
+- mce_log(LL_DEVEL, "[doubletap] emulated from touch input");
+- ev->type = EV_MSC;
+- ev->code = MSC_GESTURE;
+- ev->value = GESTURE_DOUBLETAP | GESTURE_SYNTHESIZED;
+- }
+-#endif
+-
+ /* Power key up event from touch screen -> double tap gesture event */
+ if( ev->type == EV_KEY && ev->code == KEY_POWER && ev->value == 0 ) {
+ mce_log(LL_DEVEL, "[doubletap] as power key event; "
+diff --git a/multitouch.c b/multitouch.c
+index 6bab567..95dfe22 100644
+--- a/multitouch.c
++++ b/multitouch.c
+@@ -29,6 +29,14 @@
+ #include <stdlib.h>
+ #include <string.h>
+
++#include <glib/gstdio.h>
++#include <gio/gio.h>
++
++#include "datapipe.h"
++#include "evdev.h"
++#include "mce.h"
++#include "mce-log.h"
++
+ /* ========================================================================= *
+ * TYPES & FUNCTIONS
+ * ========================================================================= */
+@@ -64,43 +72,6 @@ struct mt_point_t
+ static void mt_point_invalidate (mt_point_t *self);
+ static int mt_point_distance2 (const mt_point_t *a, const mt_point_t *b);
+
+-/* ------------------------------------------------------------------------- *
+- * TOUCH_VECTOR
+- * ------------------------------------------------------------------------- */
+-
+-typedef struct mt_touch_t mt_touch_t;
+-
+-/** Tracking data for start and end position of one touch sequence */
+-struct mt_touch_t
+-{
+- /* Coordinate where first finger was detected on screen */
+- mt_point_t mtt_beg_point;
+-
+- /* Coordinate where last finger was lifted from screen */
+- mt_point_t mtt_end_point;
+-
+- /* Timestamp for: Touch started */
+- int64_t mtt_beg_tick;
+-
+- /* Timestamp for: Touch ended */
+- int64_t mtt_end_tick;
+-
+- /* Maximum number of fingers seen during the touch */
+- size_t mtt_max_fingers;
+-};
+-
+-/** Maximum jitter allowed in double tap (pixel) coordinates */
+-#define MT_TOUCH_DBLTAP_DIST_MAX 100
+-
+-/** Maximum delay between double tap presses and releases [ms] */
+-#define MT_TOUCH_DBLTAP_DELAY_MAX 500
+-
+-/** Minimum delay between double tap presses and releases [ms] */
+-#define MT_TOUCH_DBLTAP_DELAY_MIN 1
+-
+-static bool mt_touch_is_single_tap(const mt_touch_t *self);
+-static bool mt_touch_is_double_tap(const mt_touch_t *self, const mt_touch_t *prev);
+-
+ /* ------------------------------------------------------------------------- *
+ * TOUCH_STATE
+ * ------------------------------------------------------------------------- */
+@@ -135,8 +106,10 @@ struct mt_state_t
+ /** Currently tracked primary touch point */
+ mt_point_t mts_point_tracked;
+
+- /** Stats for the last 3 taps, used for double tap detection */
+- mt_touch_t mts_tap_arr[3];
++ /** Timer used for long press detection */
++ guint tap_to_unlock_timer_id;
++
++ size_t current_seq_max_fingers;
+
+ /** Device type / protocol specific input event handler function */
+ void (*mts_event_handler_cb)(mt_state_t *, const struct input_event *);
+@@ -146,7 +119,7 @@ struct mt_state_t
+ };
+
+ static void mt_state_reset (mt_state_t *self);
+-static bool mt_state_update (mt_state_t *self);
++static void mt_state_update (mt_state_t *self);
+
+ static void mt_state_handle_event_a (mt_state_t *self, const struct input_event *ev);
+ static void mt_state_handle_event_b (mt_state_t *self, const struct input_event *ev);
+@@ -154,10 +127,65 @@ static void mt_state_handle_event_b (mt_state_t *self, const struct input
+ mt_state_t *mt_state_create (bool protocol_b);
+ void mt_state_delete (mt_state_t *self);
+
+-bool mt_state_handle_event (mt_state_t *self, const struct input_event *ev);
++void mt_state_handle_event (mt_state_t *self, const struct input_event *ev);
+
+ bool mt_state_touching (const mt_state_t *self);
+
++
++/* ------------------------------------------------------------------------- *
++ * LONG PRESS HANDLER
++ * ------------------------------------------------------------------------- */
++
++/** Minimum press time to unlock screen [ms] */
++#define MT_TOUCH_LONGPRESS_DELAY_MIN 200
++
++extern void evin_iomon_generate_activity (struct input_event *ev, bool cooked, bool raw);
++
++static gboolean mt_state_long_tap_cb(gpointer data)
++{
++ struct input_event *ev;
++ mt_state_t *self;
++
++ self = (mt_state_t *)data;
++
++ if(!self)
++ goto EXIT;
++
++ self->tap_to_unlock_timer_id = 0;
++
++ if(self->current_seq_max_fingers != 1)
++ goto EXIT;
++
++ ev = malloc(sizeof(struct input_event));
++
++ mce_log(LL_CRUCIAL, "[longpress] double tap emulated from touch input");
++ mce_log(LL_DEVEL, "[longpress] double tap emulated from touch input");
++
++ ev->type = EV_MSC;
++ ev->code = MSC_GESTURE;
++ ev->value = GESTURE_DOUBLETAP;
++
++ /* Do not generate activity if ts input is grabbed */
++ if( !datapipe_get_gint(touch_grab_wanted_pipe) )
++ evin_iomon_generate_activity(ev, true, true);
++
++ submode_t submode = mce_get_submode_int32();
++
++ /* If the event eater is active, don't send anything */
++ if( submode & MCE_SUBMODE_EVEATER )
++ goto EXIT;
++
++ /* Gesture events count as actual non-synthetized
++ * user activity. */
++ evin_iomon_generate_activity(ev, false, true);
++
++ /* But otherwise are handled in powerkey.c. */
++ datapipe_exec_full(&keypress_event_pipe, &ev);
++
++EXIT:
++ return FALSE;
++}
++
+ /* ========================================================================= *
+ * TOUCH_POINT
+ * ========================================================================= */
+@@ -188,74 +216,6 @@ static int mt_point_distance2(const mt_point_t *a, const mt_point_t *b)
+ return x*x + y*y;
+ }
+
+-/* ========================================================================= *
+- * TOUCH_VECTOR
+- * ========================================================================= */
+-
+-/** Predicate for: Touch vector represents a single tap
+- *
+- * @param self Touch vector object
+- *
+- * @return true if touch vector is tap, false otherwise
+- */
+-static bool mt_touch_is_single_tap(const mt_touch_t *self)
+-{
+- bool is_single_tap = false;
+-
+- if( !self )
+- goto EXIT;
+-
+- /* A tap is done using one finger */
+- if( self->mtt_max_fingers != 1 )
+- goto EXIT;
+-
+- /* Touch release must happen close to the point of initial contact */
+- int d2 = mt_point_distance2(&self->mtt_beg_point, &self->mtt_end_point);
+- if( d2 > MT_TOUCH_DBLTAP_DIST_MAX * MT_TOUCH_DBLTAP_DIST_MAX )
+- goto EXIT;
+-
+- /* The touch duration must not be too short or too long */
+- int64_t t = self->mtt_end_tick - self->mtt_beg_tick;
+- if( t < MT_TOUCH_DBLTAP_DELAY_MIN || t > MT_TOUCH_DBLTAP_DELAY_MAX )
+- goto EXIT;
+-
+- is_single_tap = true;
+-
+-EXIT:
+- return is_single_tap;
+-}
+-
+-/** Predicate for: Two touch vectors represent a double tap
+- *
+- * @param self Current touch vector object
+- * @param prev Previous touch vector object
+- *
+- * @return true if touch vector is double tap, false otherwise
+- */
+-static bool mt_touch_is_double_tap(const mt_touch_t *self, const mt_touch_t *prev)
+-{
+- bool is_double_tap = false;
+-
+- /* Both touch vectors must classify as single taps */
+- if( !mt_touch_is_single_tap(self) || !mt_touch_is_single_tap(prev) )
+- goto EXIT;
+-
+- /* The second tap must start near to the end point of the 1st one */
+- int d2 = mt_point_distance2(&self->mtt_beg_point, &prev->mtt_end_point);
+- if( d2 > MT_TOUCH_DBLTAP_DIST_MAX * MT_TOUCH_DBLTAP_DIST_MAX )
+- goto EXIT;
+-
+- /* The delay between the taps must be sufficiently small too */
+- int64_t t = self->mtt_beg_tick - prev->mtt_end_tick;
+- if( t < MT_TOUCH_DBLTAP_DELAY_MIN || t > MT_TOUCH_DBLTAP_DELAY_MAX )
+- goto EXIT;
+-
+- is_double_tap = true;
+-
+-EXIT:
+- return is_double_tap;
+-}
+-
+ /* ========================================================================= *
+ * TOUCH_STATE
+ * ========================================================================= */
+@@ -273,6 +233,11 @@ mt_state_reset(mt_state_t *self)
+ mt_point_invalidate(self->mts_point_array + i);
+
+ self->mts_point_slot = 0;
++
++ if(self->tap_to_unlock_timer_id != 0) {
++ g_source_remove(self->tap_to_unlock_timer_id);
++ self->tap_to_unlock_timer_id = 0;
++ }
+ }
+
+ /** Update touch position tracking state
+@@ -281,10 +246,9 @@ mt_state_reset(mt_state_t *self)
+ *
+ * @return true if a double tap was just detected, false otherwise
+ */
+-static bool
++static void
+ mt_state_update(mt_state_t *self)
+ {
+- bool dbltap_seen = false;
+ size_t finger_count = 0;
+
+ /* Count fingers on screen and update position of one finger touch */
+@@ -304,43 +268,25 @@ mt_state_update(mt_state_t *self)
+
+ /* Skip the rest if the number of fingers on screen does not change */
+ if( self->mts_point_count == finger_count )
+- goto EXIT;
++ return;
+
+- /* Convert timestamp from input event to 1ms accurate tick counter */
+- int64_t tick = self->mts_event_time.tv_sec * 1000LL + self->mts_event_time.tv_usec / 1000;
+-
+- /* When initial touch is detected, update the history buffer to reflect
+- * the current state of affairs */
+ if( self->mts_point_count == 0 ) {
+- memmove(self->mts_tap_arr+1, self->mts_tap_arr+0,
+- sizeof self->mts_tap_arr - sizeof *self->mts_tap_arr);
+-
+- self->mts_tap_arr[0].mtt_max_fingers = finger_count;
+- self->mts_tap_arr[0].mtt_beg_point = self->mts_point_tracked;
+- self->mts_tap_arr[0].mtt_beg_tick = tick;
++ self->current_seq_max_fingers = finger_count;
++ self->tap_to_unlock_timer_id =
++ g_timeout_add(MT_TOUCH_LONGPRESS_DELAY_MIN,
++ mt_state_long_tap_cb, self);
+ }
+
+- /* Maintain maximum number of fingers seen on screen */
+- if( self->mts_tap_arr[0].mtt_max_fingers < finger_count )
+- self->mts_tap_arr[0].mtt_max_fingers = finger_count;
+-
+- /* Update touch end position and time */
+- self->mts_tap_arr[0].mtt_end_point = self->mts_point_tracked;
+- self->mts_tap_arr[0].mtt_end_tick = tick;
++ if( self->current_seq_max_fingers < finger_count )
++ self->current_seq_max_fingers = finger_count;
+
+- /* When final finger is lifted, check if the history buffer content
+- * looks like a double tap */
+- if( finger_count == 0 ) {
+- if( mt_touch_is_double_tap(self->mts_tap_arr+0, self->mts_tap_arr+1) ) {
+- if( ! mt_touch_is_double_tap(self->mts_tap_arr+1, self->mts_tap_arr+2) )
+- dbltap_seen = true;
+- }
++ /* When last touch is detected, delete the current timeout */
++ if( finger_count == 0 && self->tap_to_unlock_timer_id != 0 ) {
++ g_source_remove(self->tap_to_unlock_timer_id);
++ self->tap_to_unlock_timer_id = 0;
+ }
+
+ self->mts_point_count = finger_count;
+-
+-EXIT:
+- return dbltap_seen;
+ }
+
+ /** Handle multitouch protocol A event stream
+@@ -479,19 +425,15 @@ mt_state_handle_event_b(mt_state_t *self, const struct input_event *ev)
+ * @param self Multitouch state object
+ * @param ev Input event
+ */
+-bool
++void
+ mt_state_handle_event(mt_state_t *self, const struct input_event *ev)
+ {
+- bool dbltap = false;
+-
+ self->mts_event_time = ev->time;
+
+ self->mts_event_handler_cb(self, ev);
+
+ if( ev->type == EV_SYN && ev->code == SYN_REPORT )
+- dbltap = mt_state_update(self);
+-
+- return dbltap;
++ mt_state_update(self);
+ }
+
+ /** Check if there is at least one finger on screen at the momement
+@@ -538,6 +480,8 @@ mt_state_create(bool protocol_b)
+
+ self->mts_point_count = 0;
+
++ self->tap_to_unlock_timer_id = 0;
++
+ mt_state_reset(self);
+
+ mt_point_invalidate(&self->mts_mouse);
+diff --git a/multitouch.h b/multitouch.h
+index b65a554..7f0b18c 100644
+--- a/multitouch.h
++++ b/multitouch.h
+@@ -34,7 +34,7 @@ typedef struct mt_state_t mt_state_t;
+
+ mt_state_t *mt_state_create (bool protocol_b);
+ void mt_state_delete (mt_state_t *self);
+-bool mt_state_handle_event (mt_state_t *self, const struct input_event *ev);
++void mt_state_handle_event (mt_state_t *self, const struct input_event *ev);
+ bool mt_state_touching (const mt_state_t *self);
+
+ #endif /* MCE_MULTITOUCH_H_ */
diff --git a/community/mce/0001-Keep-screen-on-by-default-on-emulator.patch b/community/mce/0001-Keep-screen-on-by-default-on-emulator.patch
new file mode 100644
index 0000000000..50bf36e055
--- /dev/null
+++ b/community/mce/0001-Keep-screen-on-by-default-on-emulator.patch
@@ -0,0 +1,22 @@
+From fb115fc533b8e1072d1b9c5b06e5f926ec99dac1 Mon Sep 17 00:00:00 2001
+From: Florent Revest <revestflo@gmail.com>
+Date: Wed, 21 Feb 2018 15:54:02 +0100
+Subject: [PATCH] Keep screen on by default on emulator
+
+---
+ modules/display.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/display.h b/modules/display.h
+index 8bd4513..43a0ae5 100644
+--- a/modules/display.h
++++ b/modules/display.h
+@@ -434,7 +434,7 @@ typedef enum {
+ * logic without modifying the timeout values.
+ */
+ # define MCE_SETTING_BLANKING_INHIBIT_MODE MCE_SETTING_DISPLAY_PATH "/inhibit_blank_mode"
+-# define MCE_DEFAULT_BLANKING_INHIBIT_MODE 0 // = INHIBIT_OFF
++# define MCE_DEFAULT_BLANKING_INHIBIT_MODE 1 // = INHIBIT_ON
+
+ /** Kbd slide inhibit type */
+ typedef enum {
diff --git a/community/mce/0002-tilt-to-wake-Wake-screen-when-wrist-gesture-arrives.patch b/community/mce/0002-tilt-to-wake-Wake-screen-when-wrist-gesture-arrives.patch
new file mode 100644
index 0000000000..09eee154a4
--- /dev/null
+++ b/community/mce/0002-tilt-to-wake-Wake-screen-when-wrist-gesture-arrives.patch
@@ -0,0 +1,592 @@
+From f37925316e80f8b9765e51909bce21eba1843c0d Mon Sep 17 00:00:00 2001
+From: MagneFire <IDaNLContact@gmail.com>
+Date: Sun, 7 Mar 2021 21:44:09 +0100
+Subject: [PATCH] tilt-to-wake: Wake screen when wrist gesture arrives.
+
+---
+ builtin-gconf.c | 10 ++
+ datapipe.c | 4 +
+ datapipe.h | 1 +
+ evdev.h | 1 +
+ mce-sensorfw.c | 206 ++++++++++++++++++++++++++++++++++++++
+ mce-sensorfw.h | 4 +
+ modules/display.h | 8 ++
+ modules/sensor-gestures.c | 25 +++++
+ tests/ut/ut_display.c | 5 +
+ tools/mcetool.c | 32 ++++++
+ 10 files changed, 296 insertions(+)
+
+diff --git a/builtin-gconf.c b/builtin-gconf.c
+index 5517292..b04689c 100644
+--- a/builtin-gconf.c
++++ b/builtin-gconf.c
+@@ -1265,6 +1265,16 @@ static const setting_t gconf_defaults[] =
+ .type = "b",
+ .def = G_STRINGIFY(MCE_DEFAULT_FLIPOVER_GESTURE_ENABLED),
+ },
++ {
++ .key = MCE_SETTING_WRIST_GESTURE_ENABLED,
++ .type = "b",
++ .def = G_STRINGIFY(MCE_DEFAULT_WRIST_GESTURE_ENABLED),
++ },
++ {
++ .key = MCE_SETTING_WRIST_GESTURE_AVAILABLE,
++ .type = "i",
++ .def = G_STRINGIFY(MCE_DEFAULT_WRIST_GESTURE_AVAILABLE),
++ },
+ {
+ .key = MCE_SETTING_ORIENTATION_CHANGE_IS_ACTIVITY,
+ .type = "b",
+diff --git a/datapipe.c b/datapipe.c
+index 8daee62..89c550d 100644
+--- a/datapipe.c
++++ b/datapipe.c
+@@ -700,6 +700,9 @@ datapipe_t proximity_sensor_required_pipe = DATAPIPE_INIT(proximity_sensor
+ /** proximity blanking; read only */
+ datapipe_t proximity_blanked_pipe = DATAPIPE_INIT(proximity_blanked, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
+
++/** wrist gesture; read only */
++datapipe_t wristgesture_sensor_pipe = DATAPIPE_INIT(wristgesture_sensor, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
++
+ /** Ambient light sensor; read only */
+ datapipe_t light_sensor_actual_pipe = DATAPIPE_INIT(light_sensor_actual, int, 400, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
+
+@@ -1346,6 +1349,7 @@ void mce_datapipe_quit(void)
+ datapipe_free(&proximity_sensor_effective_pipe);
+ datapipe_free(&proximity_sensor_required_pipe);
+ datapipe_free(&proximity_blanked_pipe);
++ datapipe_free(&wristgesture_sensor_pipe);
+ datapipe_free(&light_sensor_actual_pipe);
+ datapipe_free(&light_sensor_filtered_pipe);
+ datapipe_free(&light_sensor_poll_request_pipe);
+diff --git a/datapipe.h b/datapipe.h
+index 780881f..f5827a3 100644
+--- a/datapipe.h
++++ b/datapipe.h
+@@ -243,6 +243,7 @@ extern datapipe_t proximity_sensor_actual_pipe;
+ extern datapipe_t proximity_sensor_effective_pipe;
+ extern datapipe_t proximity_sensor_required_pipe;
+ extern datapipe_t proximity_blanked_pipe;
++extern datapipe_t wristgesture_sensor_pipe;
+ extern datapipe_t light_sensor_actual_pipe;
+ extern datapipe_t light_sensor_filtered_pipe;
+ extern datapipe_t light_sensor_poll_request_pipe;
+diff --git a/evdev.h b/evdev.h
+index be89a42..e7faf7a 100644
+--- a/evdev.h
++++ b/evdev.h
+@@ -55,6 +55,7 @@ typedef enum {
+ GESTURE_SWIPE_FROM_BOTTOM = 3,
+ GESTURE_DOUBLETAP = 4, /* To conform with value used in
+ * Nokia N9 kernel driver */
++ GESTURE_TILT_TO_WAKE = 5,
+ GESTURE_FPWAKEUP = 16,
+
+ /* Modifiers */
+diff --git a/mce-sensorfw.c b/mce-sensorfw.c
+index c71e5f7..7c49104 100644
+--- a/mce-sensorfw.c
++++ b/mce-sensorfw.c
+@@ -30,6 +30,8 @@
+ #include "mce-log.h"
+ #include "mce-dbus.h"
+ #include "libwakelock.h"
++#include "evdev.h"
++#include "mce-setting.h"
+
+ #include <linux/input.h>
+
+@@ -195,6 +197,7 @@ typedef enum
+ SFW_SENSOR_ID_PS,
+ SFW_SENSOR_ID_ALS,
+ SFW_SENSOR_ID_ORIENT,
++ SFW_SENSOR_ID_WRIST,
+ SFW_SENSOR_ID_ACCELEROMETER,
+ SFW_SENSOR_ID_COMPASS,
+ SFW_SENSOR_ID_GYROSCOPE,
+@@ -218,6 +221,7 @@ sensor_id_available(sensor_id_t id)
+ case SFW_SENSOR_ID_PS:
+ case SFW_SENSOR_ID_ALS:
+ case SFW_SENSOR_ID_ORIENT:
++ case SFW_SENSOR_ID_WRIST:
+ break;
+ default:
+ available = mce_in_sensortest_mode();
+@@ -268,6 +272,7 @@ sensor_id_available(sensor_id_t id)
+ #define SFW_SENSOR_INTERFACE_PS "local.ProximitySensor"
+ #define SFW_SENSOR_INTERFACE_ALS "local.ALSSensor"
+ #define SFW_SENSOR_INTERFACE_ORIENT "local.OrientationSensor"
++#define SFW_SENSOR_INTERFACE_WRIST "local.WristGestureSensor"
+ #define SFW_SENSOR_INTERFACE_ACCELEROMETER "local.AccelerometerSensor"
+ #define SFW_SENSOR_INTERFACE_COMPASS "local.CompassSensor"
+ #define SFW_SENSOR_INTERFACE_GYROSCOPE "local.GyroscopeSensor"
+@@ -311,6 +316,7 @@ sensor_id_available(sensor_id_t id)
+ #define SFW_SENSOR_METHOD_READ_PS "proximity"
+ #define SFW_SENSOR_METHOD_READ_ALS "lux"
+ #define SFW_SENSOR_METHOD_READ_ORIENT "orientation"
++#define SFW_SENSOR_METHOD_READ_WRIST "wristgesture"
+ #define SFW_SENSOR_METHOD_READ_ACCELEROMETER "xyz"
+ #define SFW_SENSOR_METHOD_READ_COMPASS "value" // or "declinationvalue"?
+ #define SFW_SENSOR_METHOD_READ_GYROSCOPE "value"
+@@ -335,6 +341,7 @@ sensor_id_available(sensor_id_t id)
+ #define SFW_SENSOR_NAME_PS "proximitysensor"
+ #define SFW_SENSOR_NAME_ALS "alssensor"
+ #define SFW_SENSOR_NAME_ORIENT "orientationsensor"
++#define SFW_SENSOR_NAME_WRIST "wristgesturesensor"
+ #define SFW_SENSOR_NAME_ACCELEROMETER "accelerometersensor"
+ #define SFW_SENSOR_NAME_COMPASS "compasssensor"
+ #define SFW_SENSOR_NAME_GYROSCOPE "gyroscopesensor"
+@@ -348,6 +355,13 @@ sensor_id_available(sensor_id_t id)
+ #define SFW_SENSOR_NAME_TEMPERATURE "temperaturesensor"
+
+ // ----------------------------------------------------------------
++#ifndef MCE_SETTING_DISPLAY_PATH
++#define MCE_SETTING_DISPLAY_PATH "/system/osso/dsm/display"
++#endif
++
++#ifndef MCE_SETTING_WRIST_GESTURE_AVAILABLE
++#define MCE_SETTING_WRIST_GESTURE_AVAILABLE MCE_SETTING_DISPLAY_PATH "/wrist_sensor_available"
++#endif
+
+ /* ========================================================================= *
+ * FORWARD_DECLARATIONS
+@@ -365,6 +379,7 @@ typedef struct sfw_backend_t sfw_backend_t;
+ typedef struct sfw_sample_als_t sfw_sample_als_t;
+ typedef struct sfw_sample_ps_t sfw_sample_ps_t;
+ typedef struct sfw_sample_orient_t sfw_sample_orient_t;
++typedef struct sfw_sample_wrist_t sfw_sample_wrist_t;
+ typedef struct sfw_sample_accelerometer_t sfw_sample_accelerometer_t;
+ typedef struct sfw_sample_compass_t sfw_sample_compass_t;
+ typedef struct sfw_sample_gyroscope_t sfw_sample_gyroscope_t;
+@@ -400,6 +415,9 @@ typedef struct sfw_sample_temperature_t sfw_sample_temperature_t;
+ /** Ambient light level [lux] to use when sensor can't be enabled */
+ #define SFW_NOTIFY_DEFAULT_ALS 400
+
++#define SFW_NOTIFY_DEFAULT_WRIST false
++#define SFW_NOTIFY_EXCEPTION_WRIST false
++
+ /** Orientation state to use when sensor can't be enabled */
+ #define SFW_NOTIFY_DEFAULT_ORIENT MCE_ORIENTATION_UNDEFINED
+
+@@ -479,6 +497,16 @@ struct sfw_sample_orient_t
+
+ static const char *sfw_sample_orient_repr(const sfw_sample_orient_t *self);
+
++/** Wrist gesture data block as sensord sends them */
++struct sfw_sample_wrist_t
++{
++ /* microseconds, monotonic */
++ uint64_t wrist_timestamp;
++
++ /* wrist tilted [bool] */
++ uint8_t wrist_tilted;
++};
++
+ typedef enum sfw_lid_type_t
+ {
+ SFW_LID_TYPE_UNKNOWN = -1, // UnknownLid
+@@ -724,6 +752,7 @@ static bool sfw_backend_parse_data (DBusMessageIter *data, int arg_
+ static bool sfw_backend_als_value_cb (sfw_plugin_t *plugin, DBusMessageIter *data);
+ static bool sfw_backend_ps_value_cb (sfw_plugin_t *plugin, DBusMessageIter *data);
+ static bool sfw_backend_orient_value_cb (sfw_plugin_t *plugin, DBusMessageIter *data);
++static bool sfw_backend_wrist_value_cb (sfw_plugin_t *plugin, DBusMessageIter *data);
+ static bool sfw_backend_accelerometer_value_cb (sfw_plugin_t *plugin, DBusMessageIter *data);
+ static bool sfw_backend_compass_value_cb (sfw_plugin_t *plugin, DBusMessageIter *data);
+ static bool sfw_backend_gyroscope_value_cb (sfw_plugin_t *plugin, DBusMessageIter *data);
+@@ -739,6 +768,7 @@ static bool sfw_backend_temperature_value_cb (sfw_plugin_t *plugin, DBusMessa
+ static void sfw_backend_als_sample_cb (sfw_plugin_t *plugin, sfw_notify_t type, const void *sample);
+ static void sfw_backend_ps_sample_cb (sfw_plugin_t *plugin, sfw_notify_t type, const void *sample);
+ static void sfw_backend_orient_sample_cb (sfw_plugin_t *plugin, sfw_notify_t type, const void *sample);
++static void sfw_backend_wrist_sample_cb (sfw_plugin_t *plugin, sfw_notify_t type, const void *sample);
+ static void sfw_backend_accelerometer_sample_cb (sfw_plugin_t *plugin, sfw_notify_t type, const void *sample);
+ static void sfw_backend_compass_sample_cb (sfw_plugin_t *plugin, sfw_notify_t type, const void *sample);
+ static void sfw_backend_gyroscope_sample_cb (sfw_plugin_t *plugin, sfw_notify_t type, const void *sample);
+@@ -1209,6 +1239,8 @@ static void sfw_service_do_query (sfw_service_t *self);
+ static sfw_plugin_t *sfw_service_plugin (const sfw_service_t *self, sensor_id_t id);
+ static void sfw_service_set_sensor (const sfw_service_t *self, sensor_id_t id, bool enable);
+
++static void sfw_set_wrist_available (sfw_plugin_t * plugin);
++
+ /* ========================================================================= *
+ * SENSORFW_EXCEPTION
+ * ========================================================================= */
+@@ -1246,6 +1278,9 @@ static void (*sfw_notify_als_cb)(int lux) = 0;
+ /** Orientation change callback used for notifying upper level logic */
+ static void (*sfw_notify_orient_cb)(int state) = 0;
+
++/** Wrist gesture change callback used for notifying upper level logic */
++static void (*sfw_notify_wrist_cb)(int state) = 0;
++
+ // (exported API defined in "mce-sensorfw.h")
+
+ static gboolean mce_sensorfw_evdev_cb (GIOChannel *chn, GIOCondition cnd, gpointer aptr);
+@@ -1582,6 +1617,31 @@ EXIT:
+ return ack;
+ }
+
++static bool
++sfw_backend_wrist_value_cb(sfw_plugin_t *plugin, DBusMessageIter *data)
++{
++ bool ack = false;
++ dbus_uint64_t tck = 0;
++ dbus_uint32_t val = 0;
++
++ if( !sfw_backend_parse_data(data,
++ DBUS_TYPE_UINT64, &tck,
++ DBUS_TYPE_UINT32, &val,
++ DBUS_TYPE_INVALID) )
++ goto EXIT;
++
++ const sfw_sample_wrist_t sample = {
++ .wrist_timestamp = tck,
++ .wrist_tilted = (val < 1) ? true : false,
++ };
++
++ sfw_plugin_handle_sample(plugin, &sample);
++
++ ack = true;
++EXIT:
++ return ack;
++}
++
+ static bool
+ sfw_backend_accelerometer_value_cb(sfw_plugin_t *plugin, DBusMessageIter *data)
+ {
+@@ -2116,6 +2176,114 @@ sfw_backend_orient_sample_cb(sfw_plugin_t *plugin, sfw_notify_t type, const void
+ return;
+ }
+
++extern void evin_iomon_generate_activity (struct input_event *ev, bool cooked, bool raw);
++
++/** Callback for handling wrist events from sensord */
++static void
++sfw_backend_wrist_sample_cb(sfw_plugin_t *plugin, sfw_notify_t type, const void *sampledata)
++{
++ static const sfw_sample_wrist_t default_value = {
++ .wrist_tilted = SFW_NOTIFY_DEFAULT_WRIST,
++ };
++
++ static sfw_sample_wrist_t cached_value = {
++ .wrist_tilted = SFW_NOTIFY_DEFAULT_WRIST,
++ };
++
++ static bool tracking_active = false;
++
++ struct input_event *ev;
++
++ (void)plugin;
++ const sfw_sample_wrist_t *sample = sampledata;
++
++ if( sample ) {
++ mce_log(LL_DEBUG, "WRIST: UPDATE %s %s",
++ sfw_notify_name(type),
++ sample ? "tiled" : "untiled");
++ }
++
++ switch( type ) {
++ default:
++ case NOTIFY_REPEAT:
++ break;
++
++ case NOTIFY_FORGET:
++ case NOTIFY_RESET:
++ sfw_set_wrist_available(plugin);
++ tracking_active = false;
++ cached_value = default_value;
++ break;
++
++ case NOTIFY_RESTORE:
++ sfw_set_wrist_available(plugin);
++ tracking_active = true;
++ break;
++
++ case NOTIFY_EVDEV:
++ case NOTIFY_SENSORD:
++ sfw_set_wrist_available(plugin);
++ cached_value = *sample;
++ break;
++ }
++
++ /* Default value is used unless we are in fully working state */
++ sample = tracking_active ? &cached_value : &default_value ;
++
++ if( sfw_notify_wrist_cb ) {
++ mce_log(LL_DEBUG, "WRIST: NOTIFY %s %s",
++ sfw_notify_name(type),
++ sample ? "tiled" : "untiled");
++ sfw_notify_wrist_cb(sample->wrist_tilted);
++ }
++
++ ev = malloc(sizeof(struct input_event));
++
++ mce_log(LL_DEVEL, "tilt-to-wake gesture from wrist gesture");
++
++ ev->type = EV_MSC;
++ ev->code = MSC_GESTURE;
++ ev->value = GESTURE_TILT_TO_WAKE;
++
++ evin_iomon_generate_activity(ev, true, true);
++
++ submode_t submode = mce_get_submode_int32();
++
++ /* If the event eater is active, don't send anything */
++ if( submode & MCE_SUBMODE_EVEATER )
++ goto EXIT;
++
++ /* Gesture events count as actual non-synthetized
++ * user activity. */
++ evin_iomon_generate_activity(ev, false, true);
++
++ /* But otherwise are handled in powerkey.c. */
++ datapipe_exec_full(&keypress_event_pipe, &ev);
++EXIT:
++ return;
++}
++
++/** Set availability of wrist tilt sensor based on connection state.
++ */
++static void
++sfw_set_wrist_available(sfw_plugin_t *plugin)
++{
++ mce_log(LL_DEBUG, "WRIST: sfw_set_wrist_available: %d", plugin->plg_session->ses_state);
++ switch(plugin->plg_session->ses_state) {
++ case SESSION_INITIAL:
++ case SESSION_IDLE:
++ case SESSION_REQUESTING:
++ case SESSION_INVALID:
++ mce_setting_set_int(MCE_SETTING_WRIST_GESTURE_AVAILABLE, 0);
++ break;
++ case SESSION_ACTIVE:
++ /* Only when a session is active we know that the sensor can be enabled. */
++ mce_setting_set_int(MCE_SETTING_WRIST_GESTURE_AVAILABLE, 1);
++ case SESSION_ERROR:
++ break;
++ }
++}
++
+ /** Callback for handling accelerometer events from sensord */
+ static void
+ sfw_backend_accelerometer_sample_cb(sfw_plugin_t *plugin, sfw_notify_t type, const void *sampledata)
+@@ -2608,6 +2776,15 @@ static const sfw_backend_t sfw_backend_lut[SFW_SENSOR_ID_COUNT] =
+ .be_sample_cb = sfw_backend_orient_sample_cb,
+ .be_value_method = SFW_SENSOR_METHOD_READ_ORIENT,
+ },
++ [SFW_SENSOR_ID_WRIST] = {
++ .be_sensor_name = SFW_SENSOR_NAME_WRIST,
++ .be_sensor_object = 0,
++ .be_sensor_interface = SFW_SENSOR_INTERFACE_WRIST,
++ .be_sample_size = sizeof(sfw_sample_wrist_t),
++ .be_value_cb = sfw_backend_wrist_value_cb,
++ .be_sample_cb = sfw_backend_wrist_sample_cb,
++ .be_value_method = SFW_SENSOR_METHOD_READ_WRIST,
++ },
+ [SFW_SENSOR_ID_ACCELEROMETER] = {
+ .be_sensor_name = SFW_SENSOR_NAME_ACCELEROMETER,
+ .be_sensor_object = 0,
+@@ -5183,6 +5360,35 @@ mce_sensorfw_orient_disable(void)
+
+ // ----------------------------------------------------------------
+
++/** Set Wrist notification callback
++ *
++ * @param cb function to call when Orientation events are received
++ */
++void
++mce_sensorfw_wrist_set_notify(void (*cb)(int state))
++{
++ sfw_plugin_t *plugin = sfw_service_plugin(sfw_service, SFW_SENSOR_ID_WRIST);
++ sfw_plugin_repeat_value(plugin);
++}
++
++/** Try to enable Wrist input
++ */
++void
++mce_sensorfw_wrist_enable(void)
++{
++ sfw_service_set_sensor(sfw_service, SFW_SENSOR_ID_WRIST, true);
++}
++
++/** Try to disable Wrist input
++ */
++void
++mce_sensorfw_wrist_disable(void)
++{
++ sfw_service_set_sensor(sfw_service, SFW_SENSOR_ID_WRIST, false);
++}
++
++// ----------------------------------------------------------------
++
+ /** Callback function for processing evdev events
+ *
+ * @param chn io channel
+diff --git a/mce-sensorfw.h b/mce-sensorfw.h
+index cfd8d66..1daf3c0 100644
+--- a/mce-sensorfw.h
++++ b/mce-sensorfw.h
+@@ -50,6 +50,10 @@ void mce_sensorfw_orient_set_notify(void (*cb)(int state));
+ void mce_sensorfw_orient_enable(void);
+ void mce_sensorfw_orient_disable(void);
+
++void mce_sensorfw_wrist_set_notify(void (*cb)(int state));
++void mce_sensorfw_wrist_enable(void);
++void mce_sensorfw_wrist_disable(void);
++
+ # ifdef __cplusplus
+ };
+ # endif
+diff --git a/modules/display.h b/modules/display.h
+index bfb9d4d..8075401 100644
+--- a/modules/display.h
++++ b/modules/display.h
+@@ -186,6 +186,14 @@
+ # define MCE_SETTING_ORIENTATION_CHANGE_IS_ACTIVITY MCE_SETTING_DISPLAY_PATH "/orientation_change_is_activity"
+ # define MCE_DEFAULT_ORIENTATION_CHANGE_IS_ACTIVITY true
+
++/** Whether MCE is allowed to use wrist gesture sensor */
++# define MCE_SETTING_WRIST_GESTURE_ENABLED MCE_SETTING_DISPLAY_PATH "/wrist_sensor_enabled"
++# define MCE_DEFAULT_WRIST_GESTURE_ENABLED true
++
++/** Whether the wrist gesture sensor is available on the hardware */
++# define MCE_SETTING_WRIST_GESTURE_AVAILABLE MCE_SETTING_DISPLAY_PATH "/wrist_sensor_available"
++# define MCE_DEFAULT_WRIST_GESTURE_AVAILABLE 1
++
+ /* ------------------------------------------------------------------------- *
+ * Color profile related settings
+ * ------------------------------------------------------------------------- */
+diff --git a/modules/sensor-gestures.c b/modules/sensor-gestures.c
+index f648009..5d606eb 100644
+--- a/modules/sensor-gestures.c
++++ b/modules/sensor-gestures.c
+@@ -57,6 +57,9 @@ static gint orientation_sensor_effective_id = 0;
+ static gboolean sg_flipover_gesture_enabled = MCE_DEFAULT_FLIPOVER_GESTURE_ENABLED;
+ static guint sg_flipover_gesture_enabled_setting_id = 0;
+
++/** Use of wrist gesture enabled */
++static gboolean sg_wrist_gesture_enabled = MCE_DEFAULT_WRIST_GESTURE_ENABLED;
++static guint sg_wrist_gesture_enabled_setting_id = 0;
+ /* ========================================================================= *
+ * FUNCTIONS
+ * ========================================================================= */
+@@ -465,6 +468,15 @@ static void sg_setting_cb(GConfClient *const gcc, const guint id,
+ if( id == sg_flipover_gesture_enabled_setting_id ) {
+ sg_flipover_gesture_enabled = gconf_value_get_bool(gcv);
+ }
++ else if( id == sg_wrist_gesture_enabled_setting_id ) {
++ sg_wrist_gesture_enabled = gconf_value_get_bool(gcv);
++ mce_log(LL_CRIT, "sg_wrist_gesture_enabled: %d", sg_wrist_gesture_enabled);
++ if (sg_wrist_gesture_enabled) {
++ mce_sensorfw_wrist_enable();
++ } else {
++ mce_sensorfw_wrist_disable();
++ }
++ }
+ else {
+ mce_log(LL_WARN, "Spurious GConf value received; confused!");
+ }
+@@ -482,6 +494,11 @@ static void sg_setting_init(void)
+ MCE_DEFAULT_FLIPOVER_GESTURE_ENABLED,
+ sg_setting_cb,
+ &sg_flipover_gesture_enabled_setting_id);
++ mce_setting_track_bool(MCE_SETTING_WRIST_GESTURE_ENABLED,
++ &sg_wrist_gesture_enabled,
++ MCE_DEFAULT_WRIST_GESTURE_ENABLED,
++ sg_setting_cb,
++ &sg_wrist_gesture_enabled_setting_id);
+ }
+
+ /** Stop tracking setting changes */
+@@ -489,6 +506,8 @@ static void sg_setting_quit(void)
+ {
+ mce_setting_notifier_remove(sg_flipover_gesture_enabled_setting_id),
+ sg_flipover_gesture_enabled_setting_id = 0;
++ mce_setting_notifier_remove(sg_wrist_gesture_enabled_setting_id),
++ sg_wrist_gesture_enabled_setting_id = 0;
+ }
+
+ /* ========================================================================= *
+@@ -508,6 +527,12 @@ const gchar *g_module_check_init(GModule *module)
+ sg_setting_init();
+ sg_datapipe_init();
+
++ if (sg_wrist_gesture_enabled) {
++ mce_sensorfw_wrist_enable();
++ } else {
++ mce_sensorfw_wrist_disable();
++ }
++
+ return NULL;
+ }
+
+diff --git a/tests/ut/ut_display.c b/tests/ut/ut_display.c
+index 216b3d8..673d01c 100644
+--- a/tests/ut/ut_display.c
++++ b/tests/ut/ut_display.c
+@@ -821,6 +821,11 @@ void, mce_sensorfw_orient_set_notify, (void (*cb)(int state)))
+ (void)cb;
+ }
+
++EXTERN_STUB (
++void, mce_sensorfw_wrist_enable, (void))
++{
++}
++
+ /*
+ * tklock.c stubs {{{1
+ */
+diff --git a/tools/mcetool.c b/tools/mcetool.c
+index e067c43..f5d519d 100644
+--- a/tools/mcetool.c
++++ b/tools/mcetool.c
+@@ -4159,6 +4159,29 @@ static void xmce_get_orientation_change_is_activity(void)
+ printf("%-"PAD1"s %s\n", "Orientation change is activity:", txt);
+ }
+
++/** Set wrist gesture detection toggle
++ *
++ * @param args string suitable for interpreting as enabled/disabled
++ */
++static bool xmce_set_wrist_gesture_detection(const char *args)
++{
++ gboolean val = xmce_parse_enabled(args);
++ xmce_setting_set_bool(MCE_SETTING_WRIST_GESTURE_ENABLED, val);
++ return true;
++}
++
++/** Show wrist gesture detection toggle
++ */
++static void xmce_get_wrist_gesture_detection(void)
++{
++ gboolean val = 0;
++ char txt[32] = "unknown";
++
++ if( xmce_setting_get_bool(MCE_SETTING_WRIST_GESTURE_ENABLED, &val) )
++ snprintf(txt, sizeof txt, "%s", val ? "enabled" : "disabled");
++ printf("%-"PAD1"s %s\n", "Wrist tilt gesture detection:", txt);
++}
++
+ /** Set flipover gesture detection toggle
+ *
+ * @param args string suitable for interpreting as enabled/disabled
+@@ -6532,6 +6555,7 @@ static bool xmce_get_status(const char *args)
+ xmce_get_orientation_sensor_mode();
+ xmce_get_orientation_change_is_activity();
+ xmce_get_flipover_gesture_detection();
++ xmce_get_wrist_gesture_detection();
+ xmce_get_ps_mode();
+ xmce_get_ps_on_demand();
+ xmce_get_ps_uncover_delay();
+@@ -7542,6 +7566,14 @@ static const mce_opt_t options[] =
+ " 'enabled' flipover gestures can be used to silence calls/alarms\n"
+ " 'disabled' turning device over does not affect calls/alarms\n"
+ },
++ {
++ .name = "set-wrist-gesture-detection",
++ .with_arg = xmce_set_wrist_gesture_detection,
++ .values = "enabled|disabled",
++ "set the wrist gesture detection toggle; valid modes are:\n"
++ " 'enabled' flipover gestures can be used to silence calls/alarms\n"
++ " 'disabled' turning device over does not affect calls/alarms\n"
++ },
+ {
+ .name = "get-color-profile-ids",
+ .flag = 'a',
diff --git a/community/mce/0003-inactivity-Allow-activities-in-lockscreen-mode.-aste.patch b/community/mce/0003-inactivity-Allow-activities-in-lockscreen-mode.-aste.patch
new file mode 100644
index 0000000000..838a83025e
--- /dev/null
+++ b/community/mce/0003-inactivity-Allow-activities-in-lockscreen-mode.-aste.patch
@@ -0,0 +1,58 @@
+From 6a4fad517e311a05a10f87e940faed42d3d9a67d Mon Sep 17 00:00:00 2001
+From: MagneFire <IDaNLContact@gmail.com>
+Date: Sun, 7 Mar 2021 22:36:05 +0100
+Subject: [PATCH] inactivity: Allow activities in lockscreen mode.
+ asteroid-launcher marks the watchface as the lockscreen. When the watchface
+ is visible taping the screen would not keep the screen awake.
+
+---
+ modules/inactivity.c | 36 +++++++-----------------------------
+ 1 file changed, 7 insertions(+), 29 deletions(-)
+
+diff --git a/modules/inactivity.c b/modules/inactivity.c
+index 5ac9d19..74bde99 100644
+--- a/modules/inactivity.c
++++ b/modules/inactivity.c
+@@ -360,35 +360,13 @@ static bool mia_activity_allowed(void)
+ goto DENY;
+ }
+
+- /* Normally activity does not apply when lockscreen is active */
+- if( submode & MCE_SUBMODE_TKLOCK ) {
+-
+- /* Active alarm */
+- switch( alarm_ui_state ) {
+- case MCE_ALARM_UI_RINGING_INT32:
+- case MCE_ALARM_UI_VISIBLE_INT32:
+- goto ALLOW;
+-
+- default:
+- break;
+- }
+-
+- /* Active call */
+- switch( call_state ) {
+- case CALL_STATE_RINGING:
+- case CALL_STATE_ACTIVE:
+- goto ALLOW;
+-
+- default:
+- break;
+- }
+-
+- /* Expecting user interaction */
+- if( interaction_expected )
+- goto ALLOW;
+-
+- goto DENY;
+- }
++ /* Allways allow activity when lockscreen is active.
++ *
++ * This allows the lockscreen to be longer visible,
++ * because the blanking timer can be cancelled.
++ */
++ if( submode & MCE_SUBMODE_TKLOCK )
++ goto ALLOW;
+
+ ALLOW:
+ allowed = true;
diff --git a/community/mce/0004-Ambient-mode-Adapt-low-power-mode-to-allow-for-actua.patch b/community/mce/0004-Ambient-mode-Adapt-low-power-mode-to-allow-for-actua.patch
new file mode 100644
index 0000000000..0a85ccbded
--- /dev/null
+++ b/community/mce/0004-Ambient-mode-Adapt-low-power-mode-to-allow-for-actua.patch
@@ -0,0 +1,631 @@
+From d1ddfc4611ebbd9ac7beebb1add42d66e68b7094 Mon Sep 17 00:00:00 2001
+From: MagneFire <IDaNLContact@gmail.com>
+Date: Sun, 7 Mar 2021 22:49:48 +0100
+Subject: [PATCH] Ambient mode: Adapt low-power-mode to allow for actual
+ ambient mode. Refactor the low power mode to actually work in low power
+ mode(deep sleep). There are some challenges when it comes to transitions
+ (i.e. screen on -> screen lpm). There are multiple parts responsible for
+ setting the next screen state.
+
+Depending on what state the screen is the following may happen:
+- Default, screen on (currently watchface is shown) -> screen lpm.
+- In the `long timeout`(from asteroid-launcher) state, the screen may first go from screen on -> screen dim -> screen lpm
+- When the screen is off and a notification arrives the screen isn't actually in the on state, so there is a change needed in tklock.c to fix that.
+
+Another part that is very important is the ambient light sensor module.
+There is also the filter-brightness-als module. This module is responsible for changing the range of the brightness depending on the currently set brightness and the ambient light sensor value.
+So if the brightness is set to 0% the brightness profile use is 0, for 100% the profile 20 is used. These profiles are defined in `als-defaults.ini`.
+For LPM/ambient mode a special profiles set is used (LPM).
+In LPM mode we want to limit the maximum brightness.
+So a default profile is used that limits the maximum brightness to 28%. If the als reports a lower value then a lower screen brightness is also possible.
+An important side note is that, the als mode is enabled even if no such sensor exist. For those devices, the als value of 400 is used.
+This value also signifies the maximum brightness in LPM mode.
+Because the minimum brightness can vary between devices it is suggested to create alternative profiles for such devices.
+
+---
+ inifiles/als-defaults.ini | 13 +-
+ inifiles/mce.ini | 2 +-
+ mce-dbus.h | 4 +
+ mce-fbdev.c | 19 ++-
+ mce-fbdev.h | 1 +
+ mce.conf | 6 +
+ modules/display.c | 210 ++++++++++++++++++++++++++++++--
+ modules/display.h | 6 +-
+ modules/filter-brightness-als.c | 13 +-
+ powerkey.h | 2 +-
+ tklock.c | 2 +-
+ 11 files changed, 253 insertions(+), 25 deletions(-)
+
+diff --git a/inifiles/als-defaults.ini b/inifiles/als-defaults.ini
+index 4a77fc3..c5339c0 100644
+--- a/inifiles/als-defaults.ini
++++ b/inifiles/als-defaults.ini
+@@ -1,10 +1,11 @@
+ # Configuration file for MCE - Automatic display/led/keypad brightness control
+ #
+-# Configuration for tuning lisplay backlight, keypad backlight and indication led
++# Configuration for tuning display backlight, keypad backlight and indication led
+ # brightness base on data from Ambient Light Sensor
+ #
+ # Limits are Ambient light sensor values [lux]
+ # Levels are brightness percentages
++# Profiles are input brightness percentages converted to profile range (40% -> Profile 8)
+ #
+ # Minimum, ..., Maximum correspond with brightness setting 1 ... 5
+
+@@ -85,5 +86,11 @@ LevelsProfile0=30;33;36;39;42;45;48;51;54;57;64;68;72;76;80;84;88;92;96;100
+
+ [BrightnessLPM]
+
+-LimitsProfile0=1;4;27;99;700;778;864;960;1066;1184;1315;1460;1622;1801;2000
+-LevelsProfile0=1;2;3;4;5;15;24;34;43;53;62;72;81;91;100
++# Use Limits and Levels profiles to select the desired brightness for a given ALS and current brightness.
++# When the device doesn't have an ambient light sensor the default value for 400 will be used.
++# The value 400 is over 350, so the value for 100000(=> 28%) will be used.
++# Profiles can be added to have different LPM brightness levels at different input brightness levels.
++# This sets the maximum brightness to 28% in ambient mode.
++# Why 28%? Because this is the brightness level when input brightness is set to 0 and als is not available.
++LimitsProfile0=1;2;4;6;11;19;34;61;109;195;350;100000
++LevelsProfile0=1;3;5;7;9;11;13;15;17;19;20;28
+\ No newline at end of file
+diff --git a/inifiles/mce.ini b/inifiles/mce.ini
+index 756b224..c208342 100644
+--- a/inifiles/mce.ini
++++ b/inifiles/mce.ini
+@@ -16,7 +16,8 @@
+ # to avoid unnecessary brightness fluctuations on mce startup
+ #
+ # Note: the name should not include the "lib"-prefix
+-Modules=radiostates;filter-brightness-als;display;keypad;led;battery-udev;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;memnotify;mempressure;usbmode;buttonbacklight;fingerprint;charging;
++Modules=radiostates;display;filter-brightness-als;keypad;led;battery-udev;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;memnotify;mempressure;usbmode;buttonbacklight;fingerprint;charging;
++
+
+ [KeyPad]
+
+diff --git a/mce-dbus.h b/mce-dbus.h
+index e43da0b..828ffb5 100644
+--- a/mce-dbus.h
++++ b/mce-dbus.h
+@@ -101,6 +101,10 @@
+ /* Enabling/disabling display updates via compositor service */
+ # define COMPOSITOR_SET_UPDATES_ENABLED "setUpdatesEnabled"
+
++#define COMPOSITOR_SET_AMBIENT_UPDATES_ENABLED "setAmbientUpdatesEnabled"
++#define COMPOSITOR_SET_AMBIENT_MODE_ENABLED "setAmbientEnabled"
++#define MCE_DISPLAY_LPM_SET_SUPPORTED "set_lpm_supported"
++
+ /** Query owner of topmost ui window */
+ # define COMPOSITOR_GET_TOPMOST_WINDOW_PID "privateTopmostWindowProcessId"
+
+diff --git a/mce-fbdev.c b/mce-fbdev.c
+index 7db8762..6212a91 100644
+--- a/mce-fbdev.c
++++ b/mce-fbdev.c
+@@ -58,6 +58,8 @@ static bool fbdev_use_hybris = false;
+ /** Flag for: Opening frame buffer device is allowed */
+ static bool mce_fbdev_allow_open = false;
+
++static bool mce_fbdev_power_vsync_suspend = false;
++
+ /* ========================================================================= *
+ * FBDEV_FILE_DESCRIPTOR
+ * ========================================================================= */
+@@ -239,6 +241,12 @@ void mce_fbdev_linger_after_exit(int delay_ms)
+ * FRAMEBUFFER_POWER
+ * ========================================================================= */
+
++void mce_fbdev_set_suspend_mode(bool vsync_suspend)
++{
++ mce_log(LL_DEBUG, "fbdev suspend_mode %s", vsync_suspend ? "on" : "off");
++ mce_fbdev_power_vsync_suspend = vsync_suspend;
++}
++
+ /** Set the frame buffer power state
+ *
+ * MCE uses this function for display power control only if autosuspend
+@@ -252,10 +260,17 @@ void mce_fbdev_linger_after_exit(int delay_ms)
+ */
+ void mce_fbdev_set_power(bool power_on)
+ {
+- mce_log(LL_DEBUG, "fbdev power %s", power_on ? "up" : "down");
++ mce_log(LL_DEBUG, "fbdev power %s", power_on ? "up" : (mce_fbdev_power_vsync_suspend ? "ambient" : "down"));
+
+ if( mce_fbdev_handle != -1 ) {
+- int value = power_on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
++ int value;
++ if (power_on) {
++ value = FB_BLANK_UNBLANK;
++ } else if (mce_fbdev_power_vsync_suspend) {
++ value = FB_BLANK_VSYNC_SUSPEND;
++ } else {
++ value = FB_BLANK_POWERDOWN;
++ }
+
+ if( ioctl(mce_fbdev_handle, FBIOBLANK, value) == -1 )
+ mce_log(LL_ERR, "%s: ioctl(FBIOBLANK,%d): %m", FB_DEVICE, value);
+diff --git a/mce-fbdev.h b/mce-fbdev.h
+index 03f09f5..18a1a08 100644
+--- a/mce-fbdev.h
++++ b/mce-fbdev.h
+@@ -36,6 +36,7 @@ void mce_fbdev_close (void);
+ void mce_fbdev_reopen (void);
+ bool mce_fbdev_is_open (void);
+
++void mce_fbdev_set_suspend_mode (bool vsync_suspend);
+ void mce_fbdev_set_power (bool power_on);
+
+ void mce_fbdev_linger_after_exit (int delay_ms);
+diff --git a/mce.conf b/mce.conf
+index 11d764e..9b46094 100644
+--- a/mce.conf
++++ b/mce.conf
+@@ -110,6 +110,12 @@
+ <allow send_destination="com.nokia.mce"
+ send_interface="com.nokia.mce.request"
+ send_member="req_display_state_lpm"/>
++ <allow send_destination="com.nokia.mce"
++ send_interface="com.nokia.mce.request"
++ send_member="set_lpm_supported"/>
++ <allow send_destination="com.nokia.mce"
++ send_interface="com.nokia.mce.request"
++ send_member="get_lpm_available"/>
+
+ <allow send_destination="com.nokia.mce"
+ send_interface="com.nokia.mce.request"
+diff --git a/modules/display.c b/modules/display.c
+index f33ec64..42ca0e5 100644
+--- a/modules/display.c
++++ b/modules/display.c
+@@ -412,6 +412,7 @@ static bool mdy_shutdown_in_progress(void);
+ * DATAPIPE_TRACKING
+ * ------------------------------------------------------------------------- */
+
++static void mdy_datapipe_ambient_light_level_cb(gconstpointer data);;
+ static void mdy_datapipe_packagekit_locked_cb(gconstpointer data);;
+ static void mdy_datapipe_system_state_cb(gconstpointer data);
+ static void mdy_datapipe_submode_cb(gconstpointer data);
+@@ -709,6 +710,9 @@ static void compositor_stm_send_pid_query (compositor_stm_t *
+ static void compositor_stm_forget_pid_query (compositor_stm_t *self);
+ static void compositor_stm_pid_query_cb (DBusPendingCall *pc, void *aptr);
+
++static void compositor_stm_send_lpm_request (compositor_stm_t *self);
++static void compositor_stm_lpm_request_cb (DBusPendingCall *pc, void *aptr);
++
+ static void compositor_stm_send_ctrl_request (compositor_stm_t *self);
+ static void compositor_stm_forget_ctrl_request(compositor_stm_t *self);
+ static void compositor_stm_ctrl_request_cb (DBusPendingCall *pc, void *aptr);
+@@ -933,6 +937,7 @@ static gboolean mdy_dbus_handle_blanking_pause_cancel_req(DBusMessage
+ static gboolean mdy_dbus_handle_display_stats_get_req(DBusMessage *const req);
+
+ static gboolean mdy_dbus_handle_desktop_started_sig(DBusMessage *const msg);
++static gboolean mdy_dbus_timed_wakeup_sig(DBusMessage *const msg);
+
+ static void mdy_dbus_init(void);
+ static void mdy_dbus_quit(void);
+@@ -1396,6 +1401,29 @@ xlat(int src_lo, int src_hi, int dst_lo, int dst_hi, int val)
+ * DATAPIPE_TRACKING
+ * ========================================================================= */
+
++/** Ambient light level; assume sensor not available.
++ * This is used to avoid changing the backlight when the als is disabled.
++ */
++static int ambient_light_level = -1;
++/**
++ * Handle ambient light level updates.
++ *
++ * @param data The ambient light level in a pointer
++ */
++static void mdy_datapipe_ambient_light_level_cb(gconstpointer data)
++{
++ bool prev = ambient_light_level;
++ ambient_light_level = GPOINTER_TO_INT(data);
++
++ if( ambient_light_level == prev )
++ goto EXIT;
++
++ /* Log by default as it might help analyzing lpm problems */
++ mce_log(LL_DEBUG, "ambient_light_level = %d", ambient_light_level);
++EXIT:
++ return;
++}
++
+ /** Cached exceptional ui state */
+ static uiexception_type_t uiexception_type = UIEXCEPTION_TYPE_NONE;
+
+@@ -1827,7 +1855,9 @@ static void mdy_datapipe_lpm_brightness_cb(gconstpointer data)
+
+ mce_log(LL_DEBUG, "input: %d -> %d", prev, curr);
+
+- if( curr == prev )
++ // Sometimes it happens that the brightness changes while the als is disabled(ambient_light_level = -1), this cause the
++ // filter to return 100%, resulting in max brightness ambient mode.
++ if( (curr == prev) || (ambient_light_level < 0))
+ goto EXIT;
+
+ mdy_brightness_set_lpm_level(curr);
+@@ -2242,6 +2272,10 @@ static datapipe_handler_t mdy_datapipe_handlers[] =
+ .datapipe = &audio_route_pipe,
+ .output_cb = mdy_datapipe_audio_route_cb,
+ },
++ {
++ .datapipe = &light_sensor_filtered_pipe,
++ .output_cb = mdy_datapipe_ambient_light_level_cb,
++ },
+ {
+ .datapipe = &packagekit_locked_pipe,
+ .output_cb = mdy_datapipe_packagekit_locked_cb,
+@@ -3527,12 +3561,11 @@ static void mdy_brightness_set_lpm_level(gint level)
+ * display state we are in or transitioning to */
+ switch( display_state_next ) {
+ case MCE_DISPLAY_LPM_ON:
++ case MCE_DISPLAY_OFF:
++ case MCE_DISPLAY_LPM_OFF:
+ mdy_brightness_set_fade_target_als(mdy_brightness_level_display_lpm);
+ break;
+-
+ default:
+- case MCE_DISPLAY_OFF:
+- case MCE_DISPLAY_LPM_OFF:
+ case MCE_DISPLAY_DIM:
+ case MCE_DISPLAY_ON:
+ case MCE_DISPLAY_UNDEF:
+@@ -4159,8 +4192,7 @@ static gboolean mdy_blanking_off_cb(gpointer data)
+ case MCE_DISPLAY_DIM:
+ if( lipstick_service_state != SERVICE_STATE_RUNNING )
+ break;
+- if( mdy_blanking_from_lockscreen() )
+- next_state = MCE_DISPLAY_LPM_ON;
++ next_state = MCE_DISPLAY_LPM_ON;
+ break;
+ default:
+ break;
+@@ -6164,6 +6196,12 @@ struct compositor_stm_t
+ */
+ DBusPendingCall *csi_ctrl_request_pc;
+
++ /** Currently pending compositor D-Bus method call
++ *
++ * Managed by compositor_stm_send_ctrl_request() & co
++ */
++ DBusPendingCall *csi_lpm_request_pc;
++
+ /** Timer id for killing unresponsive compositor process
+ *
+ * Managed by compositor_stm_schedule_killer() & co
+@@ -6213,6 +6251,7 @@ compositor_stm_ctor(compositor_stm_t *self)
+
+ /* No pending compositor dbus method call */
+ self->csi_ctrl_request_pc = 0;
++ self->csi_lpm_request_pc = 0;
+
+ /* Retry timer is inactive */
+ self->csi_retry_timer_id = 0;
+@@ -6411,6 +6450,70 @@ EXIT:
+ return;
+ }
+
++static void
++compositor_stm_send_lpm_request(compositor_stm_t *self)
++{
++ mce_log(LL_DEBUG, "compositor_stm_send_lpm_request");
++ dbus_bool_t dta = mdy_use_low_power_mode;
++
++ bool ack = dbus_send_ex2(COMPOSITOR_SERVICE,
++ COMPOSITOR_PATH,
++ COMPOSITOR_IFACE,
++ COMPOSITOR_SET_AMBIENT_MODE_ENABLED,
++ compositor_stm_lpm_request_cb,
++ COMPOSITOR_STM_DBUS_CALL_TIMEOUT,
++ self, 0,
++ &self->csi_lpm_request_pc,
++ DBUS_TYPE_BOOLEAN, &dta,
++ DBUS_TYPE_INVALID);
++
++ if( !ack )
++ mce_log(LL_NOTICE, "Failed to send low power mode enable request");
++}
++
++/** Handle reply to pending compositor state request
++ */
++static void
++compositor_stm_lpm_request_cb(DBusPendingCall *pc, void *aptr)
++{
++ compositor_stm_t *self = aptr;
++ DBusMessage *rsp = 0;
++ DBusError err = DBUS_ERROR_INIT;
++ bool ack = false;
++ mce_log(LL_DEBUG, "compositor_stm_lpm_request_cb");
++
++ if( self->csi_lpm_request_pc != pc )
++ goto EXIT;
++
++ dbus_pending_call_unref(self->csi_lpm_request_pc),
++ self->csi_lpm_request_pc = 0;
++
++ if( !(rsp = dbus_pending_call_steal_reply(pc)) )
++ goto EXIT;
++
++ if( dbus_set_error_from_message(&err, rsp) ) {
++ mce_log(LL_WARN, "%s: %s", err.name, err.message);
++ goto EXIT;
++ }
++
++ ack = true;
++
++EXIT:
++ if( ack ) {
++ mce_log(LL_DEBUG, "Compositor ack LPM request support: %d, enable: %d",
++ mdy_low_power_mode_supported, mdy_use_low_power_mode);
++ mce_fbdev_set_suspend_mode(mdy_use_low_power_mode && mdy_low_power_mode_supported);
++ } else {
++ mce_log(LL_DEBUG, "LPM request wasn't acknowledged, is the compositor available?");
++ }
++
++ if( rsp ) dbus_message_unref(rsp);
++
++ dbus_error_free(&err);
++
++ return;
++}
++
+ /* ------------------------------------------------------------------------- *
+ * managing org.nemomobile.compositor.setUpdatesEnabled() method calls
+ * ------------------------------------------------------------------------- */
+@@ -7662,7 +7765,8 @@ static void mdy_display_state_changed(void)
+ case MCE_DISPLAY_OFF:
+ case MCE_DISPLAY_LPM_OFF:
+ /* Blanking or already blanked -> set zero brightness */
+- mdy_brightness_force_level(0);
++ if (!mdy_use_low_power_mode || !mdy_low_power_mode_supported)
++ mdy_brightness_force_level(0);
+ break;
+
+ case MCE_DISPLAY_LPM_ON:
+@@ -7753,8 +7857,8 @@ static void mdy_display_state_leave(display_state_t prev_state,
+ bool have_power = mdy_stm_display_state_needs_power(prev_state);
+ bool need_power = mdy_stm_display_state_needs_power(next_state);
+
+- /* Deny ALS brightness when heading to powered off state */
+- if( !need_power ) {
++ /* Deny ALS brightness when heading to powered off state, but allow in ambient mode */
++ if( !need_power && !(mdy_use_low_power_mode && mdy_low_power_mode_supported)) {
+ mce_log(LL_DEBUG, "deny als fade");
+ mdy_brightness_als_fade_allowed = false;
+ }
+@@ -7786,7 +7890,8 @@ static void mdy_display_state_leave(display_state_t prev_state,
+ case MCE_DISPLAY_OFF:
+ case MCE_DISPLAY_LPM_OFF:
+ mdy_brightness_level_display_resume = 0;
+- mdy_brightness_set_fade_target_blank();
++ if (!mdy_use_low_power_mode || !mdy_low_power_mode_supported)
++ mdy_brightness_set_fade_target_blank();
+ break;
+
+ case MCE_DISPLAY_UNDEF:
+@@ -9786,6 +9891,39 @@ static gboolean mdy_dbus_handle_display_off_req(DBusMessage *const msg)
+ return TRUE;
+ }
+
++static gboolean mdy_dbus_handle_lpm_enabled_req(DBusMessage *const msg)
++{
++ gboolean status = FALSE;
++ dbus_bool_t low_power_mode_supported = false;
++ DBusError error = DBUS_ERROR_INIT;
++
++ mce_log(LL_DEVEL, "Received lpm support from %s",
++ mce_dbus_get_message_sender_ident(msg));
++
++ /* Extract result */
++ if (dbus_message_get_args(msg, &error,
++ DBUS_TYPE_BOOLEAN, &low_power_mode_supported,
++ DBUS_TYPE_INVALID) == FALSE) {
++ mce_log(LL_ERR, "Failed to get argument from %s.%s; %s",
++ "org.freedesktop.DBus", "NameOwnerChanged",
++ error.message);
++ goto EXIT;
++ }
++ status = TRUE;
++
++EXIT:
++ mce_log(LL_DEVEL, "The compositor %s support for ambient mode.",
++ low_power_mode_supported ? "has" : "hasn't");
++
++ // We have a variable that we should use to set lpm mode availability based on ack.
++ mdy_low_power_mode_supported = low_power_mode_supported;
++
++ // Enable/disable lpm mode based on support from the compositor.
++ compositor_stm_send_lpm_request(mdy_compositor_ipc);
++
++ return status;
++}
++
+ /** D-Bus callback for the display lpm method call
+ *
+ * @param msg The D-Bus message
+@@ -10254,6 +10392,40 @@ static gboolean mdy_dbus_handle_desktop_started_sig(DBusMessage *const msg)
+ return status;
+ }
+
++/**
++ * D-Bus callback for timed wakeup event, used to update ambient display.
++ *
++ * @param msg The D-Bus message
++ * @return TRUE on success, FALSE on failure
++ */
++static gboolean mdy_dbus_timed_wakeup_sig(DBusMessage *const msg)
++{
++ gboolean status = FALSE;
++ dbus_bool_t dta = TRUE;
++ (void)msg;
++
++ mce_log(LL_DEBUG, "Received timed wakeup event, updating ambient display");
++ if (mdy_use_low_power_mode && mdy_low_power_mode_supported) {
++ bool ack = dbus_send_ex2(COMPOSITOR_SERVICE,
++ COMPOSITOR_PATH,
++ COMPOSITOR_IFACE,
++ COMPOSITOR_SET_AMBIENT_UPDATES_ENABLED,
++ NULL,
++ COMPOSITOR_STM_DBUS_CALL_TIMEOUT,
++ NULL, 0,
++ NULL,
++ DBUS_TYPE_BOOLEAN, &dta,
++ DBUS_TYPE_INVALID);
++
++ if( !ack )
++ mce_log(LL_CRIT, "Failed to send ambient mode update request");
++ }
++
++ status = TRUE;
++
++ return status;
++}
++
+ /** Array of dbus message handlers */
+ static mce_dbus_handler_t mdy_dbus_handlers[] =
+ {
+@@ -10301,6 +10473,12 @@ static mce_dbus_handler_t mdy_dbus_handlers[] =
+ .type = DBUS_MESSAGE_TYPE_SIGNAL,
+ .callback = mdy_dbus_handle_desktop_started_sig,
+ },
++ {
++ .interface = "com.nokia.time",
++ .name = "wakeup_event",
++ .type = DBUS_MESSAGE_TYPE_SIGNAL,
++ .callback = mdy_dbus_timed_wakeup_sig,
++ },
+ {
+ .interface = COMPOSITOR_IFACE,
+ .name = COMPOSITOR_TOPMOST_WINDOW_PID_CHANGED,
+@@ -10348,6 +10526,14 @@ static mce_dbus_handler_t mdy_dbus_handlers[] =
+ .args =
+ " <arg direction=\"out\" name=\"cabc_mode\" type=\"s\"/>\n"
+ },
++ {
++ .interface = MCE_REQUEST_IF,
++ .name = MCE_DISPLAY_LPM_SET_SUPPORTED,
++ .type = DBUS_MESSAGE_TYPE_METHOD_CALL,
++ .callback = mdy_dbus_handle_lpm_enabled_req,
++ .args =
++ " <arg direction=\"out\" name=\"enabled\" type=\"b\"/>\n"
++ },
+ {
+ .interface = MCE_REQUEST_IF,
+ .name = MCE_DISPLAY_ON_REQ,
+@@ -10829,6 +11015,7 @@ static void mdy_setting_cb(GConfClient *const gcc, const guint id,
+ }
+ else if (id == mdy_use_low_power_mode_setting_id) {
+ mdy_use_low_power_mode = gconf_value_get_bool(gcv);
++ compositor_stm_send_lpm_request(mdy_compositor_ipc);
+
+ if (((display_state_curr == MCE_DISPLAY_LPM_OFF) ||
+ (display_state_curr == MCE_DISPLAY_LPM_ON)) &&
+@@ -11223,7 +11410,8 @@ static void mdy_setting_init(void)
+ MCE_DEFAULT_USE_LOW_POWER_MODE,
+ mdy_setting_cb,
+ &mdy_use_low_power_mode_setting_id);
+-
++
++ compositor_stm_send_lpm_request(mdy_compositor_ipc);
+ /* Blanking inhibit modes */
+ mce_setting_track_int(MCE_SETTING_BLANKING_INHIBIT_MODE,
+ &mdy_blanking_inhibit_mode,
+diff --git a/modules/display.h b/modules/display.h
+index 8075401..8bd4513 100644
+--- a/modules/display.h
++++ b/modules/display.h
+@@ -385,7 +385,7 @@
+
+ /** Display blanking delay from lpm-on state [s] */
+ # define MCE_SETTING_DISPLAY_BLANK_FROM_LPM_ON_TIMEOUT MCE_SETTING_DISPLAY_PATH "/display_blank_from_lpm_on_timeout"
+-# define MCE_DEFAULT_DISPLAY_BLANK_FROM_LPM_ON_TIMEOUT 5
++# define MCE_DEFAULT_DISPLAY_BLANK_FROM_LPM_ON_TIMEOUT 1
+
+ /** Display blanking delay from lpm-off state [s]
+ *
+@@ -394,7 +394,7 @@
+ * will cause transition back to lpm-on state.
+ */
+ # define MCE_SETTING_DISPLAY_BLANK_FROM_LPM_OFF_TIMEOUT MCE_SETTING_DISPLAY_PATH "/display_blank_from_lpm_off_timeout"
+-# define MCE_DEFAULT_DISPLAY_BLANK_FROM_LPM_OFF_TIMEOUT 5
++# define MCE_DEFAULT_DISPLAY_BLANK_FROM_LPM_OFF_TIMEOUT 1
+
+ /** Whether display blanking is forbidden
+ *
+@@ -512,7 +512,7 @@ typedef enum {
+ * to blank the screen after a while.
+ */
+ # define MCE_SETTING_USE_LOW_POWER_MODE MCE_SETTING_DISPLAY_PATH "/use_low_power_mode"
+-# define MCE_DEFAULT_USE_LOW_POWER_MODE false
++# define MCE_DEFAULT_USE_LOW_POWER_MODE true
+
+ /* ------------------------------------------------------------------------- *
+ * Power Management related settings
+diff --git a/modules/filter-brightness-als.c b/modules/filter-brightness-als.c
+index 26ff3e2..54eed91 100644
+--- a/modules/filter-brightness-als.c
++++ b/modules/filter-brightness-als.c
+@@ -810,11 +810,11 @@ fba_inputflt_sampling_output(int lux)
+
+ fba_inputflt_output_lux = lux;
+
+- fba_datapipe_execute_brightness_change();
+-
+ /* Feed filtered sensor data to datapipe */
+ datapipe_exec_full(&light_sensor_filtered_pipe,
+ GINT_TO_POINTER(fba_inputflt_output_lux));
++
++ fba_datapipe_execute_brightness_change();
+ EXIT:
+ return;
+ }
+@@ -1288,9 +1288,12 @@ fba_datapipe_lpm_brightness_filter(gpointer data)
+ if( lut_lpm.profiles < 1 )
+ goto EXIT;
+
++ int max_prof = lut_lpm.profiles - 1;
++
++ int prof = mce_xlat_int(1,100, 0,max_prof, value);
+ /* Note: Input value is ignored and output is
+ * determined only by the als config */
+- value = fba_als_filter_run(&lut_lpm, 0, fba_inputflt_output_lux);
++ value = fba_als_filter_run(&lut_lpm, prof, fba_inputflt_output_lux);
+
+ EXIT:
+ return GINT_TO_POINTER(value);
+@@ -1746,6 +1749,10 @@ fba_status_rethink(void)
+ mce_log(LL_DEBUG, "enabled=%d; autobright=%d; filter_lid=%d -> enable=%d",
+ fba_setting_als_enabled, fba_setting_als_autobrightness, fba_setting_filter_lid_with_als, enable_new);
+
++ /* When the display module is loaded the function datapipe binding is inited, this causes a a brightness update without filtering.
++ * fba_status_rethink is called when the module is loaded. Also execute the brightness filter pipe. Fixing als not filtering on boot. */
++ fba_datapipe_execute_brightness_change();
++
+ enable_old = enable_new;
+
+ if( enable_new ) {
+diff --git a/powerkey.h b/powerkey.h
+index 6d90108..4c342a0 100644
+--- a/powerkey.h
++++ b/powerkey.h
+@@ -63,7 +63,7 @@ typedef enum
+
+ /** How power key "blank" action should behave */
+ # define MCE_SETTING_POWERKEY_BLANKING_MODE MCE_SETTING_POWERKEY_PATH "/blanking_mode"
+-# define MCE_DEFAULT_POWERKEY_BLANKING_MODE 0 // = PWRKEY_BLANK_TO_OFF
++# define MCE_DEFAULT_POWERKEY_BLANKING_MODE 1 // = PWRKEY_BLANK_TO_LPM
+
+ /** How many consequent power key presses trigger proximity override
+ *
+diff --git a/tklock.c b/tklock.c
+index 867deaa..1188cb6 100644
+--- a/tklock.c
++++ b/tklock.c
+@@ -4100,7 +4100,7 @@ static void tklock_uiexception_finish(void)
+ default:
+ /* If the display was not clearly ON when exception started,
+ * turn it OFF after exceptions are over. */
+- mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
++ mce_datapipe_request_display_state(MCE_DISPLAY_LPM_ON);
+ break;
+
+ case MCE_DISPLAY_ON:
diff --git a/community/mce/0005-Ambient-Mode-Wait-for-compositor-when-sending-enable.patch b/community/mce/0005-Ambient-Mode-Wait-for-compositor-when-sending-enable.patch
new file mode 100644
index 0000000000..ee993f30a9
--- /dev/null
+++ b/community/mce/0005-Ambient-Mode-Wait-for-compositor-when-sending-enable.patch
@@ -0,0 +1,55 @@
+From 0e138361813294bbacd8e6bf6bd621303fad40c6 Mon Sep 17 00:00:00 2001
+From: MagneFire <IDaNLContact@gmail.com>
+Date: Sun, 7 Mar 2021 23:03:41 +0100
+Subject: [PATCH] Ambient Mode: Wait for compositor when sending enable/disable
+ request. Low power mode wouldn't activate properly after boot sometimes, this
+ is likely due to the compositor not being available at the time. So wait
+ until we know that the compositor is available (ready to receive DBus
+ messages).
+
+---
+ modules/display.c | 16 ++++++++++------
+ 1 file changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/modules/display.c b/modules/display.c
+index 42ca0e5..85d0df3 100644
+--- a/modules/display.c
++++ b/modules/display.c
+@@ -7128,6 +7128,9 @@ compositor_stm_enter_state(compositor_stm_t *self)
+ compositor_stm_cancel_killer(self);
+ compositor_stm_cancel_panic(self);
+
++ /* Compositor is ready to receive D-Bus messages, send request to enable/disable lpm. */
++ compositor_stm_send_lpm_request(self);
++
+ /* Wake display state machine */
+ mdy_stm_schedule_rethink();
+ break;
+@@ -9915,11 +9918,13 @@ EXIT:
+ mce_log(LL_DEVEL, "The compositor %s support for ambient mode.",
+ low_power_mode_supported ? "has" : "hasn't");
+
+- // We have a variable that we should use to set lpm mode availability based on ack.
+- mdy_low_power_mode_supported = low_power_mode_supported;
++ if (!mdy_low_power_mode_supported != !low_power_mode_supported) {
++ // We have a variable that we should use to set lpm mode availability based on ack.
++ mdy_low_power_mode_supported = low_power_mode_supported;
+
+- // Enable/disable lpm mode based on support from the compositor.
+- compositor_stm_send_lpm_request(mdy_compositor_ipc);
++ // Enable/disable lpm mode based on support from the compositor.
++ compositor_stm_send_lpm_request(mdy_compositor_ipc);
++ }
+
+ return status;
+ }
+@@ -11410,8 +11415,7 @@ static void mdy_setting_init(void)
+ MCE_DEFAULT_USE_LOW_POWER_MODE,
+ mdy_setting_cb,
+ &mdy_use_low_power_mode_setting_id);
+-
+- compositor_stm_send_lpm_request(mdy_compositor_ipc);
++
+ /* Blanking inhibit modes */
+ mce_setting_track_int(MCE_SETTING_BLANKING_INHIBIT_MODE,
+ &mdy_blanking_inhibit_mode,
diff --git a/community/mce/0006-Ambient-Mode-Exit-ambient-mode-when-touch-is-detecte.patch b/community/mce/0006-Ambient-Mode-Exit-ambient-mode-when-touch-is-detecte.patch
new file mode 100644
index 0000000000..f20e661ce8
--- /dev/null
+++ b/community/mce/0006-Ambient-Mode-Exit-ambient-mode-when-touch-is-detecte.patch
@@ -0,0 +1,61 @@
+From 1ee2bd9009608370d02ab35510109e88efcf003d Mon Sep 17 00:00:00 2001
+From: MagneFire <IDaNLContact@gmail.com>
+Date: Sun, 7 Mar 2021 23:07:09 +0100
+Subject: [PATCH] Ambient Mode: Exit ambient mode when touch is detected.
+
+---
+ modules/display.c | 27 +++++++++++++++++++++++++++
+ 1 file changed, 27 insertions(+)
+
+diff --git a/modules/display.c b/modules/display.c
+index 85d0df3..3c50973 100644
+--- a/modules/display.c
++++ b/modules/display.c
+@@ -413,6 +413,7 @@ static bool mdy_shutdown_in_progress(void);
+ * ------------------------------------------------------------------------- */
+
+ static void mdy_datapipe_ambient_light_level_cb(gconstpointer data);;
++static void mdy_datapipe_touch_detected_cb(gconstpointer data);
+ static void mdy_datapipe_packagekit_locked_cb(gconstpointer data);;
+ static void mdy_datapipe_system_state_cb(gconstpointer data);
+ static void mdy_datapipe_submode_cb(gconstpointer data);
+@@ -1767,6 +1768,28 @@ EXIT:
+ return;
+ }
+
++/**
++ * Handle touchscreen detections.
++ *
++ * @param data The touch pressed/unpressed in a pointer
++ */
++static void mdy_datapipe_touch_detected_cb(gconstpointer data)
++{
++ gboolean touch_detected = GPOINTER_TO_INT(data);
++
++ /* Log by default as it might help analyzing lpm problems */
++ mce_log(LL_DEBUG, "touch_detected = %d", touch_detected);
++
++ switch( display_state_curr ) {
++ case MCE_DISPLAY_LPM_ON:
++ /* Screen is in LPM mode, exit LPM mode when touch is detected. */
++ mce_datapipe_request_display_state(MCE_DISPLAY_ON);
++ break;
++ default:
++ break;
++ }
++}
++
+ /** Keypad slide input state; assume closed */
+ static cover_state_t keyboard_slide_input_state = COVER_CLOSED;
+
+@@ -2276,6 +2299,10 @@ static datapipe_handler_t mdy_datapipe_handlers[] =
+ .datapipe = &light_sensor_filtered_pipe,
+ .output_cb = mdy_datapipe_ambient_light_level_cb,
+ },
++ {
++ .datapipe = &touch_detected_pipe,
++ .output_cb = mdy_datapipe_touch_detected_cb,
++ },
+ {
+ .datapipe = &packagekit_locked_pipe,
+ .output_cb = mdy_datapipe_packagekit_locked_cb,
diff --git a/community/mce/0007-powerkey-Also-suspend-on-palm-reports.patch b/community/mce/0007-powerkey-Also-suspend-on-palm-reports.patch
new file mode 100644
index 0000000000..2aca7735f0
--- /dev/null
+++ b/community/mce/0007-powerkey-Also-suspend-on-palm-reports.patch
@@ -0,0 +1,156 @@
+From fc86713d797c0defb781205b070fd17b438fb7f2 Mon Sep 17 00:00:00 2001
+From: MagneFire <dgriet@gmail.com>
+Date: Sun, 26 Dec 2021 19:40:13 +0100
+Subject: [PATCH] powerkey: Also suspend on palm reports.
+
+---
+ event-input.c | 5 +++
+ powerkey.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 107 insertions(+)
+
+diff --git a/event-input.c b/event-input.c
+index de0d19c..10c4894 100644
+--- a/event-input.c
++++ b/event-input.c
+@@ -2181,6 +2181,11 @@ evin_iomon_touchscreen_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
+ /* Only send pressure events */
+ datapipe_exec_full(&touchscreen_event_pipe, &ev);
+ }
++ else if( ev->type == EV_KEY && ev->code == KEY_SLEEP ) {
++ /* Report palm events. */
++ datapipe_exec_full(&touchscreen_event_pipe, &ev);
++ goto EXIT;
++ }
+
+ EXIT:
+ return flush;
+diff --git a/powerkey.c b/powerkey.c
+index e06e231..98297bf 100644
+--- a/powerkey.c
++++ b/powerkey.c
+@@ -596,6 +596,7 @@ static void pwrkey_setting_quit (void);
+ * ------------------------------------------------------------------------- */
+
+ static void pwrkey_datapipe_keypress_event_cb(gconstpointer const data);
++static void pwrkey_datapipe_touchscreen_cb(gconstpointer data);
+ static void pwrkey_datapipe_ngfd_service_state_cb(gconstpointer data);
+ static void pwrkey_datapipe_system_state_cb(gconstpointer data);
+ static void pwrkey_datapipe_devicelock_state_cb(gconstpointer data);
+@@ -3159,6 +3160,103 @@ EXIT:
+ return;
+ }
+
++/**
++ * Datapipe trigger for the [sleep] key
++ *
++ * @param data A pointer to the input_event struct
++ */
++static void
++pwrkey_datapipe_touchscreen_cb(gconstpointer const data)
++{
++ /* Faulty/aged physical power key buttons can generate
++ * bursts of press and release events that are then
++ * interpreted as double presses. To avoid this we
++ * ignore power key presses that occur so soon after
++ * previous release that they are unlikely to be
++ * caused by human activity. */
++
++ /* Minimum delay between power key release and press. */
++ static const int64_t press_delay = 50;
++
++ /* Time limit for accepting the next power key press */
++ static int64_t press_limit = 0;
++
++ const struct input_event * const *evp;
++ const struct input_event *ev;
++
++ if( !(evp = data) )
++ goto EXIT;
++
++ if( !(ev = *evp) )
++ goto EXIT;
++
++ switch( ev->type ) {
++ case EV_KEY:
++ switch( ev->code ) {
++ case KEY_SLEEP:
++ if( ev->value == 1 ) {
++ if( mce_lib_get_boot_tick() < press_limit ) {
++ /* Too soon after the previous powerkey
++ * release -> assume faulty hw sending
++ * bursts of presses */
++ mce_log(LL_CRUCIAL, "sleep press event ignored");
++ }
++ else {
++ mce_log(LL_CRUCIAL, "sleep press event");
++ /* Detect repeated power key pressing while
++ * proximity sensor is covered; assume it means
++ * the sensor is stuck and user wants to be able
++ * to turn on the display regardless of the sensor
++ * state */
++ pwrkey_ps_override_evaluate();
++
++ /* Power key pressed */
++ pwrkey_stm_powerkey_pressed();
++
++ /* Some devices report both power key press and release
++ * already when the physical button is pressed down.
++ * Other devices wait for physical release before
++ * reporting key release. And in some devices it depends
++ * on whether the device is suspended or not.
++ *
++ * To normalize behavior in default configuration (i.e.
++ * begin display power up already on power key press
++ * without waiting for user to lift finger off the button):
++ * Synthetize key release, if no actions are bound to long
++ * power key press from display off state. */
++ if( pwrkey_stm_display_state == MCE_DISPLAY_OFF ) {
++ if( !pwrkey_actions_from_display_off.mask_long ) {
++ mce_log(LL_DEBUG, "sleep release event simulated");
++ pwrkey_stm_powerkey_released();
++ }
++ }
++ }
++ }
++ else if( ev->value == 0 ) {
++ mce_log(LL_CRUCIAL, "sleep release event");
++ /* Power key released */
++ pwrkey_stm_powerkey_released();
++
++ /* Adjust time limit for accepting the next power
++ * key press */
++ press_limit = mce_lib_get_boot_tick() + press_delay;
++ }
++
++ pwrkey_stm_rethink_wakelock();
++ break;
++
++ default:
++ break;
++ }
++ break;
++ default:
++ break;
++ }
++
++EXIT:
++ return;
++}
++
+ /**
+ * Datapipe trigger for the [power] key
+ *
+@@ -3381,6 +3479,10 @@ static datapipe_handler_t pwrkey_datapipe_handlers[] =
+ .datapipe = &keypress_event_pipe,
+ .input_cb = pwrkey_datapipe_keypress_event_cb,
+ },
++ {
++ .datapipe = &touchscreen_event_pipe,
++ .input_cb = pwrkey_datapipe_touchscreen_cb,
++ },
+ {
+ .datapipe = &ngfd_event_request_pipe,
+ .input_cb = pwrkey_datapipe_ngfd_event_request_cb,
+--
+2.34.1
+
diff --git a/community/mce/0008-fix-32bit-build.patch b/community/mce/0008-fix-32bit-build.patch
new file mode 100644
index 0000000000..5ae8b7c725
--- /dev/null
+++ b/community/mce/0008-fix-32bit-build.patch
@@ -0,0 +1,14 @@
+diff --git a/multitouch.c b/multitouch.c
+index 95dfe22..94f41fe 100644
+--- a/multitouch.c
++++ b/multitouch.c
+@@ -428,7 +428,8 @@ mt_state_handle_event_b(mt_state_t *self, const struct input_event *ev)
+ void
+ mt_state_handle_event(mt_state_t *self, const struct input_event *ev)
+ {
+- self->mts_event_time = ev->time;
++ self->mts_event_time.tv_sec = ev->input_event_sec;
++ self->mts_event_time.tv_usec = ev->input_event_usec;
+
+ self->mts_event_handler_cb(self, ev);
+
diff --git a/community/mce/APKBUILD b/community/mce/APKBUILD
index ff76cf98e3..c24fba7cd2 100644
--- a/community/mce/APKBUILD
+++ b/community/mce/APKBUILD
@@ -1,11 +1,11 @@
# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=mce
-pkgver=0_git20210902
-pkgrel=1
-_commit="d9c254b4bfb4e92de91e911ab2f514562cd1e4ae"
+pkgver=1.111.0
+pkgrel=0
+_commit_dbus_gmain="d42176ae4763e5288ef37ea314fe58387faf2005"
pkgdesc="mce with support for tap-to-wake and tilt-to-wake"
-url="https://github.com/AsteroidOS/mce"
+url="https://github.com/sailfishos/mce"
arch="all"
license="LGPL-2.1-only"
makedepends="
@@ -14,20 +14,38 @@ makedepends="
dbus-glib-dev
doxygen
elogind-dev
+ eudev-dev
glib-dev
graphviz
libdsme-dev
libiphb-dev
libngf-dev
+ mce-dev
+ usb-moded-dev
"
subpackages="$pkgname-doc $pkgname-openrc"
-source="https://github.com/AsteroidOS/mce/archive/$_commit/mce-$_commit.tar.gz
+source="https://github.com/sailfishos/mce/archive/$pkgver/mce-$pkgver.tar.gz
+ https://github.com/sailfishos-mirror/dbus-glib/archive/$_commit_dbus_gmain/dbus-glib-$_commit_dbus_gmain.tar.gz
+ 0001-Double-tap-emulation-Adapts-the-state-machine-to-a-s.patch
+ 0001-Keep-screen-on-by-default-on-emulator.patch
+ 0002-tilt-to-wake-Wake-screen-when-wrist-gesture-arrives.patch
+ 0003-inactivity-Allow-activities-in-lockscreen-mode.-aste.patch
+ 0004-Ambient-mode-Adapt-low-power-mode-to-allow-for-actua.patch
+ 0005-Ambient-Mode-Wait-for-compositor-when-sending-enable.patch
+ 0006-Ambient-Mode-Exit-ambient-mode-when-touch-is-detecte.patch
+ 0007-powerkey-Also-suspend-on-palm-reports.patch
+ 0008-fix-32bit-build.patch
mce.initd
- mce.confd
- fix-build.patch
+ mce.confd
"
options="!check" # Build failures
-builddir="$srcdir/$pkgname-$_commit"
+
+prepare() {
+ default_prepare
+
+ rmdir dbus-gmain
+ mv "$srcdir/dbus-glib-$_commit_dbus_gmain" dbus-gmain
+}
build() {
make
@@ -52,8 +70,17 @@ package() {
}
sha512sums="
-4529e4d71767313b141c52a3fc297f80051fb0bbf83d4a9517de3c4ef06db8cedfbca0c8cf77ce39405f8de96b74afcb8cd01a60a40a5e3d6520ceb2e80ba90c mce-d9c254b4bfb4e92de91e911ab2f514562cd1e4ae.tar.gz
+8b9295bf4fdaf5579d0368e5edda559be343c2adff92e114c5174eaf8493fd4588ee381be0db0ea1cc6f2297353220e25f5fcbd1b62412dc383969be76841b58 mce-1.111.0.tar.gz
+665cd6395ee0ea14086ba30188c62a72697b3f63484681e18fc7f54109c9aca162f2e33aa2fa4d45287c6c0b590e81ca310c143dac0232cd5887692cdaf51256 dbus-glib-d42176ae4763e5288ef37ea314fe58387faf2005.tar.gz
+d5855bb7cf72920a57533ff0e6d567b1fc52104e04c3e4a15c01d72b83cf7011daf66c37b86ae5e20ff859c13606a2acd81f7f34ff29f8086c34979ca641491b 0001-Double-tap-emulation-Adapts-the-state-machine-to-a-s.patch
+4cecf1b48266c4ec1d05412514eca1d63f9c442a39eaee25e654c1878f6c506995458f43d4f70ed4179198577ab2cadd4ab2d816e185e6f4d187aa449dbd0887 0001-Keep-screen-on-by-default-on-emulator.patch
+b3a0c202679077ad40959fc447d5d7dab21dd7acb852084ed88ed27fb86f506c053c23ac56ecbc0cc174171336fa08de9e3865458c0dec51501f73a4364da435 0002-tilt-to-wake-Wake-screen-when-wrist-gesture-arrives.patch
+9777138f514591d34524ccde1b0646c0d8d8f980ac3f217fed4739e2718fef6c820106fa58a12999ff567eba49dfbff03f0a7b952d65d8763eb263f52086a6b0 0003-inactivity-Allow-activities-in-lockscreen-mode.-aste.patch
+4d1f150406e489c3dcc3481dc42d2c04882423dda94e5c43ab46213e0aa77a20f10c44044665a36c49134590529b438b37fda38a07d85872d1068858e2935d56 0004-Ambient-mode-Adapt-low-power-mode-to-allow-for-actua.patch
+23910efee13c22c3718bacd76d87f6b485d2de2eb5b6678022e439d6397e07c639eca17286a8bf1e716fbcd57b7e25b07352b15b469a22f3e9cf97fbc4e4975e 0005-Ambient-Mode-Wait-for-compositor-when-sending-enable.patch
+777d4e4d2229f16685208e644bfd9a5f121a73e7645c37f7366d3887a8a0228ed7a0d680d5aab875457f7fa65b26710e21690f5b990bc1749b5b2faf7c847902 0006-Ambient-Mode-Exit-ambient-mode-when-touch-is-detecte.patch
+039f03a014e9e3ee7193df3b3e1d046740ee62525608e8a63a241b365d2c42ba191b78c7eb9b43ff8de460e03f6ef6ee0aad5e1a3fcb7e9d5d61f34a660ebd4d 0007-powerkey-Also-suspend-on-palm-reports.patch
+ad76be70336bec361bfcb2cd664a627a26c1576d7acd98666f986d318ff1ac96e739696577381b99f5ff13febd62b497f9e5e7ee80c7ea1de02409c65d8a7a36 0008-fix-32bit-build.patch
b07d40a66fd9206b1e34164a0229b05456cbe268b4004045c8fda34742c40528c56c5f1cf81cbc4ba3662c20fcbcff4a8f8e00fc8fbb2ff7bb92e7ab125dd55b mce.initd
b841282b96110ec59a7aa539db0737327b09549d55c78dc4b2c3b28b4a6ad1facf015b3175cb6d3a38f13e47aa6314ef3dc1514a4e60dd653a97409ec54ba706 mce.confd
-758a84642f866eea2b7e8e51ea054b472f1ab2c511b1d9ff9061bf3b4eb29fa2455fc6ce3d9896d8c6d1b160e911f49952b4ef43a090888b63b165ee9eb15504 fix-build.patch
"
diff --git a/community/mce/fix-build.patch b/community/mce/fix-build.patch
deleted file mode 100644
index 4df308e773..0000000000
--- a/community/mce/fix-build.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-diff --git a/event-input.c b/event-input.c
-index 9d9d4c7..16a3e09 100644
---- a/event-input.c
-+++ b/event-input.c
-@@ -1908,7 +1908,7 @@ evin_iomon_generate_activity(struct input_event *ev, bool cooked, bool raw)
- if( !ev )
- goto EXIT;
-
-- time_t t = ev->time.tv_sec;
-+ time_t t = ev->input_event_sec;
-
- /* Actual, never synthetized user activity */
- if( raw ) {
-diff --git a/libwakelock.h b/libwakelock.h
-index d87f4cd..ec4be44 100644
---- a/libwakelock.h
-+++ b/libwakelock.h
-@@ -7,6 +7,8 @@
- #ifndef LIBWAKELOCK_H_
- # define LIBWAKELOCK_H_
-
-+#include "musl-compatibility.h"
-+
- # ifdef __cplusplus
- extern "C" {
- # elif 0
-diff --git a/mce-hybris.c b/mce-hybris.c
-index 10f9117..3aafb91 100644
---- a/mce-hybris.c
-+++ b/mce-hybris.c
-@@ -328,7 +328,11 @@ static void *mce_hybris_lookup_function(const char *name)
- else if( access(path, F_OK) == -1 && errno == ENOENT ) {
- mce_log(LL_NOTICE, "%s: not installed", path);
- }
-+#if defined(RTLD_DEEPBIND)
- else if( !(base = dlopen(path, RTLD_NOW|RTLD_LOCAL|RTLD_DEEPBIND)) ) {
-+#else
-+ else if( !(base = dlopen(path, RTLD_NOW|RTLD_LOCAL)) ) {
-+#endif
- mce_log(LL_WARN, "%s: failed to load: %s", path, dlerror());
- }
- else {
-diff --git a/mce.h b/mce.h
-index b113d06..1a98555 100644
---- a/mce.h
-+++ b/mce.h
-@@ -26,6 +26,7 @@
- #ifndef _MCE_H_
- #define _MCE_H_
-
-+#include "musl-compatibility.h"
- #include "datapipe.h"
-
- /** Indicate enabled (sub)mode */
-diff --git a/multitouch.c b/multitouch.c
-index 0e6fe41..93aa15d 100644
---- a/multitouch.c
-+++ b/multitouch.c
-@@ -431,7 +431,8 @@ mt_state_handle_event_b(mt_state_t *self, const struct input_event *ev)
- void
- mt_state_handle_event(mt_state_t *self, const struct input_event *ev)
- {
-- self->mts_event_time = ev->time;
-+ self->mts_event_time.tv_sec = ev->input_event_sec;
-+ self->mts_event_time.tv_usec = ev->input_event_usec;
-
- self->mts_event_handler_cb(self, ev);
-
-diff --git a/musl-compatibility.h b/musl-compatibility.h
-new file mode 100644
-index 0000000..56cff68
---- /dev/null
-+++ b/musl-compatibility.h
-@@ -0,0 +1,10 @@
-+/* Used to retry syscalls that can return EINTR. Taken from bionic unistd.h */
-+#ifndef TEMP_FAILURE_RETRY
-+#define TEMP_FAILURE_RETRY(exp) ({ \
-+ __typeof__(exp) _rc; \
-+ do { \
-+ _rc = (exp); \
-+ } while (_rc == -1 && errno == EINTR); \
-+ _rc; })
-+#endif
-+
-diff --git a/tools/evdev_trace.c b/tools/evdev_trace.c
-index 8cac5b8..b4f944b 100644
---- a/tools/evdev_trace.c
-+++ b/tools/evdev_trace.c
-@@ -88,8 +88,8 @@ process_events(int fd, const char *title)
- if( emit_event_time )
- {
- snprintf(toe, sizeof toe, "%ld.%03ld - ",
-- (long)e->time.tv_sec,
-- (long)e->time.tv_usec / 1000);
-+ (long)e->input_event_sec,
-+ (long)e->input_event_usec / 1000);
- }
-
- printf("%s: %s%s0x%02x/%s - 0x%03x/%s - %d\n",