From c56e1f473991f363078557c9c1bc2600eaf0fcb1 Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Mon, 1 Apr 2024 13:49:26 +0200 Subject: [PATCH] iface-modem-location: fix zeroing capabilities on reinitialization The modem location interface loads modem location capabilities only during the very first initialization of this interface. On each later reinitialization it skips loading these capabilities from modem, however it still goes through the whole interface initialization state machine. This state machine uses its own "ctx->capabilities" field for temporary capabilities storage, which is set to MM_MODEM_LOCATION_SOURCE_NONE at the start of the initialization process. However, if we aren't actually loading modem location capabilities because we're only reinitializing the interface we still need to set this "ctx->capabilities" field to the existing (previously loaded) modem location capabilities. Otherwise the next interface initialization step (validation) will permanently disable the whole location interface. --- src/mm-iface-modem-location.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mm-iface-modem-location.c b/src/mm-iface-modem-location.c index 8fe374ef..8867a501 100644 --- a/src/mm-iface-modem-location.c +++ b/src/mm-iface-modem-location.c @@ -1746,6 +1746,7 @@ interface_initialization_step (GTask *task) { MMIfaceModemLocation *self; InitializationContext *ctx; + MMModemLocationSource existing_capabilities; /* Don't run new steps if we're cancelled */ if (g_task_return_error_if_cancelled (task)) { @@ -1765,8 +1766,10 @@ interface_initialization_step (GTask *task) /* Location capabilities value is meant to be loaded only once during * the whole lifetime of the modem. Therefore, if we already have it * loaded, don't try to load it again. */ - if (!mm_gdbus_modem_location_get_capabilities (ctx->skeleton) && - MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self)->load_capabilities && + existing_capabilities = mm_gdbus_modem_location_get_capabilities (ctx->skeleton); + if (existing_capabilities != MM_MODEM_LOCATION_SOURCE_NONE) { + ctx->capabilities = existing_capabilities; + } else if (MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self)->load_capabilities && MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self)->load_capabilities_finish) { MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self)->load_capabilities ( self,