Skip to content

Commit

Permalink
[tklock] Add settings for proximity sensor uncover delays. Fixes MER#…
Browse files Browse the repository at this point in the history
…1881

Some devices / users might benefit from having ability to tweak in-call
proximity unblanking delay, but currently delays between proximity sensor
reporting uncovered and taking actions on the change are hard coded.

Add setting for both default and in-call proximity uncover delays. This
allows configuration files to be used to define device specific defaults
and mcetool for tweaking by users.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Feb 23, 2018
1 parent 0510206 commit 6274eb5
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 10 deletions.
10 changes: 10 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1826,6 +1826,16 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = G_STRINGIFY(MCE_DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED),
},
{
.key = MCE_SETTING_TK_PROXIMITY_DELAY_DEFAULT,
.type = "i",
.def = G_STRINGIFY(MCE_DEFAULT_TK_PROXIMITY_DELAY_DEFAULT),
},
{
.key = MCE_SETTING_TK_PROXIMITY_DELAY_INCALL,
.type = "i",
.def = G_STRINGIFY(MCE_DEFAULT_TK_PROXIMITY_DELAY_INCALL),
},
{
.key = NULL,
}
Expand Down
50 changes: 40 additions & 10 deletions tklock.c
Expand Up @@ -554,6 +554,14 @@ static guint exception_length_activity_setting_id = 0;
static gboolean lockscreen_anim_enabled = MCE_DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED;
static guint lockscreen_anim_enabled_setting_id = 0;

/** Default delay for delaying proximity uncovered handling [ms] */
static gint tklock_proximity_delay_default = MCE_DEFAULT_TK_PROXIMITY_DELAY_DEFAULT;
static guint tklock_proximity_delay_default_setting_id = 0;

/** Delay for delaying proximity uncovered handling during calls [ms] */
static gint tklock_proximity_delay_incall = MCE_DEFAULT_TK_PROXIMITY_DELAY_INCALL;
static guint tklock_proximity_delay_incall_setting_id = 0;

/* ========================================================================= *
* probed control file paths
* ========================================================================= */
Expand Down Expand Up @@ -971,14 +979,6 @@ static void tklock_datapipe_proximity_uncover_cancel(void)
}
}

enum {
/** Default delay for delaying proximity uncovered handling [ms] */
PROXIMITY_DELAY_DEFAULT = 100,

/** Delay for delaying proximity uncovered handling during calls [ms] */
PROXIMITY_DELAY_INCALL = 500,
};

/** Schedule delayed proximity uncovering
*/
static void tklock_datapipe_proximity_uncover_schedule(void)
Expand All @@ -988,10 +988,15 @@ static void tklock_datapipe_proximity_uncover_schedule(void)
else
wakelock_lock("mce_proximity_stm", -1);

int delay = PROXIMITY_DELAY_DEFAULT;
int delay = tklock_proximity_delay_default;

if( call_state == CALL_STATE_ACTIVE )
delay = PROXIMITY_DELAY_INCALL;
delay = tklock_proximity_delay_incall;

if( delay < MCE_MINIMUM_TK_PROXIMITY_DELAY )
delay = MCE_MINIMUM_TK_PROXIMITY_DELAY;
else if( delay > MCE_MAXIMUM_TK_PROXIMITY_DELAY )
delay = MCE_MAXIMUM_TK_PROXIMITY_DELAY;

tklock_datapipe_proximity_uncover_id =
g_timeout_add(delay, tklock_datapipe_proximity_uncover_cb, 0);
Expand Down Expand Up @@ -4811,6 +4816,18 @@ static void tklock_setting_cb(GConfClient *const gcc, const guint id,
mce_log(LL_NOTICE, "exception_length_activity: %d -> %d",
old, exception_length_activity);
}
else if( id == tklock_proximity_delay_default_setting_id ) {
gint old = tklock_proximity_delay_default;
tklock_proximity_delay_default = gconf_value_get_int(gcv);
mce_log(LL_NOTICE, "proximity_delay_default: %d -> %d",
old, tklock_proximity_delay_default);
}
else if( id == tklock_proximity_delay_incall_setting_id ) {
gint old = tklock_proximity_delay_incall;
tklock_proximity_delay_incall = gconf_value_get_int(gcv);
mce_log(LL_NOTICE, "proximity_delay_incall: %d -> %d",
old, tklock_proximity_delay_incall);
}
else {
mce_log(LL_WARN, "Spurious GConf value received; confused!");
}
Expand Down Expand Up @@ -5034,6 +5051,19 @@ static void tklock_setting_init(void)
MCE_DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED,
tklock_setting_cb,
&lockscreen_anim_enabled_setting_id);

/* Delays for proximity sensor uncover handling */
mce_setting_track_int(MCE_SETTING_TK_PROXIMITY_DELAY_DEFAULT,
&tklock_proximity_delay_default,
MCE_DEFAULT_TK_PROXIMITY_DELAY_DEFAULT,
tklock_setting_cb,
&tklock_proximity_delay_default_setting_id);

