Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Hold wakelock while waiting for state machine to run
Previously suspend policy was evaluated while mce was holding
input wakelock. Since this is no longer the case, we need to
have another wakelock while waiting for the state machine
evaluation to take place.
  • Loading branch information
spiiroin committed Sep 4, 2013
1 parent c62cb25 commit e53045d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions mce.c
Expand Up @@ -281,6 +281,7 @@ static void mce_cleanup_wakelocks(void)

wakelock_unlock("mce_display_on");
wakelock_unlock("mce_input_handler");
wakelock_unlock("mce_display_stm");
}
#endif // ENABLE_WAKELOCKS

Expand Down
16 changes: 14 additions & 2 deletions modules/display.c
Expand Up @@ -4988,8 +4988,18 @@ static void stm_rethink(void)
static gboolean stm_rethink_cb(gpointer aptr)
{
(void)aptr; // not used
if( stm_rethink_id )
stm_rethink_id = 0, stm_rethink();

if( stm_rethink_id ) {
/* clear pending rethink */
stm_rethink_id = 0;

/* run the state machine */
stm_rethink();

/* remove wakelock if not re-scheduled */
if( !stm_rethink_id )
wakelock_unlock("mce_display_stm");
}
return FALSE;
}

Expand All @@ -4998,12 +5008,14 @@ static void stm_rethink_cancel(void)
if( stm_rethink_id ) {
g_source_remove(stm_rethink_id), stm_rethink_id = 0;
mce_log(LL_INFO, "cancelled");
wakelock_unlock("mce_display_stm");
}
}

static void stm_rethink_schedule(void)
{
if( !stm_rethink_id ) {
wakelock_lock("mce_display_stm", -1);
mce_log(LL_INFO, "scheduled");
stm_rethink_id = g_idle_add(stm_rethink_cb, 0);
}
Expand Down

0 comments on commit e53045d

Please sign in to comment.