Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[tklock] Do not unblank due to open cover on mce startup. Fixes JB#41255
Once "device has a working lid sensor" condition is met, display gets
unblanked on every mce restart unless a suitable cover is in use and
closed.

Do not act on lid open events until lid has been observed to be closed.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jun 12, 2019
1 parent c3a54b3 commit cf31f93
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tklock.c
Expand Up @@ -3181,6 +3181,9 @@ static void tklock_lidfilter_rethink_als_state(void)
*/
static void tklock_lidpolicy_rethink(void)
{
/* We have not seen COVER_CLOSED state yet */
static bool lid_has_been_closed = false;

/* Assume lid is neither open nor closed */
cover_state_t action = COVER_UNDEF;

Expand All @@ -3206,6 +3209,11 @@ static void tklock_lidpolicy_rethink(void)
action = COVER_OPEN;
}

/* To avoid unblanking on mce restart while lid is open, stay in
* undecided state until we have observed lid closed state too. */
if( action == COVER_OPEN && !lid_has_been_closed )
action = COVER_UNDEF;

/* Skip the rest if there is no change */
if( lid_sensor_filtered == action )
goto EXIT;
Expand All @@ -3221,6 +3229,9 @@ static void tklock_lidpolicy_rethink(void)
/* Then execute the required actions */
switch( action ) {
case COVER_CLOSED:
/* Allow unblanking when lid is opened again. */
lid_has_been_closed = true;

/* Blank display + lock ui */
if( tklock_lid_close_actions != LID_CLOSE_ACTION_DISABLED ) {
mce_log(LL_DEVEL, "lid closed - blank");
Expand Down

0 comments on commit cf31f93

Please sign in to comment.