Skip to content

Commit

Permalink
Allow disabling of automatic screen blanking from lock screen
Browse files Browse the repository at this point in the history
New config setting "/system/osso/dsm/locks/tklock_blank_disable".

When enabled, tklock module uses longer timeouts for display
dimming / blanking. Effectively the lock screen is shown until
power key is pressed.

The config setting can be toggled with:
  mcetool --set-tklock-noblank=enabled|disabled
  • Loading branch information
spiiroin committed Feb 19, 2013
1 parent b271b2d commit f5ae869
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 4 deletions.
6 changes: 6 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1271,6 +1271,12 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = "1",
},
{
// MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH @ tklock.h
.key = "/system/osso/dsm/locks/tklock_blank_disable",
.type = "i",
.def = "0",
},
{
.key = NULL,
}
Expand Down
57 changes: 55 additions & 2 deletions tklock.c
Expand Up @@ -171,6 +171,12 @@ static output_state_t mce_keypad_sysfs_disable_output =
.close_on_exit = TRUE,
};

/** Disable automatic dim/blank from tklock */
static gint tklock_blank_disable = FALSE;

/** GConf notifier id for tracking tklock_blank_disable changes */
static guint tklock_blank_disable_id = 0;

/** Touchscreen double tap gesture policy */
static gint doubletap_gesture_policy = DEFAULT_DOUBLETAP_GESTURE_POLICY;

Expand Down Expand Up @@ -1330,6 +1336,8 @@ static void setup_tklock_visual_blank_timeout(void)
datapipe_get_gint(alarm_ui_state_pipe);
call_state_t call_state = datapipe_get_gint(call_state_pipe);

gint delay = DEFAULT_VISUAL_BLANK_DELAY;

cancel_tklock_dim_timeout();
cancel_tklock_visual_blank_timeout();

Expand All @@ -1340,9 +1348,14 @@ static void setup_tklock_visual_blank_timeout(void)
(alarm_ui_state == MCE_ALARM_UI_RINGING_INT32))
goto EXIT;

if( tklock_blank_disable ) {
mce_log(LL_INFO, "visual_blank_timeout disabled");
delay = 24 * 60 * 60; // 24h
}

/* Setup blank timeout */
tklock_visual_blank_timeout_cb_id =
g_timeout_add_seconds(DEFAULT_VISUAL_BLANK_DELAY, tklock_visual_blank_timeout_cb, NULL);
g_timeout_add_seconds(delay, tklock_visual_blank_timeout_cb, NULL);

EXIT:
return;
Expand Down Expand Up @@ -1392,11 +1405,18 @@ static void cancel_tklock_dim_timeout(void)
*/
static void setup_tklock_dim_timeout(void)
{
gint delay = dim_delay;

cancel_tklock_dim_timeout();

if( tklock_blank_disable ) {
mce_log(LL_INFO, "visual_dim_timeout disabled");
delay = 24 * 60 * 60; // 24h
}

/* Setup new timeout */
tklock_dim_timeout_cb_id =
g_timeout_add_seconds(dim_delay, tklock_dim_timeout_cb, NULL);
g_timeout_add_seconds(delay, tklock_dim_timeout_cb, NULL);
}

/**
Expand Down Expand Up @@ -2069,6 +2089,23 @@ static void tklock_gconf_cb(GConfClient *const gcc, const guint id,
doubletap_gesture_policy =
DEFAULT_DOUBLETAP_GESTURE_POLICY;
}
} else if(id == tklock_blank_disable_id) {
gint old = tklock_blank_disable;

tklock_blank_disable = gconf_value_get_int(gcv);

mce_log(LL_NOTICE, "tklock_blank_disable: %d -> %d",
old, tklock_blank_disable);

if( tklock_blank_disable == old ) {
// no need to change the timers
}
else if( tklock_visual_blank_timeout_cb_id ) {
setup_tklock_visual_blank_timeout();
}
else if( tklock_dim_timeout_cb_id ) {
setup_tklock_dim_timeout();
}
} else {
mce_log(LL_WARN, "Spurious GConf value received; confused!");
}
Expand Down Expand Up @@ -3203,6 +3240,17 @@ gboolean mce_tklock_init(void)
append_output_trigger_to_datapipe(&heartbeat_pipe,
heartbeat_trigger);

/* Config tracking for disabling automatic screen dimming/blanking
* while showing lockscreen. This is demo/debugging feature, so sane
* defaults must be used and no error checking is needed. */
mce_gconf_notifier_add(MCE_GCONF_LOCK_PATH,
MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
tklock_gconf_cb,
&tklock_blank_disable_id);

mce_gconf_get_int(MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
&tklock_blank_disable);

