Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[inactivity] Skip activity renew instead of switching to inactivity
Datapipe filter callback functions can only modify the value that datapipe
ends up having and can't be used to skip calling of notification functions.
In case of inactivity processing this means that when filter function does
not allow extending of "user activity" period, it actually immediately
terminates the period.

Instead of having a single inactivity datapipe with filter callback, use two
separate "event" and "state" datapipes chained so that events can be
propagated from event to state datapipe or ignored depending on whether the
activity change is allowed or not.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jun 2, 2017
1 parent 2669211 commit 5c3916f
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 112 deletions.
12 changes: 9 additions & 3 deletions datapipe.c
Expand Up @@ -39,7 +39,10 @@ datapipe_struct led_brightness_pipe;
datapipe_struct lpm_brightness_pipe;

/** State of device; read only */
datapipe_struct device_inactive_pipe;
datapipe_struct device_inactive_state_pipe;

/** Device inactivity events; read only */
datapipe_struct device_inactive_event_pipe;

/** LED pattern to activate; read only */
datapipe_struct led_pattern_activate_pipe;
Expand Down Expand Up @@ -769,7 +772,9 @@ void mce_datapipe_init(void)
sizeof (struct input_event), NULL);
setup_datapipe(&touchscreen_pipe, READ_ONLY, FREE_CACHE,
sizeof (struct input_event), NULL);
setup_datapipe(&device_inactive_pipe, READ_WRITE, DONT_FREE_CACHE,
setup_datapipe(&device_inactive_state_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(TRUE));
setup_datapipe(&device_inactive_event_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(TRUE));
setup_datapipe(&lockkey_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(0));
Expand Down Expand Up @@ -890,7 +895,8 @@ void mce_datapipe_quit(void)
free_datapipe(&keyboard_slide_pipe);
free_datapipe(&keyboard_available_pipe);
free_datapipe(&lockkey_pipe);
free_datapipe(&device_inactive_pipe);
free_datapipe(&device_inactive_state_pipe);
free_datapipe(&device_inactive_event_pipe);
free_datapipe(&touchscreen_pipe);
free_datapipe(&keypress_pipe);
free_datapipe(&key_backlight_pipe);
Expand Down
3 changes: 2 additions & 1 deletion datapipe.h
Expand Up @@ -90,7 +90,8 @@ typedef enum {
/* Available datapipes */
extern datapipe_struct led_brightness_pipe;
extern datapipe_struct lpm_brightness_pipe;
extern datapipe_struct device_inactive_pipe;
extern datapipe_struct device_inactive_state_pipe;
extern datapipe_struct device_inactive_event_pipe;
extern datapipe_struct led_pattern_activate_pipe;
extern datapipe_struct led_pattern_deactivate_pipe;
extern datapipe_struct device_resumed_pipe;
Expand Down
2 changes: 1 addition & 1 deletion event-input.c
Expand Up @@ -1925,7 +1925,7 @@ evin_iomon_generate_activity(struct input_event *ev, bool cooked, bool raw)

if( t_cooked != t || (submode & MCE_EVEATER_SUBMODE) ) {
t_cooked = t;
execute_datapipe(&device_inactive_pipe,
execute_datapipe(&device_inactive_event_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
}
Expand Down
30 changes: 15 additions & 15 deletions event-switches.c
Expand Up @@ -92,8 +92,8 @@ static gboolean generic_activity_iomon_cb(mce_io_mon_t *iomon, gpointer data, gs
(void)bytes_read;

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);

return FALSE;
}
Expand All @@ -120,8 +120,8 @@ static gboolean camera_launch_button_iomon_cb(mce_io_mon_t *iomon, gpointer data
}

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);

/* Update camera button state */
(void)execute_datapipe(&camera_button_pipe,
Expand Down Expand Up @@ -177,9 +177,9 @@ static gboolean kbd_slide_iomon_cb(mce_io_mon_t *iomon, gpointer data, gsize byt
slide_state = COVER_OPEN;

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
} else {
slide_state = COVER_CLOSED;
}
Expand Down Expand Up @@ -209,9 +209,9 @@ static gboolean lid_cover_iomon_cb(mce_io_mon_t *iomon, gpointer data, gsize byt
lid_cover_state = COVER_OPEN;

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
} else {
lid_cover_state = COVER_CLOSED;
}
Expand Down Expand Up @@ -273,8 +273,8 @@ static gboolean usb_cable_iomon_cb(mce_io_mon_t *iomon, gpointer data, gsize byt
}

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);

(void)execute_datapipe(&usb_cable_pipe,
GINT_TO_POINTER(cable_state),
Expand All @@ -301,9 +301,9 @@ static gboolean lens_cover_iomon_cb(mce_io_mon_t *iomon, gpointer data, gsize by
lens_cover_state = COVER_OPEN;

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
} else {
lens_cover_state = COVER_CLOSED;
}
Expand Down
16 changes: 8 additions & 8 deletions modules/battery-bme.c
Expand Up @@ -331,8 +331,8 @@ static gboolean charger_charging_failed_dbus_cb(DBusMessage *const msg)
execute_datapipe_output_triggers(&led_pattern_deactivate_pipe, MCE_LED_PATTERN_BATTERY_CHARGING, USE_INDATA);

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);

status = TRUE;

Expand All @@ -357,9 +357,9 @@ static gboolean charger_connected_dbus_cb(DBusMessage *const msg)

if (cached_charger_connected != 1) {
/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
cached_charger_connected = 1;
}

Expand Down Expand Up @@ -397,9 +397,9 @@ static gboolean charger_disconnected_dbus_cb(DBusMessage *const msg)

if (cached_charger_connected != 0) {
/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
cached_charger_connected = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/battery-statefs.c
Expand Up @@ -744,8 +744,8 @@ mcebat_update_cb(gpointer user_data)
}

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
}

if( mcebat.status != prev.status ) {
Expand Down
4 changes: 2 additions & 2 deletions modules/battery-upower.c
Expand Up @@ -712,8 +712,8 @@ mcebat_update_cb(gpointer user_data)
}

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
}

