aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-06-27 10:28:16 +0200
committerAleksander Morgado <aleksander@aleksander.es>2014-07-02 12:28:56 +0200
commitad67d68179263355510306c500f31a4d7f8cd87d (patch)
treea546b9790e9946db151cd35e2d6fd7a517e3a874 /src
parent915a5beac0e10b0246adc9eefdb2dc29eb2c071e (diff)
location: new 'unmanaged' GPS setup
Standard GPS setup (raw/nmea) will both enable the GPS module and take full control of the GPS port. This prevents other processes from reading the NMEA traces from e.g. a tty. In order to handle this, a new 'unmanaged' GPS location source is introduced, which will just enable/disable the GPS module, without reading anything from the GPS port. Of course, both raw/nmea and unmanaged setups cannot be enabled at the same time.
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem-location.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/mm-iface-modem-location.c b/src/mm-iface-modem-location.c
index 32f9a731..57d5f2c1 100644
--- a/src/mm-iface-modem-location.c
+++ b/src/mm-iface-modem-location.c
@@ -137,6 +137,8 @@ build_location_dictionary (GVariant *previous,
case MM_MODEM_LOCATION_SOURCE_CDMA_BS:
location_cdma_bs_value = value;
break;
+ case MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED:
+ g_assert_not_reached ();
default:
g_warn_if_reached ();
break;
@@ -505,6 +507,8 @@ update_location_source_status (MMIfaceModemLocation *self,
} else
g_clear_object (&ctx->location_cdma_bs);
break;
+ case MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED:
+ /* Nothing to setup in the context */
default:
break;
}
@@ -612,7 +616,7 @@ setup_gathering_step (SetupGatheringContext *ctx)
return;
}
- while (ctx->current <= MM_MODEM_LOCATION_SOURCE_CDMA_BS) {
+ while (ctx->current <= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED) {
gchar *source_str;
if (ctx->to_enable & ctx->current) {
@@ -709,7 +713,7 @@ setup_gathering (MMIfaceModemLocation *self,
/* Loop through all known bits in the bitmask to enable/disable specific location sources */
for (source = MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI;
- source <= MM_MODEM_LOCATION_SOURCE_CDMA_BS;
+ source <= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED;
source = source << 1) {
/* skip unsupported sources */
if (!(mm_gdbus_modem_location_get_capabilities (ctx->skeleton) & source))
@@ -734,6 +738,22 @@ setup_gathering (MMIfaceModemLocation *self,
g_free (str);
}
+ /* When standard GPS retrieval (RAW/NMEA) is enabled, we cannot enable the
+ * UNMANAGED setup, and viceversa. */
+ if ((ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED &&
+ currently_enabled & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA)) ||
+ (ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) &&
+ currently_enabled & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED) ||
+ (ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) &&
+ ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Cannot have both unmanaged GPS and raw/nmea GPS enabled at the same time");
+ setup_gathering_context_complete_and_free (ctx);
+ return;
+ }
+
if (ctx->to_enable != MM_MODEM_LOCATION_SOURCE_NONE) {
str = mm_modem_location_source_build_string_from_mask (ctx->to_enable);
mm_dbg ("Need to enable the following location sources: '%s'", str);
@@ -1162,7 +1182,9 @@ interface_enabling_step (EnablingContext *ctx)
/* By default, we'll enable all NON-GPS sources */
default_sources = mm_gdbus_modem_location_get_capabilities (ctx->skeleton);
- default_sources &= ~(MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA);
+ default_sources &= ~(MM_MODEM_LOCATION_SOURCE_GPS_RAW |
+ MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
+ MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED);
setup_gathering (ctx->self,
default_sources,