/* Touchscreen/keypad autolock */
/* Since we've set a default, error handling is unnecessary */
/*(void)mce_gconf_get_bool(MCE_GCONF_TK_AUTOLOCK_ENABLED_PATH,
Expand Down Expand Up @@ -3341,6 +3389,11 @@ gboolean mce_tklock_init(void)
*/
void mce_tklock_exit(void)
{
/* Remove gconf change notifiers */
if( tklock_blank_disable_id ) {
mce_gconf_notifier_remove(GINT_TO_POINTER(tklock_blank_disable_id), 0);
}

/* Remove triggers/filters from datapipes */
remove_output_trigger_from_datapipe(&heartbeat_pipe,
heartbeat_trigger);
Expand Down
3 changes: 3 additions & 0 deletions tklock.h
Expand Up @@ -85,6 +85,9 @@
/** Path to the touchscreen/keypad double tap gesture GConf setting */
#define MCE_GCONF_TK_DOUBLE_TAP_GESTURE_PATH MCE_GCONF_LOCK_PATH "/tklock_double_tap_gesture"

/** Path to the automatic tklock dim/blank disable GConf setting */
#define MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH MCE_GCONF_LOCK_PATH "/tklock_blank_disable"

/** Name of D-Bus callback to provide to Touchscreen/Keypad Lock SystemUI */
#define MCE_TKLOCK_CB_REQ "tklock_callback"
/** Delay before the touchscreen/keypad is unlocked */
Expand Down
46 changes: 44 additions & 2 deletions tools/mcetool.c
Expand Up @@ -225,6 +225,10 @@ static void usage(void)
" set the threshold for the power saving mode;\n"
" valid values are:\n"
" 10, 20, 30, 40, 50\n"
" -t, --set-tklock-noblank=MODE\n"
" set the touchscreen/keypad autoblank mode;\n"
" valid modes are: \"enabled\" and \"disabled\"\n"

" -k, --set-tklock-mode=MODE\n"
" set the touchscreen/keypad lock mode;\n"
" valid modes are:\n"
Expand Down Expand Up @@ -1985,6 +1989,16 @@ static const symbol_t suspendpol_values[] = {
{ NULL, -1 }
};

/** Lookup table for tklock autoblank policy values
*
* @note These must match the hardcoded values in mce itself.
*/
static const symbol_t tklockblank_values[] = {
{ "disabled", 1 },
{ "enabled", 0 },
{ NULL, -1 }
};

/**
* Print mce related information
*
Expand Down Expand Up @@ -2416,9 +2430,18 @@ static gint mcetool_get_status(void)
gint policy;
retval = mcetool_gconf_get_int(MCE_GCONF_USE_AUTOSUSPEND_PATH,
&policy);
fprintf(stdout, " %-40s %s", "Autosuspend policy",
fprintf(stdout, " %-40s %s\n", "Autosuspend policy",
!retval ? "<unset>" : rlookup(suspendpol_values, policy) ?: "<unknown>");
}

/* Get tklock blank policy */
{
gint policy;
retval = mcetool_gconf_get_int(MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
&policy);
fprintf(stdout, " %-40s %s\n", "tklock autoblank policy",
!retval ? "<unset>" : rlookup(tklockblank_values, policy) ?: "<unknown>");
}
EXIT:
fprintf(stdout, "\n");

Expand Down Expand Up @@ -2489,6 +2512,7 @@ int main(int argc, char **argv)

gint powerkeyevent = INVALID_EVENT;
gint newinhibitmode = -1;
gint newtklockblank = -1;
#if MCETOOL_USE_DEMOMODE_HACK
gint demomode = -1;
#endif
Expand Down Expand Up @@ -2533,7 +2557,7 @@ int main(int argc, char **argv)
DBusBusType bus_type = DBUS_BUS_SYSTEM;

// Unused short options left ....
// - - - - - - - - i j - - m - o - q - s t u - w x - z
// - - - - - - - - i j - - m - o - q - - - u - w x - z
// - - - - - - - - - - - - - - - - Q - - - - - W X - Z

const char optline[] =
Expand Down Expand Up @@ -2575,6 +2599,7 @@ int main(int argc, char **argv)
"M:" // --set-doubletap-mode
"O:" // --set-dim-timeouts
"s:" // --set-suspend-policy
"t:" // --set-tklock-noblank
;

struct option const options[] = {
Expand All @@ -2597,6 +2622,7 @@ int main(int argc, char **argv)
{ "set-forced-psm", required_argument, 0, 'F' },
{ "set-psm-threshold", required_argument, 0, 'T' },
{ "set-tklock-mode", required_argument, 0, 'k' },
{ "set-tklock-noblank", required_argument, 0, 't' },
{ "enable-led", no_argument, 0, 'l' },
{ "disable-led", no_argument, 0, 'L' },
{ "activate-led-pattern", required_argument, 0, 'y' },
Expand Down Expand Up @@ -2910,6 +2936,15 @@ int main(int argc, char **argv)
get_mce_status = FALSE;
break;

case 't':
if( (newtklockblank = lookup(tklockblank_values, optarg)) < 0 ) {
fprintf(stderr, "invalid lockscreen blanking policy: %s\n",
optarg);
goto EXIT;
}
get_mce_status = FALSE;
break;

case 'I':
if (!strcmp(optarg, BLANKING_INHIBIT_DISABLED)) {
newinhibitmode = 0;
Expand Down Expand Up @@ -3167,6 +3202,13 @@ int main(int argc, char **argv)
goto EXIT;
}

if (newtklockblank != -1) {
if (mcetool_gconf_set_int(MCE_GCONF_TK_AUTO_BLANK_DISABLE_PATH,
newtklockblank) == FALSE)
goto EXIT;
}


#if MCETOOL_USE_DEMOMODE_HACK
if (demomode != -1) {
if (dbus_send(MCE_SERVICE, MCE_REQUEST_PATH,
Expand Down

0 comments on commit f5ae869

Please sign in to comment.