if( mcebat.status != prev.status ) {
Expand Down
4 changes: 2 additions & 2 deletions modules/camera.c
Expand Up @@ -123,8 +123,8 @@ static gboolean camera_popout_state_iomon_input_cb(mce_io_mon_t *iomon, gpointer
(void)bytes_read;

/* Generate activity */
(void)execute_datapipe(&device_inactive_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);
execute_datapipe(&device_inactive_event_pipe, GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);

if (popout_unlock == FALSE)
goto EXIT;
Expand Down
6 changes: 3 additions & 3 deletions modules/display.c
Expand Up @@ -1816,7 +1816,7 @@ static void mdy_datapipe_call_state_trigger_cb(gconstpointer data)
/** Cached inactivity state */
static gboolean device_inactive = FALSE;

/** Handle device_inactive_pipe notifications
/** Handle device_inactive_state_pipe notifications
*
* @param data The inactivity stored in a pointer;
* TRUE if the device is inactive,
Expand Down Expand Up @@ -1979,7 +1979,7 @@ static datapipe_handler_t mdy_datapipe_handlers[] =
.output_cb = mdy_datapipe_submode_cb,
},
{
.datapipe = &device_inactive_pipe,
.datapipe = &device_inactive_state_pipe,
.output_cb = mdy_datapipe_device_inactive_cb,
},
{
Expand Down Expand Up @@ -6654,7 +6654,7 @@ static void mdy_orientation_generate_activity(void)
}

mce_log(LL_DEBUG, "orientation change; generate activity");
execute_datapipe(&device_inactive_pipe,
execute_datapipe(&device_inactive_event_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_OUTDATA);

Expand Down

0 comments on commit 5c3916f

Please sign in to comment.