Skip to content

Commit

Permalink
[tklock] Add setting for disabling unblank to lockscreen animation. C…
Browse files Browse the repository at this point in the history
…ontributes to JB#30849

A lot of users think the animated unblank to lockscreen is too slow.

While there is at present no way to directly control the animation that
happens on the ui side, it does get implicitly disabled when display is
unblanked due to alarms/calls/notifications. Utilize this and optionally
fake notification unblank when a double tap or power key press is used
to wake up the device.

Add setting for enabling/disabling lockscreen unblank animations.

By default the animations are enabled, but this can be changed via
mcetool option:
  --set-lockscreen-animation=<enabled|disabled>

The value of the setting persists over mce / device restarts.
  • Loading branch information
spiiroin committed Sep 30, 2015
1 parent 0c178da commit eae505c
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 7 deletions.
5 changes: 5 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1767,6 +1767,11 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = G_STRINGIFY(DEFAULT_EXCEPTION_LENGTH_ACTIVITY),
},
{
.key = MCE_GCONF_TK_LOCKSCREEN_ANIM_ENABLED,
.type = "b",
.def = G_STRINGIFY(DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED),
},
{
.key = NULL,
}
Expand Down
2 changes: 2 additions & 0 deletions datapipe.c
Expand Up @@ -1054,6 +1054,7 @@ const char *uiexctype_repr(uiexctype_t state)
case UIEXC_CALL: res = "call"; break;
case UIEXC_ALARM: res = "alarm"; break;
case UIEXC_NOTIF: res = "notif"; break;
case UIEXC_NOANIM: res = "noanim"; break;
default: break;
}
return res;
Expand All @@ -1075,6 +1076,7 @@ const char *uiexctype_to_dbus(uiexctype_t state)

switch( state ) {
case UIEXC_NOTIF:
case UIEXC_NOANIM:
res = MCE_BLANKING_POLICY_NOTIFICATION_STRING;
break;

Expand Down
1 change: 1 addition & 0 deletions mce.h
Expand Up @@ -306,6 +306,7 @@ typedef enum {
UIEXC_CALL = 1<<1,
UIEXC_ALARM = 1<<2,
UIEXC_NOTIF = 1<<3,
UIEXC_NOANIM = 1<<4,
} uiexctype_t;

const char *uiexctype_repr(uiexctype_t state);
Expand Down
6 changes: 2 additions & 4 deletions powerkey.c
Expand Up @@ -22,6 +22,7 @@
*/

#include "powerkey.h"
#include "tklock.h"

#include "mce.h"
#include "mce-log.h"
Expand Down Expand Up @@ -685,10 +686,7 @@ pwrkey_action_unblank(void)
display_state_t request = MCE_DISPLAY_ON;
mce_log(LL_DEBUG, "Requesting display=%s",
display_state_repr(request));
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(request),
USE_INDATA, CACHE_INDATA);

mce_tklock_unblank(request);
}

static void
Expand Down
63 changes: 60 additions & 3 deletions tklock.c
Expand Up @@ -360,6 +360,7 @@ static void mce_tklock_end_notification(const char *owner, const char *name,
// "module" load/unload
extern gboolean mce_tklock_init(void);
extern void mce_tklock_exit(void);
extern void mce_tklock_unblank(display_state_t to_state);

/* ========================================================================= *
* gconf settings
Expand Down Expand Up @@ -510,6 +511,10 @@ static gint exception_length_activity = DEFAULT_EXCEPTION_LENGTH_ACTIV
/** GConf callback ID for exception_length_activity */
static guint exception_length_activity_cb_id = 0;

/** Flag for: Allow lockscreen animation during unblanking */
static gboolean lockscreen_anim_enabled = DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED;
static guint lockscreen_anim_enabled_cb_id = 0;

/* ========================================================================= *
* probed control file paths
* ========================================================================= */
Expand Down Expand Up @@ -757,6 +762,12 @@ static void tklock_datapipe_display_state_cb(gconstpointer data)
display_state_repr(prev),
display_state_repr(display_state));

