Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[devicelock] Fix bug related to secondary device lock check
Due to the secondary device lock check the mode was always undefined
and charging mode not correctly set. Luckily the kernel fallback
of the charging driver kicks in, which is why this went unnoticed.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Aug 26, 2014
1 parent a0d0d76 commit b3e7e25
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
10 changes: 6 additions & 4 deletions src/usb_moded-devicelock.c
Expand Up @@ -141,10 +141,12 @@ static DBusHandlerResult devicelock_unlocked_cb(DBusConnection *conn, DBusMessag
if(ret == 0 && get_usb_connection_state() == 1 )
{
log_debug("usb_mode %s\n", get_usb_mode());
/* if the mode is MODE_CHARGING_FALLBACK we know the user has not selected any mode */
if(!strcmp(get_usb_mode(), MODE_UNDEFINED) || !strcmp(get_usb_mode(), MODE_CHARGING)) {
log_debug("set_usb");
set_usb_connected_state();
/* if the mode is MODE_CHARGING_FALLBACK we know the user has not selected any mode, in case it
things are still undefined it cannot hurt to try again to set a mode */
if(!strcmp(get_usb_mode(), MODE_UNDEFINED) || !strcmp(get_usb_mode(), MODE_CHARGING_FALLBACK))
{
log_debug("set_usb");
set_usb_connected_state();
}
}
}
Expand Down
42 changes: 24 additions & 18 deletions src/usb_moded.c
Expand Up @@ -303,27 +303,13 @@ void set_usb_mode(const char *mode)
/* set return to 1 to be sure to error out if no matching mode is found either */
int ret=1, net=0;


#ifdef MEEGOLOCK
/* Do a second check in case timer suspend causes a race issue */
int export = 1;
#endif

/* check if we are allowed to export system contents 0 is unlocked */
/* In ACTDEAD export is always ok */
if(is_in_user_state())
{
export = usb_moded_get_export_permission();

if(export && strcmp(mode, MODE_CHARGING) && !rescue_mode)
{
log_debug("Secondary device lock check failed. Not setting mode!\n");
goto end;
}
}
#endif /* MEEGOLOCK */

log_debug("Setting %s\n", mode);

/* CHARGING AND FALLBACK CHARGING are always ok to set, so this can be done
before the optional second device lock check */
if(!strcmp(mode, MODE_CHARGING) || !strcmp(mode, MODE_CHARGING_FALLBACK))
{
check_module_state(MODULE_MASS_STORAGE);
Expand All @@ -340,7 +326,27 @@ void set_usb_mode(const char *mode)
charging_mode_set = TRUE;
goto end;
}
else if(!strcmp(mode, MODE_ASK) || !strcmp(mode, MODE_CHARGER))

#ifdef MEEGOLOCK
/* check if we are allowed to export system contents 0 is unlocked */
/* In ACTDEAD export is always ok */
if(is_in_user_state())
{
export = usb_moded_get_export_permission();

if(export && !rescue_mode)
{
log_debug("Secondary device lock check failed. Not setting mode!\n");
goto end;
}
}
#endif /* MEEGOLOCK */

log_debug("Setting %s\n", mode);

/* nothing needs to be done for these modes, apart from the
signalling at the end */
if(!strcmp(mode, MODE_ASK) || !strcmp(mode, MODE_CHARGER))
{
ret = 0;
goto end;
Expand Down

0 comments on commit b3e7e25

Please sign in to comment.