Skip to content
Permalink
Browse files
[charging fallback] introduce charging fallback mode. Fixes JB#22320
Identify if we fell back to charging or it was a user conscious decision.
This helps us to know if we should set a mode if the device lock gets
unlocked or not.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Aug 26, 2014
1 parent 907513c commit 147dcc5b83a8665e6a2370b1978ac20958d718b7
Showing with 12 additions and 8 deletions.
  1. +1 −0 src/usb_moded-devicelock.c
  2. +1 −0 src/usb_moded-modes.h
  3. +1 −1 src/usb_moded-modesetting.c
  4. +9 −7 src/usb_moded.c
@@ -140,6 +140,7 @@ 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();
@@ -24,6 +24,7 @@
#define MODE_MASS_STORAGE "mass_storage"
#define MODE_OVI_SUITE "ovi_suite"
#define MODE_CHARGING "charging_only"
#define MODE_CHARGING_FALLBACK "charging_only_fallback"
#define MODE_UNDEFINED "undefined"
#define MODE_ASK "ask"
#define MODE_DEVELOPER "developer_mode"
@@ -533,7 +533,7 @@ int usb_moded_mode_cleanup(const char *module)
{
/* no clean-up needs to be done when we come from charging mode. We need
to check since we use fake mass-storage for charging */
if(!strcmp(MODE_CHARGING, get_usb_mode()))
if(!strcmp(MODE_CHARGING, get_usb_mode()) || !strcmp(MODE_CHARGING_FALLBACK, get_usb_mode()))
return 0;
unset_mass_storage_mode(NULL);
}
@@ -158,7 +158,8 @@ static gboolean set_disconnected(gpointer data)
/* signal usb disconnected */
usb_moded_send_signal(USB_DISCONNECTED);
/* unload modules and general cleanup if not charging */
if(strcmp(get_usb_mode(), MODE_CHARGING))
if(strcmp(get_usb_mode(), MODE_CHARGING) ||
strcmp(get_usb_mode(), MODE_CHARGING_FALLBACK))
usb_moded_mode_cleanup(get_usb_module());
/* Nothing else as we do not need to do anything for cleaning up charging mode */
usb_moded_module_cleanup(get_usb_module());
@@ -177,7 +178,8 @@ if(!get_usb_connection_state())
{
log_debug("Resetting connection data after HUP\n");
/* unload modules and general cleanup if not charging */
if(strcmp(get_usb_mode(), MODE_CHARGING))
if(strcmp(get_usb_mode(), MODE_CHARGING) ||
strcmp(get_usb_mode(), MODE_CHARGING_FALLBACK))
usb_moded_mode_cleanup(get_usb_module());
/* Nothing else as we do not need to do anything for cleaning up charging mode */
usb_moded_module_cleanup(get_usb_module());
@@ -285,7 +287,7 @@ void set_usb_connected_state(void)
We also fall back here in case the device is locked and we do not
export the system contents. Or if we are in acting dead mode.
*/
set_usb_mode(MODE_CHARGING);
set_usb_mode(MODE_CHARGING_FALLBACK);
}
end:
free((void *)mode_to_set);
@@ -322,7 +324,7 @@ void set_usb_mode(const char *mode)

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

if(!strcmp(mode, MODE_CHARGING))
if(!strcmp(mode, MODE_CHARGING) || !strcmp(mode, MODE_CHARGING_FALLBACK))
{
check_module_state(MODULE_MASS_STORAGE);
/* for charging we use a fake file_storage (blame USB certification for this insanity */
@@ -394,8 +396,8 @@ void set_usb_mode(const char *mode)
int valid_mode(const char *mode)
{

/* MODE_ASK and MODE_CHARGER are not modes that are settable seen their special status */
if(!strcmp(MODE_CHARGING, mode))
/* MODE_ASK and MODE_CHARGER_FALLBACK are not modes that are settable seen their special status */
if(!strcmp(MODE_CHARGING_FALLBACK, mode))
return(0);
else
{
@@ -580,7 +582,7 @@ static gboolean charging_fallback(gpointer data)
if(strcmp(get_usb_mode(), MODE_ASK) != 0)
return FALSE;

set_usb_mode(MODE_CHARGING);
set_usb_mode(MODE_CHARGING_FALLBACK);
/* since this is the fallback, we keep an indication
for the UI, as we are not really in charging mode.
*/

0 comments on commit 147dcc5

Please sign in to comment.