Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[orientation] Add options for tweaking orientation sensor usage. Fixe…
…s MER#1331

Some users would prefer to stop orientation changes from keeping
the display on. While it is possible to make this happen by disabling
orientation sensor usage, this also stops flipover gestures from
silencing calls/alarms.

Add separate settings for "orientation change is activity" and
"flipover gesture detection". If the already existing orientation
sensor master toggle is set to disabled, the feature specific
settings are ignored.

By default all three settings are enabled, and can be modified via
mcetool options:
  --set-orientation-change-is-activity=<enabled|disabled>
  --set-flipover-gesture-detection=<enabled|disabled>
  --set-orientation-sensor-mode=<enabled|disabled>

The values of the settings persists over mce / device restarts.

Also do light refactoring of sensor-gestures plugin.
  • Loading branch information
spiiroin committed Sep 18, 2015
1 parent 888b602 commit ef1ba81
Show file tree
Hide file tree
Showing 6 changed files with 370 additions and 78 deletions.
4 changes: 4 additions & 0 deletions .depend
Expand Up @@ -793,18 +793,22 @@ modules/sensor-gestures.o:\
builtin-gconf.h\
datapipe.h\
mce-dbus.h\
mce-gconf.h\
mce-log.h\
mce-sensorfw.h\
mce.h\
modules/display.h\

modules/sensor-gestures.pic.o:\
modules/sensor-gestures.c\
builtin-gconf.h\
datapipe.h\
mce-dbus.h\
mce-gconf.h\
mce-log.h\
mce-sensorfw.h\
mce.h\
modules/display.h\

modules/usbmode.o:\
modules/usbmode.c\
Expand Down
10 changes: 10 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1191,6 +1191,16 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = G_STRINGIFY(DEFAULT_ORIENTATION_SENSOR_ENABLED),
},
{
.key = MCE_GCONF_FLIPOVER_GESTURE_ENABLED,
.type = "b",
.def = G_STRINGIFY(DEFAULT_FLIPOVER_GESTURE_ENABLED),
},
{
.key = MCE_GCONF_ORIENTATION_CHANGE_IS_ACTIVITY,
.type = "b",
.def = G_STRINGIFY(DEFAULT_ORIENTATION_CHANGE_IS_ACTIVITY),
},
{
.key = MCE_GCONF_DISPLAY_BLANKING_PAUSE_MODE,
.type = "i",
Expand Down
79 changes: 59 additions & 20 deletions modules/display.c
Expand Up @@ -1666,7 +1666,7 @@ static void mdy_datapipe_orientation_state_cb(gconstpointer data)
mce_log(LL_DEBUG, "orientation_state = %s",
orientation_state_repr(orientation_state));

/* No activity from sensor power up/down */
/* Ignore sensor power up/down */
if( prev == MCE_ORIENTATION_UNDEFINED ||
orientation_state == MCE_ORIENTATION_UNDEFINED )
goto EXIT;
Expand Down Expand Up @@ -2157,6 +2157,18 @@ static gboolean mdy_orientation_sensor_enabled = DEFAULT_ORIENTATION_SENSOR_ENAB
/** GConf change notification id for mdy_orientation_sensor_enabled */
static guint mdy_orientation_sensor_enabled_gconf_cb_id = 0;

/** Flipover gesture detection enabled */
static gboolean mdy_flipover_gesture_enabled = DEFAULT_FLIPOVER_GESTURE_ENABLED;

/** GConf change notification id for mdy_flipover_gesture_enabled */
static guint mdy_flipover_gesture_enabled_gconf_cb_id = 0;

/** Orientation change generates activity enabled */
static gboolean mdy_orientation_change_is_activity = DEFAULT_ORIENTATION_CHANGE_IS_ACTIVITY;

/** GConf change notification id for mdy_orientation_change_is_activity */
static guint mdy_orientation_change_is_activity_gconf_cb_id = 0;

/** Set display brightness via sysfs write */
static void mdy_brightness_set_level_default(int number)
{
Expand Down Expand Up @@ -5686,25 +5698,27 @@ static void mdy_orientation_changed_cb(int state)
*/
static void mdy_orientation_generate_activity(void)
{
/* Generate activity if the display is on/dim */
/* The feature must be enabled */
if( !mdy_orientation_change_is_activity )
goto EXIT;

/* Display must be on/dimmed */
switch( display_state ) {
case MCE_DISPLAY_ON:
case MCE_DISPLAY_DIM:
mce_log(LL_DEBUG, "orientation change; generate activity");
execute_datapipe(&device_inactive_pipe,
GINT_TO_POINTER(FALSE),
USE_INDATA, CACHE_INDATA);
break;

default:
case MCE_DISPLAY_UNDEF:
case MCE_DISPLAY_OFF:
case MCE_DISPLAY_LPM_OFF:
case MCE_DISPLAY_LPM_ON:
case MCE_DISPLAY_POWER_UP:
case MCE_DISPLAY_POWER_DOWN:
break;
goto EXIT;
}

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

EXIT:
return;
}

/** Check if orientation sensor should be enabled
Expand All @@ -5713,7 +5727,7 @@ static bool mdy_orientation_sensor_wanted(void)
{
bool wanted = false;

/* Skip disabled in settings */
/* Skip if master toggle is disabled */
if( !mdy_orientation_sensor_enabled )
goto EXIT;

Expand All @@ -5728,17 +5742,16 @@ static bool mdy_orientation_sensor_wanted(void)
case MCE_DISPLAY_ON:
case MCE_DISPLAY_LPM_ON:
case MCE_DISPLAY_POWER_UP:
wanted = true;
break;

default:
case MCE_DISPLAY_UNDEF:
case MCE_DISPLAY_OFF:
case MCE_DISPLAY_LPM_OFF:
case MCE_DISPLAY_POWER_DOWN:
break;
goto EXIT;
}

/* But only if orientation sensor features are enabled */
wanted = (mdy_flipover_gesture_enabled ||
mdy_orientation_change_is_activity);

EXIT:
return wanted;
}
Expand Down Expand Up @@ -8571,6 +8584,14 @@ static void mdy_gconf_cb(GConfClient *const gcc, const guint id,
mdy_orientation_sensor_enabled = gconf_value_get_bool(gcv);
mdy_orientation_sensor_rethink();
}
else if (id == mdy_flipover_gesture_enabled_gconf_cb_id) {
mdy_flipover_gesture_enabled = gconf_value_get_bool(gcv);
mdy_orientation_sensor_rethink();
}
else if (id == mdy_orientation_change_is_activity_gconf_cb_id) {
mdy_orientation_change_is_activity = gconf_value_get_bool(gcv);
mdy_orientation_sensor_rethink();
}
else {
mce_log(LL_WARN, "Spurious GConf value received; confused!");
}
Expand Down Expand Up @@ -8909,6 +8930,18 @@ static void mdy_gconf_init(void)
mdy_gconf_cb,
&mdy_orientation_sensor_enabled_gconf_cb_id);

