Skip to content

Commit

Permalink
Cancel display state restore if devicelock state changes
Browse files Browse the repository at this point in the history
When usb cable is plugged in and device lock code entered, the display
will blank and possibly re-apply the device lock unless the user does
swipe to show homescreen almost immediately. Since successfully entering
the device lock code is clear indication that user wants to do something
with the device, normal blanking timeouts should be applied instead.

Cancel state restoration if device lock status changes during exceptional
display on state.

[mce] Cancel display state restore if devicelock state changes. Fixes JB#22743
  • Loading branch information
spiiroin committed Sep 17, 2014
1 parent ee0ea21 commit 3d51d22
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tklock.c
Expand Up @@ -546,6 +546,8 @@ static void tklock_datapipe_device_lock_active_cb(gconstpointer data)
mce_log(LL_DEBUG, "device_lock_active = %d -> %d", prev,
device_lock_active);

tklock_uiexcept_rethink();

tklock_autolock_rethink();

EXIT:
Expand Down Expand Up @@ -2047,6 +2049,7 @@ typedef struct
uiexctype_t mask;
display_state_t display;
bool tklock;
bool devicelock;
bool insync;
bool restore;
int64_t linger_tick;
Expand All @@ -2060,6 +2063,7 @@ static exception_t exdata =
.mask = UIEXC_NONE,
.display = MCE_DISPLAY_UNDEF,
.tklock = false,
.devicelock = false,
.insync = true,
.restore = true,
.linger_tick = MIN_TICK,
Expand Down Expand Up @@ -2160,6 +2164,11 @@ static void tklock_uiexcept_rethink(void)
exdata.restore = false;
}

if( exdata.restore && exdata.devicelock != device_lock_active ) {
mce_log(LL_NOTICE, "DISABLING STATE RESTORE; devicelock out of sync");
exdata.restore = false;
}

// re-sync on display on transition
if( display_prev != display_state ) {
mce_log(LL_DEBUG, "display state: %d -> %d",
Expand Down Expand Up @@ -2308,6 +2317,7 @@ static void tklock_uiexcept_cancel(void)
exdata.mask = UIEXC_NONE;
exdata.display = MCE_DISPLAY_UNDEF;
exdata.tklock = false;
exdata.devicelock = false;
exdata.insync = true;
exdata.restore = true;
exdata.linger_tick = MIN_TICK;
Expand Down Expand Up @@ -2417,9 +2427,10 @@ static void tklock_uiexcept_begin(uiexctype_t type, int64_t linger)
/* reset existing stats */
tklock_uiexcept_cancel();

/* save display and tklock state */
exdata.tklock = tklock_datapipe_have_tklock_submode();
exdata.display = display_state;
/* save display, tklock and device lock states */
exdata.display = display_state;
exdata.tklock = tklock_datapipe_have_tklock_submode();
exdata.devicelock = device_lock_active;

/* initially insync, restore state at end */
exdata.insync = true;
Expand Down

0 comments on commit 3d51d22

Please sign in to comment.