mce_setting_track_int(MCE_SETTING_TK_PROXIMITY_DELAY_INCALL,
&tklock_proximity_delay_incall,
MCE_DEFAULT_TK_PROXIMITY_DELAY_INCALL,
tklock_setting_cb,
&tklock_proximity_delay_incall_setting_id);
}

/** Stop tracking setting changes
Expand Down
12 changes: 12 additions & 0 deletions tklock.h
Expand Up @@ -248,6 +248,18 @@ typedef enum {
# define MCE_SETTING_TK_LOCKSCREEN_ANIM_ENABLED MCE_SETTING_TK_PATH "/lockscreen_animation_enabled"
# define MCE_DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED true

/** Default proximity sensor uncover handling [ms]*/
# define MCE_SETTING_TK_PROXIMITY_DELAY_DEFAULT MCE_SETTING_TK_PATH "/proximity_delay_default"
# define MCE_DEFAULT_TK_PROXIMITY_DELAY_DEFAULT 100

/** In-call proximity sensor uncover handling [ms]*/
# define MCE_SETTING_TK_PROXIMITY_DELAY_INCALL MCE_SETTING_TK_PATH "/proximity_delay_incall"
# define MCE_DEFAULT_TK_PROXIMITY_DELAY_INCALL 500

/** Accpeted range for proximity sensor uncover delay: [0s, 1h] */
# define MCE_MINIMUM_TK_PROXIMITY_DELAY 0
# define MCE_MAXIMUM_TK_PROXIMITY_DELAY (60 * 60 * 1000)

/* ========================================================================= *
* Configuration
* ========================================================================= */
Expand Down
70 changes: 70 additions & 0 deletions tools/mcetool.c
Expand Up @@ -3536,6 +3536,63 @@ static void xmce_get_ps_acts_as_lid(void)
printf("%-"PAD1"s %s\n", "PS acts as LID sensor:", txt);
}

/* ------------------------------------------------------------------------- *
* ps uncover delay
* ------------------------------------------------------------------------- */

static bool xmce_set_ps_uncover_delay_sub(const char *key, const char *args)
{
int val = xmce_parse_integer(args);
if( val < MCE_MINIMUM_TK_PROXIMITY_DELAY ||
val > MCE_MAXIMUM_TK_PROXIMITY_DELAY ) {
errorf("%s: invalid proximity uncover delay\n", args);
return false;
}
return xmce_setting_set_int(key, val);
}

static void xmce_get_ps_uncover_delay_sub(const char *tag, const char *key)
{
gint val = 0;
char txt[32];

strcpy(txt, "unknown");
if( xmce_setting_get_int(key, &val) )
snprintf(txt, sizeof txt, "%d", (int)val);
printf("%-"PAD1"s %s (ms)\n", tag, txt);
}

/** Set default proximity sensor uncover delay
*
* @param args string that can be parsed to integer
*/
static bool xmce_set_default_ps_uncover_delay(const char *args)
{
return xmce_set_ps_uncover_delay_sub(MCE_SETTING_TK_PROXIMITY_DELAY_DEFAULT,
args);
}

/** Set default proximity sensor uncover delay
*
* @param args string that can be parsed to integer
*/
static bool xmce_set_incall_ps_uncover_delay(const char *args)
{
return xmce_set_ps_uncover_delay_sub(MCE_SETTING_TK_PROXIMITY_DELAY_INCALL,
args);
}

/** Get proximity sensor uncover delays and print them out
*/
static void xmce_get_ps_uncover_delay(void)
{
xmce_get_ps_uncover_delay_sub("Default ps uncover delay:",
MCE_SETTING_TK_PROXIMITY_DELAY_DEFAULT);

xmce_get_ps_uncover_delay_sub("In-call ps uncover delay:",
MCE_SETTING_TK_PROXIMITY_DELAY_INCALL);
}

/* ------------------------------------------------------------------------- *
* als
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -5539,6 +5596,7 @@ static bool xmce_get_status(const char *args)
xmce_get_orientation_change_is_activity();
xmce_get_flipover_gesture_detection();
xmce_get_ps_mode();
xmce_get_ps_uncover_delay();
xmce_get_ps_blocks_touch();
xmce_get_ps_acts_as_lid();
xmce_get_lid_sensor_mode();
Expand Down Expand Up @@ -6339,6 +6397,18 @@ static const mce_opt_t options[] =
"set the ps mode; valid modes are:\n"
"'enabled' and 'disabled'\n"
},
{
.name = "set-default-ps-uncover-delay",
.with_arg = xmce_set_default_ps_uncover_delay,
.values = "ms",
"set the default ps uncover delay in milliseconds\n"
},
{
.name = "set-incall-ps-uncover-delay",
.with_arg = xmce_set_incall_ps_uncover_delay,
.values = "ms",
"set the incall ps uncover delay in milliseconds\n"
},
{
.name = "set-ps-blocks-touch",
.with_arg = xmce_set_ps_blocks_touch,
Expand Down

0 comments on commit 6274eb5

Please sign in to comment.