/* Disable "wakeup with fake policy" hack
* when any stable display state is reached */
if( display_state != MCE_DISPLAY_POWER_UP &&
display_state != MCE_DISPLAY_POWER_DOWN )
tklock_uiexcept_end(UIEXC_NOANIM, 0);

if( display_state == MCE_DISPLAY_DIM )
tklock_ui_eat_event();

Expand Down Expand Up @@ -1510,15 +1521,14 @@ static void tklock_datapipe_touchscreen_cb(gconstpointer const data)
case DBLTAP_ACTION_UNBLANK: // unblank
case DBLTAP_ACTION_TKUNLOCK: // unblank + unlock
mce_log(LL_DEBUG, "double tap -> display on");

/* Double tap event that is about to be used for unblanking
* the display counts as non-syntetized user activity */
execute_datapipe_output_triggers(&user_activity_pipe,
ev, USE_INDATA);

/* Turn the display on */
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_tklock_unblank(MCE_DISPLAY_ON);

/* Optionally remove tklock */
if( doubletap_gesture_policy == DBLTAP_ACTION_TKUNLOCK ) {
Expand Down Expand Up @@ -2919,6 +2929,7 @@ static uiexctype_t topmost_active(uiexctype_t mask)
UIEXC_ALARM,
UIEXC_CALL,
UIEXC_LINGER,
UIEXC_NOANIM,
0
};

Expand Down Expand Up @@ -3087,6 +3098,17 @@ static void tklock_uiexcept_rethink(void)
}

switch( active ) {
case UIEXC_NOANIM:
/* The noanim exception is used only during display power up.
* It also has the lowest priority, which means that if it
* ever gets on top of the exception stack, we need to disable
* state restore. */
if( exdata.restore ) {
mce_log(LL_DEBUG, "noanim exception state; disable state restore");
exdata.restore = false;
}
break;

case UIEXC_NOTIF:
mce_log(LL_DEBUG, "UIEXC_NOTIF");
activate = true;
Expand Down Expand Up @@ -4274,6 +4296,9 @@ static void tklock_gconf_cb(GConfClient *const gcc, const guint id,
else if( id == filter_lid_with_als_gconf_id ) {
filter_lid_with_als = gconf_value_get_bool(gcv);
}
else if( id == lockscreen_anim_enabled_cb_id ) {
lockscreen_anim_enabled= gconf_value_get_bool(gcv);
}
else if( id == tklock_autolock_delay_cb_id ) {
gint old = tklock_autolock_delay;
tklock_autolock_delay = gconf_value_get_int(gcv);
Expand Down Expand Up @@ -4648,6 +4673,12 @@ static void tklock_gconf_init(void)
DEFAULT_EXCEPTION_LENGTH_ACTIVITY,
tklock_gconf_cb,
&exception_length_activity_cb_id);

mce_gconf_track_bool(MCE_GCONF_TK_LOCKSCREEN_ANIM_ENABLED,
&lockscreen_anim_enabled,
DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED,
tklock_gconf_cb,
&lockscreen_anim_enabled_cb_id);
}

/** Remove gconf change notifiers
Expand Down Expand Up @@ -4743,6 +4774,9 @@ static void tklock_gconf_quit(void)

mce_gconf_notifier_remove(exception_length_activity_cb_id),
exception_length_activity_cb_id = 0;

mce_gconf_notifier_remove(lockscreen_anim_enabled_cb_id),
lockscreen_anim_enabled_cb_id = 0;
}

/* ========================================================================= *
Expand Down Expand Up @@ -6333,3 +6367,26 @@ void mce_tklock_exit(void)

return;
}

/** Perform display powerup under faked abnormal blanking policy
*
* @param to_state display state to wake up to
*/
void mce_tklock_unblank(display_state_t to_state)
{
if( display_state_next == to_state)
goto EXIT;

if( !lockscreen_anim_enabled ) {
/* Disable lockscreen animations by invoking a faked
* abnormal display blanking policy for the duration
* of the display power up. */
tklock_uiexcept_begin(UIEXC_NOANIM, 0);
}

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(to_state),
USE_INDATA, CACHE_INDATA);
EXIT:
return;
}
7 changes: 7 additions & 0 deletions tklock.h
Expand Up @@ -22,6 +22,8 @@
#ifndef _TKLOCK_H_
#define _TKLOCK_H_