mce_gconf_track_bool(MCE_GCONF_FLIPOVER_GESTURE_ENABLED,
&mdy_flipover_gesture_enabled,
DEFAULT_FLIPOVER_GESTURE_ENABLED,
mdy_gconf_cb,
&mdy_flipover_gesture_enabled_gconf_cb_id);

mce_gconf_track_bool(MCE_GCONF_ORIENTATION_CHANGE_IS_ACTIVITY,
&mdy_orientation_change_is_activity,
DEFAULT_ORIENTATION_CHANGE_IS_ACTIVITY,
mdy_gconf_cb,
&mdy_orientation_change_is_activity_gconf_cb_id);

/* Blanking pause mode */
mce_gconf_track_int(MCE_GCONF_DISPLAY_BLANKING_PAUSE_MODE,
&mdy_blanking_pause_mode,
Expand Down Expand Up @@ -9002,6 +9035,12 @@ static void mdy_gconf_quit(void)
mce_gconf_notifier_remove(mdy_orientation_sensor_enabled_gconf_cb_id),
mdy_orientation_sensor_enabled_gconf_cb_id = 0;

mce_gconf_notifier_remove(mdy_flipover_gesture_enabled_gconf_cb_id),
mdy_flipover_gesture_enabled_gconf_cb_id = 0;

mce_gconf_notifier_remove(mdy_orientation_change_is_activity_gconf_cb_id),
mdy_orientation_change_is_activity_gconf_cb_id = 0;

mce_gconf_notifier_remove(mdy_blanking_pause_mode_gconf_cb_id),
mdy_blanking_pause_mode_gconf_cb_id = 0;

Expand Down
8 changes: 8 additions & 0 deletions modules/display.h
Expand Up @@ -364,6 +364,14 @@ enum
/** Default value for MCE_GCONF_ORIENTATION_SENSOR_ENABLED setting */
#define DEFAULT_ORIENTATION_SENSOR_ENABLED true

/** Flipover gesture detection enabled GConf setting */
# define MCE_GCONF_FLIPOVER_GESTURE_ENABLED MCE_GCONF_DISPLAY_PATH"/flipover_gesture_enabled"
# define DEFAULT_FLIPOVER_GESTURE_ENABLED true

/** Orientation change is user activity GConf setting */
# define MCE_GCONF_ORIENTATION_CHANGE_IS_ACTIVITY MCE_GCONF_DISPLAY_PATH"/orientation_change_is_activity"
# define DEFAULT_ORIENTATION_CHANGE_IS_ACTIVITY true

/** Display blanking pause modes */
typedef enum {
/** Ignore blanking pause requests */
Expand Down

0 comments on commit ef1ba81

Please sign in to comment.