Skip to content
Permalink
Browse files
[usb-moded] Use MEEGOLOCK features only when enabled. Fixes MER#1765
The is_in_user_state() is used unconditionally, but it is available only
when --enable-meegodevlock option has been passed to configure. Also,
the related "usb_moded-dsme.h" is included both unconditionally and from
withing a #ifdef MEEGOLOCK block - which hides the configuration problem
until build proceeds to linking phase.

Make the call is_in_user_state() only if MEEGOLOCK is defined.

Remove the extraneous "usb_moded-dsme.h" include to make such errors
visible already in compilation stage due to missing prototypes.

Also, make sure the "usb_moded-dsme.h" can't be included without
warnings unless MEEGOLOCK is defined.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 13, 2017
1 parent 3b81d0f commit 04e3a75315d667c1e62cef3f48d23b3362bae39a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
@@ -21,6 +21,10 @@
02110-1301 USA
*/

#ifndef MEEGOLOCK
# warning usb_moded-dsme.h included without enabling MEEGOLOCK
#endif

gboolean is_in_user_state(void);
gboolean dsme_listener_start(void);
void dsme_listener_stop(void);
@@ -32,13 +32,13 @@
#include <signal.h>

#include <libkmod.h>

#ifdef SYSTEMD
#include <systemd/sd-daemon.h>
#endif

#include "usb_moded.h"
#include "usb_moded-modes.h"
#include "usb_moded-dsme.h"
#include "usb_moded-dbus.h"
#include "usb_moded-dbus-private.h"
#include "usb_moded-hw-ab.h"
@@ -55,6 +55,7 @@
#include "usb_moded-mac.h"
#include "usb_moded-android.h"
#include "usb_moded-systemd.h"

#ifdef MEEGOLOCK
#include "usb_moded-dsme.h"
#endif
@@ -280,10 +281,12 @@ rethink_usb_charging_fallback(void)

/* Device must be in USER state or in rescue mode
*/
#ifdef MEEGOLOCK
if( !is_in_user_state() && !rescue_mode ) {
log_notice("device is not in USER mode; stay in %s", usb_mode);
goto EXIT;
}
#endif

log_debug("attempt to leave %s", usb_mode);
set_usb_connected_state();

0 comments on commit 04e3a75

Please sign in to comment.