#include "mce.h"

#include <glib.h>

#ifndef MCE_GCONF_LOCK_PATH
Expand Down Expand Up @@ -261,6 +263,10 @@ enum
#define MCE_GCONF_TK_INPUT_POLICY_ENABLED MCE_GCONF_LOCK_PATH "/touchscreen_policy_enabled"
#define DEFAULT_TK_INPUT_POLICY_ENABLED true

/** Allow / try to deny lockscreen animations */
#define MCE_GCONF_TK_LOCKSCREEN_ANIM_ENABLED MCE_GCONF_LOCK_PATH "/lockscreen_animation_enabled"
#define DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED true

/** Name of D-Bus callback to provide to Touchscreen/Keypad Lock SystemUI */
#define MCE_TKLOCK_CB_REQ "tklock_callback"

Expand All @@ -275,4 +281,5 @@ enum
gboolean mce_tklock_init(void);
void mce_tklock_exit(void);

void mce_tklock_unblank(display_state_t to_state);
#endif /* _TKLOCK_H_ */
35 changes: 35 additions & 0 deletions tools/mcetool.c
Expand Up @@ -3481,6 +3481,33 @@ static void xmce_get_devicelock_in_lockscreen(void)
printf("%-"PAD1"s %s\n", "Devicelock is in lockscreen:", txt);
}

/* ------------------------------------------------------------------------- *
* lock screen animation
* ------------------------------------------------------------------------- */

/* Set lock screen animation enabled/disabled
*
* @param args string suitable for interpreting as enabled/disabled
*/
static bool xmce_set_lockscreen_unblank_animation(const char *args)
{
gboolean val = xmce_parse_enabled(args);
mcetool_gconf_set_bool(MCE_GCONF_TK_LOCKSCREEN_ANIM_ENABLED, val);
return true;
}

/* Show current lock screen animation enabled/disabled
*/
static void xmce_get_lockscreen_unblank_animation(void)
{
gboolean val = 0;
char txt[32] = "unknown";

if( mcetool_gconf_get_bool(MCE_GCONF_TK_LOCKSCREEN_ANIM_ENABLED, &val) )
snprintf(txt, sizeof txt, "%s", val ? "enabled" : "disabled");
printf("%-"PAD1"s %s\n", "Lockscreen unblank animations:", txt);
}

/* ------------------------------------------------------------------------- *
* blank timeout
* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -5046,6 +5073,7 @@ static bool xmce_get_status(const char *args)
xmce_get_autolock_mode();
xmce_get_autolock_delay();
xmce_get_devicelock_in_lockscreen();
xmce_get_lockscreen_unblank_animation();
xmce_get_doubletap_mode();
xmce_get_doubletap_wakeup();
xmce_get_powerkey_action();
Expand Down Expand Up @@ -5356,6 +5384,13 @@ static const mce_opt_t options[] =
"\n"
"Valid modes are: 'enabled' and 'disabled'\n"
},
{
.name = "set-lockscreen-animation",
.with_arg = xmce_set_lockscreen_unblank_animation,
.values = "enabled|disabled",
.usage =
"allow/deny animations during unblanking via powerkey / doubletap\n"
},
{
.name = "set-tklock-blank",
.flag = 't',
Expand Down

0 comments on commit eae505c

Please sign in to comment.