Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Block tklock while update mode is active
If update mode gets activated while home screen is available,
tklock should be blocked.
  • Loading branch information
spiiroin committed Jun 12, 2014
1 parent feb935c commit 12db936
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions datapipe.c
Expand Up @@ -154,6 +154,9 @@ datapipe_struct lipstick_available_pipe;
/** PackageKit Locked status; read only */
datapipe_struct packagekit_locked_pipe;

/** Update mode active status; read only */
datapipe_struct update_mode_pipe;

/** Device Lock active status; read only */
datapipe_struct device_lock_active_pipe;

Expand Down Expand Up @@ -850,6 +853,8 @@ void mce_datapipe_init(void)
0, GINT_TO_POINTER(FALSE));
setup_datapipe(&packagekit_locked_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(FALSE));
setup_datapipe(&update_mode_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(FALSE));
setup_datapipe(&device_lock_active_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(FALSE));
setup_datapipe(&touch_grab_wanted_pipe, READ_WRITE, DONT_FREE_CACHE,
Expand Down Expand Up @@ -910,6 +915,7 @@ void mce_datapipe_quit(void)
free_datapipe(&heartbeat_pipe);
free_datapipe(&lipstick_available_pipe);
free_datapipe(&packagekit_locked_pipe);
free_datapipe(&update_mode_pipe);
free_datapipe(&device_lock_active_pipe);
free_datapipe(&touch_grab_active_pipe);
free_datapipe(&touch_grab_wanted_pipe);
Expand Down
1 change: 1 addition & 0 deletions mce.h
Expand Up @@ -328,6 +328,7 @@ extern datapipe_struct thermal_state_pipe;
extern datapipe_struct heartbeat_pipe;
extern datapipe_struct lipstick_available_pipe;
extern datapipe_struct packagekit_locked_pipe;
extern datapipe_struct update_mode_pipe;
extern datapipe_struct device_lock_active_pipe;
extern datapipe_struct touch_grab_wanted_pipe;
extern datapipe_struct touch_grab_active_pipe;
Expand Down
5 changes: 5 additions & 0 deletions modules/display.c
Expand Up @@ -6845,6 +6845,11 @@ static void mdy_flagfiles_update_mode_cb(const char *path,

/* blanking timers need to be started or stopped */
mdy_blanking_rethink_timers(true);

/* broadcast change within mce */
execute_datapipe(&update_mode_pipe,
GINT_TO_POINTER(mdy_update_mode),
USE_INDATA, CACHE_INDATA);
}
}

Expand Down
35 changes: 35 additions & 0 deletions tklock.c
Expand Up @@ -173,6 +173,7 @@ static int64_t tklock_monotick_get(void);
static void tklock_datapipe_system_state_cb(gconstpointer data);
static void tklock_datapipe_device_lock_active_cb(gconstpointer data);
static void tklock_datapipe_lipstick_available_cb(gconstpointer data);
static void tklock_datapipe_update_mode_cb(gconstpointer data);
static void tklock_datapipe_display_state_cb(gconstpointer data);
static void tklock_datapipe_proximity_update(void);
static gboolean tklock_datapipe_proximity_uncover_cb(gpointer data);
Expand Down Expand Up @@ -583,6 +584,32 @@ static void tklock_datapipe_lipstick_available_cb(gconstpointer data)
return;
}

/** Update mode is active; assume false */
static bool update_mode = false;

/** Change notifications for update_mode
*/
static void tklock_datapipe_update_mode_cb(gconstpointer data)
{
bool prev = update_mode;
update_mode = GPOINTER_TO_INT(data);

if( update_mode == prev )
goto EXIT;

mce_log(LL_DEBUG, "update_mode = %d -> %d", prev, update_mode);

if( update_mode ) {
/* undo tklock when update mode starts */
execute_datapipe(&tk_lock_pipe,
GINT_TO_POINTER(LOCK_OFF),
USE_INDATA, CACHE_INDATA);
}

EXIT:
return;
}

/** Display state; undefined initially, can't assume anything */
static display_state_t display_state = MCE_DISPLAY_UNDEF;

Expand Down Expand Up @@ -1417,6 +1444,10 @@ static datapipe_binding_t tklock_datapipe_triggers[] =
.datapipe = &lipstick_available_pipe,
.output_cb = tklock_datapipe_lipstick_available_cb,
},
{
.datapipe = &update_mode_pipe,
.output_cb = tklock_datapipe_update_mode_cb,
},
{
.datapipe = &device_lock_active_pipe,
.output_cb = tklock_datapipe_device_lock_active_cb,
Expand Down Expand Up @@ -3406,6 +3437,10 @@ static void tklock_ui_set(bool enable)
mce_log(LL_INFO, "deny tklock; lipstick not running");
enable = false;
}
else if( update_mode ) {
mce_log(LL_INFO, "deny tklock; os update in progress");
enable = false;
}
}

if( tklock_ui_sent != enable ) {
Expand Down

0 comments on commit 12db936

Please sign in to comment.