Skip to content
Permalink
Browse files
[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 b3e7e259fe0b8b5a80580b4c033db368358b5970
Showing with 30 additions and 22 deletions.
  1. +6 −4 src/usb_moded-devicelock.c
  2. +24 −18 src/usb_moded.c
@@ -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();
}
}
}
@@ -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);
@@ -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;

0 comments on commit b3e7e25

Please sign in to comment.