Merge remote-tracking branch 'cros/upstream' into 'cros/master'

Change-Id: Iafe8a576dfcdf6f70c6f2d0c0905504c0b076283
diff --git a/NEWS b/NEWS
index 81f2702..eaa7b36 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,123 @@
 
+ModemManager 1.10.0
+-------------------------------------------
+This is a new stable release of ModemManager.
+
+The following notes are directed to package maintainers:
+
+ * This version requires:
+   ** libmbim >= 1.18.0 (for the optional MBIM support)
+   ** libqmi >= 1.22.0 (for the optional QMI support)
+
+The most important features and changes in this release are the following:
+
+ * udev:
+   ** Consolidated common tag names among all the supported plugins. E.g.
+      ID_MM_PORT_TYPE_GPS, ID_MM_PORT_TYPE_AT_*, ID_MM_PORT_TYPE_QCDM...
+      All these generic tags are included as symbols in the API, and
+      compatibility will be maintained for these. Custom setups of
+      ModemManager relying on previously available per-plugin udev tags may
+      need to manually port them to this new generic subset.
+   ** New tag to allow specifying flow control settings to use in serial ports.
+
+ * Core:
+   ** Avoid probing other protocols on TTYs tagged in udev with specific port
+      type tags (e.g. avoid probing QCDM if a port is tagged as AT). This allows
+      faster port probing and modem detection for known modem layouts.
+   ** Implemented support to enable and handle +CGEV URCs for asynchronous
+      connection state updates in AT-controlled devices.
+
+ * Manager interface:
+   ** New runtime daemon version reporting.
+   ** New support for requesting device inhibition, e.g. so that ModemManager
+      stops completely using a modem device until the inhibition is released.
+      This feature is implemented to allow fwupd taking over of a device
+      completely for as long as it needs during a firmware update.
+
+ * Modem interface:
+   ** All methods are always connected, even in Failed state.
+   ** Allow parallel Enable()/Disable() calls.
+   ** Deprecated redundant ListBearers() method, the read-only Bearers property
+      is already showing the same information.
+
+ * Bearer interface:
+   ** New 'BearerType' property, e.g. to specify whether a bearer is the initial
+      LTE default bearer or not.
+   ** Deprecated 'number' field in bearer settings. Applications do not need to
+      send the 'number' field in Bearer.Connect() or in Modem.Simple.Connect(),
+      as the setting is totally ignored.
+
+ * mmcli:
+   ** New 'key-value' output, easier to parse by scripts than the default.
+   ** Removed redundant '--location-get-XXX' actions, as the '--location-get'
+      already reports the location information for all sources.
+   ** Removed redundant '--simple-status' action, as the same information can be
+      obtained through different mmcli operations.
+   ** New manager '--inhibit-device' action and modem-specific '--inhibit', to
+      allow requesting device inhibition.
+
+ * 3GPP interface:
+   ** New support for exposing the network reported Protocol Configuration
+      Options (PCO), to be used instead of the new deprecated Subscription
+      State property.
+   ** New support for exposing the initial LTE default bearer status.
+   ** New support for configuring the initial LTE default bearer settings.
+
+ * Location interface:
+   ** New LTE Tracking Area Code (TAC) in 3GPP location information.
+   ** New support for injecting assistance data (e.g. Qualcomm XTRA) into the
+      GNSS engine, useful when there is no mobile connection to use MSA A-GPS.
+
+ * Firmware interface:
+   ** Support for reporting firmware update support properties, e.g. specifying
+      which update methods are supported. This information will be consumed by
+      fwupd in order to allow upgrading firmware in devices managed by
+      ModemManager.
+
+ * Voice interface:
+   ** Multiple improvements and fixes in the voice call management logic
+      implemented with generic AT commands.
+   ** Added AudioPort and AudioFormat properties to the Call object.
+   ** Added new generic audio channel setup/cleanup handlers in the Call object.
+
+ * QMI:
+   ** New LOC service based GNSS support, including A-GPS setup via SUPL server.
+   ** New support for the "extended" LTE band list.
+   ** New support for reading IMSI and ICCID with the UIM service.
+
+ * MBIM:
+   ** Implemented support for processing Protocol Configuration Options using
+      Microsoft-defined Basic Connect Extensions.
+   ** Implemented support for LTE attach status and configuration using
+      Microsoft-defined Basic Connect Extensions.
+   ** Implemented support for the extended signal interface and for 3GPP location
+      details using the AT&T specific service.
+   ** Implemented support for 3GPP USSD operations using the standard USSD
+      service.
+   ** For Qualcomm-based MBIM devices, those with QMI-over-MBIM support, a whole
+      new set of features is now available, including: QMI LOC/PDS location
+      support, allowed/preferred mode management, frequency band selection,
+      power management operations...
+
+ * Plugins:
+   ** xmm: new XMM plugin, with shared logic (allowed/preferred mode management,
+      frequency band selection, power management operations, extended signal
+      quality reporting, GPS/A-GPS...) for Intel XMM based devices.
+   ** fibocom: new plugin, with support for generic MBIM and XMM-based devices.
+   ** dell: added support for XMM-based devices, like the DW5820e.
+   ** dell: added custom support for the DW5821e, including 'unmanaged' GPS and
+      firmware update integration details.
+   ** cinterion: new shared interface to include all logic shared between Option
+      and Option/HSO devices.
+   ** sierra-legacy: implemented connection monitoring support.
+   ** u-blox: added support for extended call state transitions.
+   ** u-blox: added CDC-ECM support for SARA/LISA-U2xx modems.
+   ** altair-lte: migrated from SubscriptionState to PCO.
+
+All the features and fixes which were backported to 1.8.x releases are also present
+in ModemManager 1.10.0.
+
+
 ModemManager 1.8.0
 -------------------------------------------
 This is a new stable release of ModemManager.
diff --git a/cli/mmcli-modem-firmware.c b/cli/mmcli-modem-firmware.c
index 9bff170..48d0862 100644
--- a/cli/mmcli-modem-firmware.c
+++ b/cli/mmcli-modem-firmware.c
@@ -159,13 +159,8 @@
             version = mm_firmware_update_settings_get_version (update_settings);
         }
 
-        switch (m) {
-        case MM_MODEM_FIRMWARE_UPDATE_METHOD_FASTBOOT:
+        if (m & MM_MODEM_FIRMWARE_UPDATE_METHOD_FASTBOOT)
             fastboot_at = mm_firmware_update_settings_get_fastboot_at (update_settings);
-            break;
-        default:
-            break;
-        }
     }
 
     /* There's not much to print in this status info, and if the modem
@@ -180,10 +175,10 @@
         exit (EXIT_FAILURE);
     }
 
-    mmcli_output_string_take  (MMC_F_FIRMWARE_METHOD,      method);
-    mmcli_output_string_array (MMC_F_FIRMWARE_DEVICE_IDS,  device_ids, TRUE);
-    mmcli_output_string       (MMC_F_FIRMWARE_VERSION,     version);
-    mmcli_output_string       (MMC_F_FIRMWARE_FASTBOOT_AT, fastboot_at);
+    mmcli_output_string_list_take (MMC_F_FIRMWARE_METHOD,      method);
+    mmcli_output_string_array     (MMC_F_FIRMWARE_DEVICE_IDS,  device_ids, TRUE);
+    mmcli_output_string           (MMC_F_FIRMWARE_VERSION,     version);
+    mmcli_output_string           (MMC_F_FIRMWARE_FASTBOOT_AT, fastboot_at);
     mmcli_output_dump ();
 }
 
diff --git a/cli/mmcli.c b/cli/mmcli.c
index 80b9e65..6953672 100644
--- a/cli/mmcli.c
+++ b/cli/mmcli.c
@@ -138,7 +138,7 @@
 {
     g_print ("\n"
              PROGRAM_NAME " " PROGRAM_VERSION "\n"
-             "Copyright (2011 - 2016) Aleksander Morgado\n"
+             "Copyright (2011 - 2019) Aleksander Morgado\n"
              "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>\n"
              "This is free software: you are free to change and redistribute it.\n"
              "There is NO WARRANTY, to the extent permitted by law.\n"
diff --git a/configure.ac b/configure.ac
index 1fcb9c3..94140df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,8 +5,8 @@
 dnl
 
 m4_define([mm_major_version], [1])
-m4_define([mm_minor_version], [9])
-m4_define([mm_micro_version], [990])
+m4_define([mm_minor_version], [10])
+m4_define([mm_micro_version], [0])
 m4_define([mm_version],
           [mm_major_version.mm_minor_version.mm_micro_version])
 
@@ -18,9 +18,9 @@
 dnl            with old code), increment a.
 dnl        If the interface has changed in an incompatible way (that is,
 dnl            functions have changed or been removed), then zero a.
-m4_define([mm_glib_lt_current],  [3])
+m4_define([mm_glib_lt_current],  [4])
 m4_define([mm_glib_lt_revision], [0])
-m4_define([mm_glib_lt_age],      [3])
+m4_define([mm_glib_lt_age],      [4])
 
 dnl-----------------------------------------------------------------------------
 dnl autoconf, automake, libtool initialization
diff --git a/docs/man/mmcli.1 b/docs/man/mmcli.1
index ddb2a4e..cb00f32 100644
--- a/docs/man/mmcli.1
+++ b/docs/man/mmcli.1
@@ -80,8 +80,13 @@
 
 .SH MANAGER OPTIONS
 .TP
+.B \-B, \-\-get\-daemon\-version
+Retrieve the version of the currently running ModemManager daemon.
+.TP
 .B \-G, \-\-set\-logging=[ERR|WARN|INFO|DEBUG]
-Set the logging level in ModemManager daemon. For debugging information you can supply \fBDEBUG\fR. Each value above \fBDEBUG\fR provides less detail. In most cases \fBERR\fR (for displaying errors) are the important messages.
+Set the logging level in ModemManager daemon. For debugging information you can
+supply \fBDEBUG\fR. Each value above \fBDEBUG\fR provides less detail. In most
+cases \fBERR\fR (for displaying errors) are the important messages.
 
 The default mode is \fBERR\fR.
 .TP
@@ -94,6 +99,53 @@
 .B \-S, \-\-scan-modems
 Scan for any potential new modems. This is only useful when expecting pure
 RS232 modems, as they are not notified automatically by the kernel.
+.TP
+.B \-I, \-\-inhibit\-device=[UID]
+Inhibit the specific device from being used by ModemManager. The \fBUID\fR
+that should be given is the value of the \fBDevice\fR property exposed by
+a given modem (i.e. equal to the \fBID_MM_PHYSDEV_UID\fR if one set, or
+otherwise equal to the full device sysfs path).
+
+This command will not exit right away, as that would implicitly remove the
+inhibition. The user must make sure to stop the mmcli process hitting Ctrl+C
+in order to un-inhibit the device.
+
+When a device is inhibited via this method, ModemManager will disable the modem
+(therefore stopping any ongoing connection) and will no longer use it until it
+is uninhibited.
+.TP
+.B \-\-report\-kernel\-event=['KEY1=VALUE1,KEY2=VALUE2,...']
+Manually report kernel events, instead of relying on udev (e.g. if the daemon
+is running with \fB\-\-no\-auto\-scan\fR or if the system was built without udev
+support).
+
+The supported \fBKEY\fRs are:
+.RS 9
+.TP
+\fB'action'\fR
+Action to report, one of 'add' or 'remove'. Required.
+.TP
+\fB'subsystem'\fR
+Subsystem of the specific port being reported, e.g. 'tty' (for serial ports),
+'net' (for network interfaces), or 'usbmisc' (for cdc-wdm ports)..
+.TP
+\fB'name'\fR
+Name of the port being reported, e.g. 'ttyACM0', 'wwan0' or 'cdc-wdm0'.
+.TP
+\fB'uid'\fR
+The specific UID of the device, equivalent to the \fBID_MM_PHYSDEV_UID\fR udev
+tag. All ports reported with the same 'UID' value will be considered part of the
+same device, which may be useful for e.g. modems with multiple platform TTYs.
+.RE
+
+.TP
+.B \-\-report\-kernel\-event\-auto\-scan
+When built with udev support but the daemon is running with
+\fB\-\-no\-auto\-scan\fR, this method may be used to automatically report kernel
+events based on udev.
+
+This command will not exit right away. The user must make sure to stop the mmcli
+process hitting Ctrl+C in order to stopping monitoring for new events.
 
 .SH COMMON OPTIONS
 All options below take a \fBPATH\fR or \fBINDEX\fR argument. If no action is
@@ -210,15 +262,19 @@
 Telephone number to dial. Required in POTS.
 .RE
 .TP
-.B \-\-delete\-bearer=PATH
-Delete bearer from a given modem. This option explicitly uses a
-\fBPATH\fR to define the bearer, you can not use an \fBINDEX\fR to be
-deleted.
+.B \-\-delete\-bearer=[PATH|INDEX]
+Delete bearer from a given modem.
 .TP
 .B \-\-set\-allowed\-modes=[MODE1|MODE2|...]
 Set allowed modes for a given modem. For possible modes, see the
 beginning of this section.
 .TP
+.B \-\-set\-preferred\-mode=MODE
+Set the preferred \fBMODE\fR for the given modem. The \fBMODE\fR
+\fIMUST\fR be one of the allowed modes as set with the
+\fB\-\-set\-allowed\-modes\fR option. Possible \fBMODE\fR arguments
+are detailed at the beginning of this section.
+.TP
 .B \-\-set\-current\-bands=[BAND1|BAND2|...]
 Set bands to be used for a given modem. These are frequency ranges
 the modem should use. There are quite a number of supported bands and
@@ -228,11 +284,19 @@
 An example would be: 'egsm|dcs|pcs|g850' to select all the GSM
 frequency bands.
 .TP
-.B \-\-set\-preferred\-mode=MODE
-Set the preferred \fBMODE\fR for the given modem. The \fBMODE\fR
-\fIMUST\fR be one of the allowed modes as set with the
-\fB\-\-set\-allowed\-modes\fR option. Possible \fBMODE\fR arguments
-are detailed at the beginning of this section.
+.B \-\-inhibit
+Inhibit the specific modem from being used by ModemManager. This method
+is completely equivalent to \fB\-\-inhibit\-device\fR, with the only
+difference being that in this case, the modem must be managed by the daemon
+at the time the inhibition is requested.
+
+This command will not exit right away, as that would implicitly remove the
+inhibition. The user must make sure to stop the mmcli process hitting Ctrl+C
+in order to un-inhibit the device.
+
+When a device is inhibited via this method, ModemManager will disable the modem
+(therefore stopping any ongoing connection) and will no longer use it until it
+is uninhibited.
 
 .SH 3GPP OPTIONS
 The 3rd Generation Partnership Project (3GPP) is a collaboration
@@ -305,9 +369,6 @@
 .TP
 .B \-\-simple\-disconnect
 Disconnect \fIALL\fR connected bearers for a given modem.
-.TP
-.B \-\-simple\-status
-Display the status of the given modem.
 
 .SH LOCATION OPTIONS
 These options detail how to discover your location using Global
@@ -329,27 +390,38 @@
 .B \-\-location\-disable\-3gpp
 Disable location discovery using the 3GPP network.
 .TP
-.B \-\-location\-get\-3gpp
-Show 3GPP based location information (MCC, MNC, LAC, CI).
+.B \-\-location\-enable\-agps
+Enable A-GPS (MSA) support. This command does not implicitly start the GPS
+engine, it just specifies that A-GPS should be enabled when the engine is
+started. Therefore, the user should request enabling A-GPS before the raw
+or NMEA outputs are enabled with \fB\-\-location\-enable\-gps\-raw\fR or
+\fB\-\-location\-enable\-gps\-nmea\fR.
+.TP
+.B \-\-location\-disable\-agps
+Disable A-GPS (MSA) support.
 .TP
 .B \-\-location\-enable\-gps\-nmea
 Enable location discovery using GPS and reported with NMEA traces.
+
+This command will start the GPS engine, if it isn't started already.
 .TP
 .B \-\-location\-disable\-gps\-nmea
 Disable location discovery using GPS and NMEA traces.
-.TP
-.B \-\-location\-get\-gps\-nmea
-Show GPS based location with NMEA trace information.
+
+If the raw output is not enabled at the same time, the GPS engine will be
+stopped.
 .TP
 .B \-\-location\-enable\-gps\-raw
 Enable location discovery using GPS and reported with raw (i.e.
 longitude/latitude) values.
+
+This command will start the GPS engine, if it isn't started already.
 .TP
 .B \-\-location\-disable\-gps\-raw
 Disable location discovery using GPS and raw values.
-.TP
-.B \-\-location\-get\-gps\-raw
-Show GPS based location information with raw values (e.g. latitude, longitude).
+
+If the NMEA output is not enabled at the same time, the GPS engine will be
+stopped.
 .TP
 .B \-\-location\-enable\-cdma-bs
 Enable location discovery using the 3GPP2 network.
@@ -357,12 +429,10 @@
 .B \-\-location\-disable\-cdma-bs
 Disable location discovery using the 3GPP2 network.
 .TP
-.B \-\-location\-get\-cdma-bs
-Show 3GPP2 based location information (location of the CDMA base station).
-.TP
 .B \-\-location\-enable\-gps\-unmanaged
 Enable location discovery using GPS but without taking control of the NMEA tty
-port.
+port. This allows other programs, e.g. gpsd, to use the NMEA tty once the GPS
+engine has been enabled.
 .TP
 .B \-\-location\-disable\-gps\-unmanaged
 Disable location discovery using GPS and unmanaged port.
@@ -371,6 +441,26 @@
 Set the location refresh rate on the DBus interface to SEC seconds. If set to
 0, the new location is published on the DBus interface as soon as ModemManager
 detects it.
+.TP
+.B \-\-location\-set\-supl\-server=[IP:PORT] or \-\-location\-set\-supl\-server=[FQDN:PORT]
+Configure the location of the A\-GPS SUPL server, either specifying the IP
+address (\fBIP:PORT\fR) or specifyng a fully qualified domain name
+(\fB[FQDN:PORT]\fR).
+.TP
+.B \-\-location\-inject\-assistance\-data=[PATH]
+Inject assistance data into the GNSS module, loaded from a local file at
+\fBPATH\fR. The assistance data should be in a format expected by the device,
+e.g. downloaded from the URLs exposed by the 'AssistanceDataServers' property.
+.TP
+.B \-\-location\-set\-enable\-signal
+Enable reporting location updates via DBus property signals. This is
+required if applications rely on listening to 'Location' property updates,
+instead of explicit queries with the policy-protected 'GetLocation' method.
+
+This DBus property signal updates are by default disabled.
+.TP
+.B \-\-location\-set\-disable\-signal
+Disable reporting location updates via DBus property signals.
 
 .SH MESSAGING OPTIONS
 All messaging options must be used with \fB\-\-modem\fR or \fB\-m\fR.
@@ -413,11 +503,11 @@
 be 'sm', 'me', 'mt', 'sr', 'bm', 'ta'.
 .RE
 .TP
-.B \-\-messaging\-create-sms-with-data=PATH
+.B \-\-messaging\-create\-sms\-with\-data=PATH
 Use \fBPATH\fR to a filename as the data to create a new SMS.
 .TP
-.B \-\-messaging\-delete-sms=PATH
-Delete an SMS from a given modem. \fBPATH\fR indicates the SMS path.
+.B \-\-messaging\-delete\-sms=[PATH|INDEX]
+Delete an SMS from a given modem.
 
 .SH TIME OPTIONS
 All time operations require the \fB\-\-modem\fR or \fB\-m\fR option.
@@ -427,10 +517,32 @@
 Display the current network time from the operator. This includes the
 timezone which is usually of importance.
 
+.SH VOICE OPTIONS
+All voice operations require the \fB\-\-modem\fR or \fB\-m\fR option.
+
+.TP
+.B \-\-voice\-list\-calls
+List calls managed (initiated, received, ongoing) on a given modem.
+.TP
+.B \-\-voice\-create-call=['KEY1=VALUE1,...']
+Create a new outgoing call on a given modem. \fBKEY\fRs can be any of the
+following:
+.RS 9
+.TP
+\fB'number'\fR
+Number to call.
+.RE
+.TP
+.B \-\-voice\-delete\-call=[PATH|INDEX]
+Delete a call from a given modem.
+
 .SH FIRMWARE OPTIONS
 All firmware options require the \fB\-\-modem\fR or \fB\-m\fR option.
 
 .TP
+.B \-\-firmware\-status
+Show firmware update specific details and properties.
+.TP
 .B \-\-firmware\-list
 List all the firmware images installed on a given modem.
 .TP
@@ -441,6 +553,19 @@
 
 The \fBID\fR provided is a \fIUNIQUE\fR identifier for the firmware.
 
+.SH SIGNAL OPTIONS
+All signal options require the \fB\-\-modem\fR or \fB\-m\fR option.
+
+.TP
+.B \-\-signal\-setup=[Rate]
+Setup extended signal quality information retrieval at the specified rate
+(in seconds).
+
+By default this is disabled (rate set to 0).
+.TP
+.B \-\-signal\-get
+Retrieve the last extended signal quality information loaded.
+
 .SH OMA OPTIONS
 All OMA options require the \fB\-\-modem\fR or \fB\-m\fR option.
 
@@ -539,8 +664,26 @@
 create a local file described by \fBPATH\fR and store the content of
 the SMS there.
 
+.SH CALL OPTIONS
+.TP
+.B \-\-start
+Initiate an outgoing call.
+.TP
+.B \-\-accept
+Accept an incoming call.
+.TP
+.B \-\-hangup
+Reject an incoming call or hangup an ongoing one.
+.TP
+.B \-\-send\-dtmf=[0\-9A\-D*#]
+Send a DTMF sequence through an ongoing call.
+
 .SH APPLICATION OPTIONS
 .TP
+.B \-K, \-\-output\-keyvalue
+Run action with machine-friendly key-value output, to be used e.g. by
+shell scripts that rely on mmcli operations.
+.TP
 .B \-v, \-\-verbose
 Perform actions with more details reported and/or logged.
 .TP
@@ -554,7 +697,7 @@
 .B \-\-timeout=SECONDS
 Use \fBSECONDS\fR for the timeout when performing operations with this
 command. This option is useful when executing long running operations, like
-\-\-3gpp\-scan.
+\fB\-\-3gpp\-scan\fR.
 
 .SH EXAMPLES
 .SS Send the PIN to the SIM card
@@ -562,13 +705,13 @@
 You'll need first to know which the proper path/index is for the SIM in your
 modem:
 .Bd -literal -compact
-    $ mmcli -m 0 | grep SIM
-    SIM | path: '/org/freedesktop/ModemManager1/SIM/0'
+    $ mmcli -m 0 -K | grep "modem.generic.sim" | awk -F ": " '{ print $2 }'
+    /org/freedesktop/ModemManager1/SIM/0
 .Ed
 
 And after that, you can just use the SIM index:
 .Bd -literal -compact
-    $ mmcli -i 0 --pin=1234
+    $ sudo mmcli -i 0 --pin=1234
     successfully sent PIN code to the SIM
 .Ed
 
@@ -576,13 +719,13 @@
 
 You can launch the simple connection process like:
 .Bd -literal -compact
-    $ mmcli -m 0 --simple-connect="pin=1234,apn=internet"
+    $ sudo mmcli -m 0 --simple-connect="pin=1234,apn=internet"
     successfully connected the modem
 .Ed
 
 Then, you can disconnect it like:
 .Bd -literal -compact
-    $ mmcli -m 0 --simple-disconnect
+    $ sudo mmcli -m 0 --simple-disconnect
     successfully disconnected all bearers in the modem
 .Ed
 
@@ -591,13 +734,12 @@
 Scanning for 3GPP networks may really take a long time, so a specific timeout
 must be given:
 .Bd -literal -compact
-    $ mmcli -m 0 --3gpp-scan --timeout=300
-
-    Found 4 networks:
-    21404 - Yoigo (umts, available)
-    21407 - Movistar (umts, current)
-    21401 - vodafone ES (umts, forbidden)
-    21403 - Orange (umts, forbidden)
+    $ sudo mmcli -m 0 --3gpp-scan --timeout=300
+      ---------------------
+      3GPP scan | networks: 21403 - Orange SP (gprs, unknown)
+                |           21407 - Movistar (gprs, unknown)
+                |           21404 - YOIGO (gprs, unknown)
+                |           21401 - vodafone ES (gprs, unknown)
 .Ed
 
 .SS Creating a new SMS message & storing it
@@ -605,7 +747,7 @@
 Using the “sm” (SIM), you can do this using:
 
 .Bd -literal -compact
-    $ mmcli -m 0 --messaging-create-sms="text='Hello world',number='+1234567890'"
+    $ sudo mmcli -m 0 --messaging-create-sms="text='Hello world',number='+1234567890'"
     Successfully created new SMS:
         /org/freedesktop/ModemManager1/SMS/21 (unknown)
 
@@ -613,28 +755,28 @@
     successfully stored the SMS
 
     $ sudo mmcli -s 21
-    SMS '/org/freedesktop/ModemManager1/SMS/21'
-      -----------------------------------
-      Content    |              number: '+1234567890'
-                 |                text: 'Hello world'
-      -----------------------------------
-      Properties |            PDU type: 'submit'
-                 |               state: 'stored'
-                 |                smsc: 'unknown'
-                 |            validity: '0'
-                 |               class: '0'
-                 |             storage: 'sm'
-                 |     delivery report: 'not requested'
-                 |   message reference: '0'
+      -------------------------------
+      General    |         dbus path: /org/freedesktop/ModemManager1/SMS/21
+      -------------------------------
+      Content    |            number: +1234567890
+                 |              text: Hello world
+      -------------------------------
+      Properties |          PDU type: submit
+                 |             state: stored
+                 |              smsc: unknown
+                 |          validity: 0
+                 |             class: 0
+                 |           storage: sm
+                 |   delivery report: not requested
+                 | message reference: 0
 
     $ sudo mmcli -m 0 --messaging-status
-    /org/freedesktop/ModemManager1/Modem/0
       ----------------------------
-      Messaging | supported storages: 'sm, me'
-                |    default storage: 'me'
+      Messaging | supported storages: sm, me
+                |    default storage: me
 .Ed
 
-.SS Sending SMS messages from files
+.SS Sending binary SMS messages from files
 
 As you can see below, the important part is the
 \fB\-\-messaging\-create\-sms\-with\-data\fR and the \fBPATH\fR provided.
@@ -658,7 +800,6 @@
 
 .Bd -literal -compact
     $> sudo mmcli -m 0 --messaging-list-sms
-    Found 1 SMS messages:
         /org/freedesktop/ModemManager1/SMS/0 (received)
 
     $> sudo mmcli -s 0 --create-file-with-data=/path/to/the/output/file
@@ -673,11 +814,10 @@
 
 .Bd -literal -compact
     $ mmcli -m 0 --location-status
-    /org/freedesktop/ModemManager1/Modem/0
       ----------------------------
-      Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea'
-               |      enabled: 'none'
-               |      signals: 'no'
+      Location | capabilities: 3gpp-lac-ci, gps-raw, gps-nmea
+               |      enabled: none
+               |      signals: no
 .Ed
 
 The output says that the modem supports 3GPP Location area code/Cell
@@ -689,16 +829,15 @@
     successfully enabled the modem
 
     $ mmcli -m 0 --location-status
-    /org/freedesktop/ModemManager1/Modem/0
       ----------------------------
-      Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea'
-               |      enabled: '3gpp-lac-ci'
-               |      signals: 'no'
+      Location | capabilities: 3gpp-lac-ci, gps-raw, gps-nmea
+               |      enabled: 3gpp-lac-ci
+               |      signals: no
 .Ed
 
 .SS GPS location technology enabling
 
-We can enable the RAW and NMEA GPS location sources using:
+We can start the GPS engine by enabling the RAW or NMEA GPS location sources:
 
 .Bd -literal -compact
     $ sudo mmcli -m 0 \\
@@ -711,27 +850,25 @@
 
 .Bd -literal -compact
     $ mmcli -m 0 --location-status
-    /org/freedesktop/ModemManager1/Modem/0
-      ----------------------------
-      Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea'
-               |      enabled: '3gpp-lac-ci, gps-raw, gps-nmea'
-               |      signals: 'no'
+      --------------------------------
+      Location | capabilities: 3gpp-lac-ci, gps-raw, gps-nmea
+               |      enabled: 3gpp-lac-ci, gps-raw, gps-nmea
+               |      signals: no
 .Ed
 
 .SS GPS location retrieval
 
-You can query location source specific information with
-\fB\-\-location\-get\-3gpp\fR, \fB\-\-location\-get\-gps\-nmea\fR and
-\fB\-\-location\-get\-gps\-raw\fR; but also for all at the same time:
+You can query all location information at the same time with a single command.
+If any of the specific outputs is not available, the corresponding section will
+be omitted from the output.
 
 .Bd -literal -compact
     $ sudo mmcli -m 0 --location-get
-    /org/freedesktop/ModemManager1/Modem/0
       -------------------------
-      3GPP location   | Mobile country code: '214'
-                      | Mobile network code: '3'
-                      |  Location area code: '21071'
-                      |             Cell ID: '7033737'
+      3GPP location   | Mobile country code: 214
+                      | Mobile network code: 3
+                      |  Location area code: 21071
+                      |             Cell ID: 7033737
       -------------------------
       GPS NMEA traces | $GPGGA,,,,,,0,,,,,,,,*66
                       | $GPRMC,,V,,,,,,,,,,N*53
@@ -741,26 +878,92 @@
                       | $GPGSV,4,3,16,03,,,,12,,,,30,,,,13,,,*78
                       | $GPGSV,4,4,16,23,,,,15,,,,27,,,,07,,,*79
                       | $GPVTG,,T,,M,,N,,K,N*2C
-      -------------------------
-      Raw GPS         | Not available
-      -------------------------
-      CDMA BS         | Not available
 .Ed
 
-An example of RAW GPS location information:
+.SS A-GPS support
+
+If A-GPS is enabled before starting the GPS engine, and if a data connection
+is available in the modem, the configured SUPL servers may be used to obtain
+a faster initial position fix.
+
+Note that the GPS engine will not be started when just A-GPS capability is
+enabled. An explicit output (RAW or NMEA) is required to be enabled in order
+to start the GPS engine.
 
 .Bd -literal -compact
-    $ sudo mmcli -m 0 --location-get-gps-raw
-    /org/freedesktop/ModemManager1/Modem/0
-      -------------------------
-      Raw GPS         |  UTC time: '155142.2'
-                      | Longitude: '-3.513941'
-                      |  Latitude: '40.502603'
-                      |  Altitude: '18.000000'
+    $ mmcli -m 0 --location-status
+      --------------------------------
+      Location |      capabilities: 3gpp-lac-ci, gps-raw, gps-nmea, agps
+               |           enabled: 3gpp-lac-ci
+               |           signals: no
+      -----------------------------
+      GPS      |      refresh rate: 30 seconds
+               | a-gps supl server: supl.google.com:7276
+
+    $ sudo mmcli -m 0 --location-enable-agps
+    successfully setup location gathering
+
+    $ sudo mmcli -m 0 --location-enable-gps-nmea
+    successfully setup location gathering
+
+    $ sudo mmcli -m 0 --location-enable-gps-raw
+    successfully setup location gathering
 .Ed
 
-.SH AUTHOR
-Martyn Russell <martyn@lanedo.com>
+.SS Injecting assistance data
+
+If the modem device does not have an ongoing connection (e.g. no mobile network
+coverage) but the system has other means to access the Internet (e.g. WiFi), the
+user may be able to download location assistance data and inject it in the
+module.
+
+E.g. If the device supports XTRA assistance data, the user may download it from
+one of the servers listed by ModemManager and manually inject it afterwards. The
+XTRA assistance data is usually valid for several days.
+
+.Bd -literal -compact
+    $ mmcli -m 0 --location-status
+      --------------------------------
+      Location |         capabilities: 3gpp-lac-ci, gps-raw, gps-nmea, agps
+               |              enabled: 3gpp-lac-ci
+               |              signals: no
+      --------------------------------
+      GPS      |         refresh rate: 30 seconds
+               |    a-gps supl server: supl.google.com:7276
+               | supported assistance: xtra
+               |   assistance servers: https://xtrapath3.izatcloud.net/xtra3grcej.bin
+               |                       https://xtrapath1.izatcloud.net/xtra3grcej.bin
+               |                       https://xtrapath2.izatcloud.net/xtra3grcej.bin
+
+    $ wget -q https://xtrapath3.izatcloud.net/xtra3grcej.bin
+
+    $ sudo mmcli -m 0 --location-inject-assistance-data=./xtra3grcej.bin
+    successfully injected assistance data
+
+    $ sudo mmcli -m 0 --location-enable-gps-nmea
+    successfully setup location gathering
+
+    $ sudo mmcli -m 0 --location-enable-gps-raw
+    successfully setup location gathering
+.Ed
+
+.SS Key-Value output
+
+Writing shell scripts that use mmcli to perform operations with the
+modem is easy when using the \fB\-\-output\-keyvalue\fR option. For
+example, you could gather all the main status information of the modem
+with a single call and then parse it to read single fields:
+
+.Bd -literal -compact
+    $ STATUS=$(mmcli -m 0 --output-keyvalue)
+    $ echo "${STATUS}" | grep "modem.generic.state " | awk -F ": " '{ print $2 }'
+    failed
+    $ echo "${STATUS}" | grep "modem.generic.state-failed-reason " | awk -F ": " '{ print $2 }'
+    sim-missing
+.Ed
+
+.SH AUTHORS
+Written by Martyn Russell <martyn@lanedo.com> and Aleksander Morgado <aleksander@aleksander.es>
 
 .SH SEE ALSO
 \fBModemManager\fR(8), \fBNetworkManager\fR(8)
diff --git a/docs/reference/api/ModemManager-docs.xml b/docs/reference/api/ModemManager-docs.xml
index 156b6ff..93d6e95 100644
--- a/docs/reference/api/ModemManager-docs.xml
+++ b/docs/reference/api/ModemManager-docs.xml
@@ -50,6 +50,7 @@
       <year>2016</year>
       <year>2017</year>
       <year>2018</year>
+      <year>2019</year>
       <holder>The ModemManager Authors</holder>
     </copyright>
 
diff --git a/docs/reference/libmm-glib/libmm-glib-docs.xml b/docs/reference/libmm-glib/libmm-glib-docs.xml
index 1c24d80..5778936 100644
--- a/docs/reference/libmm-glib/libmm-glib-docs.xml
+++ b/docs/reference/libmm-glib/libmm-glib-docs.xml
@@ -38,6 +38,7 @@
       <year>2016</year>
       <year>2017</year>
       <year>2018</year>
+      <year>2019</year>
       <holder>The ModemManager Authors</holder>
     </copyright>
 
diff --git a/examples/modem-watcher-javascript/modemWatcher.js b/examples/modem-watcher-javascript/modemWatcher.js
index f97ff48..278e335 100644
--- a/examples/modem-watcher-javascript/modemWatcher.js
+++ b/examples/modem-watcher-javascript/modemWatcher.js
@@ -49,7 +49,7 @@
 
     _ModemManagerNameOwnerChanged: function() {
         if (this._manager.name_owner)
-            print('[ModemWatcher] ModemManager service is available in bus');
+            print('[ModemWatcher] ModemManager ' + this._manager.get_version() + ' service is available in bus');
         else
             print('[ModemWatcher] ModemManager service not available in bus');
     },
diff --git a/examples/modem-watcher-python/ModemWatcher.py b/examples/modem-watcher-python/ModemWatcher.py
index ab264e5..a18725b 100644
--- a/examples/modem-watcher-python/ModemWatcher.py
+++ b/examples/modem-watcher-python/ModemWatcher.py
@@ -54,7 +54,7 @@
     """
     def set_available(self):
         if self.available == False or self.initializing == True:
-            print('[ModemWatcher] ModemManager service is available in bus')
+            print('[ModemWatcher] ModemManager %s service is available in bus' % self.manager.get_version())
         self.object_added_id = self.manager.connect('object-added', self.on_object_added)
         self.object_removed_id = self.manager.connect('object-removed', self.on_object_removed)
         self.available = True
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Firmware.xml b/introspection/org.freedesktop.ModemManager1.Modem.Firmware.xml
index 43784e2..1e45cbb 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Firmware.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Firmware.xml
@@ -23,7 +23,10 @@
       the device. Instead, it exposes information about the expected firmware update
       method as well as method-specific details required for the upgrade to happen.
       The actual firmware upgrade may be performed via the Linux Vendor Firmware Service
-      and the <link linkend="https://fwupd.org">fwupd</link> daemon.
+      and the <ulink url="https://fwupd.org">fwupd</ulink> daemon.
+
+      This interface will always be available as long a the modem is considered
+      valid.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Firmware">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Location.xml b/introspection/org.freedesktop.ModemManager1.Modem.Location.xml
index e36f8e0..5c49abb 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Location.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Location.xml
@@ -19,6 +19,11 @@
       client applications. Not all devices can provide this information, or even
       if they do, they may not be able to provide it while a data session is
       active.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used (including GNSS module management).
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Location">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Messaging.xml b/introspection/org.freedesktop.ModemManager1.Modem.Messaging.xml
index 514a745..cf13cb9 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Messaging.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Messaging.xml
@@ -17,6 +17,11 @@
 
       The Messaging interface handles sending SMS messages and notification of new
       incoming messages.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used (including listing stored messages).
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Messaging">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml b/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml
index 5616019..bc64d4a 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml
@@ -16,6 +16,11 @@
       @short_description: The ModemManager 3GPP USSD interface.
 
       This interface provides access to actions based on the USSD protocol.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.xml b/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.xml
index b0b078d..b9e9b19 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.xml
@@ -17,6 +17,11 @@
 
       This interface provides access to specific actions that may be performed
       in modems with 3GPP capabilities.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Modem3gpp">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.ModemCdma.xml b/introspection/org.freedesktop.ModemManager1.Modem.ModemCdma.xml
index 28e4e16..6000f41 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.ModemCdma.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.ModemCdma.xml
@@ -17,6 +17,11 @@
 
       This interface provides access to specific actions that may be performed
       in modems with CDMA capabilities.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. Mixed 3GPP+3GPP2 devices will require
+      a valid unlocked SIM card before any of the features in the interface can
+      be used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.ModemCdma">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Oma.xml b/introspection/org.freedesktop.ModemManager1.Modem.Oma.xml
index 351ff51..cb0f808 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Oma.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Oma.xml
@@ -17,6 +17,11 @@
 
       Device management sessions are either on-demand (client-initiated), or
       automatically initiated by either the device itself or the network.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Oma">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Signal.xml b/introspection/org.freedesktop.ModemManager1.Modem.Signal.xml
index c2b36ff..38c7957 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Signal.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Signal.xml
@@ -13,6 +13,11 @@
       @short_description: The ModemManager Signal interface.
 
       This interface provides access to extended signal quality information.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Signal">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml b/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml
index 937664b..91501c5 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml
@@ -16,6 +16,11 @@
       @short_description: The ModemManager Simple interface.
 
       The Simple interface allows controlling and querying the status of Modems.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Simple">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Time.xml b/introspection/org.freedesktop.ModemManager1.Modem.Time.xml
index d96f9b7..2659338 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Time.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Time.xml
@@ -16,6 +16,11 @@
 
       This interface allows clients to receive network time and timezone
       updates broadcast by mobile networks.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Time">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Voice.xml b/introspection/org.freedesktop.ModemManager1.Modem.Voice.xml
index 188b2bb..4912ba5 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Voice.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Voice.xml
@@ -14,6 +14,11 @@
       @short_description: The ModemManager Voice interface.
 
       The Voice interface handles Calls.
+
+      This interface will only be available once the modem is ready to be
+      registered in the cellular network. 3GPP devices will require a valid
+      unlocked SIM card before any of the features in the interface can be
+      used.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem.Voice">
 
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.xml b/introspection/org.freedesktop.ModemManager1.Modem.xml
index 34a74fe..7ac7cdd 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.xml
@@ -17,6 +17,9 @@
 
       The Modem interface controls the status and actions in a given modem
       object.
+
+      This interface will always be available as long a the modem is considered
+      valid.
   -->
   <interface name="org.freedesktop.ModemManager1.Modem">
 
diff --git a/libmm-glib/mm-firmware-update-settings.c b/libmm-glib/mm-firmware-update-settings.c
index 01c8bc8..37c8381 100644
--- a/libmm-glib/mm-firmware-update-settings.c
+++ b/libmm-glib/mm-firmware-update-settings.c
@@ -255,7 +255,7 @@
     g_variant_get (variant, "(u@a{sv})", &method, &dictionary);
     self = mm_firmware_update_settings_new (method);
 
-    if (dictionary) {
+    if ((method != MM_MODEM_FIRMWARE_UPDATE_METHOD_NONE) && dictionary) {
         GVariantIter  iter;
         gchar        *key;
         GVariant     *value;
diff --git a/libmm-glib/mm-manager.c b/libmm-glib/mm-manager.c
index fe2932d..3376763 100644
--- a/libmm-glib/mm-manager.c
+++ b/libmm-glib/mm-manager.c
@@ -89,6 +89,15 @@
 
 /*****************************************************************************/
 
+static void
+cleanup_modem_manager1_proxy (MMManager *self)
+{
+    if (self->priv->manager_iface_proxy) {
+        g_signal_handlers_disconnect_by_func (self, cleanup_modem_manager1_proxy, NULL);
+        g_clear_object (&self->priv->manager_iface_proxy);
+    }
+}
+
 static gboolean
 ensure_modem_manager1_proxy (MMManager  *self,
                              GError    **error)
@@ -124,6 +133,12 @@
     g_free (object_path);
     g_free (name);
 
+    if (self->priv->manager_iface_proxy)
+        g_signal_connect (self,
+                          "notify::name-owner",
+                          G_CALLBACK (cleanup_modem_manager1_proxy),
+                          NULL);
+
     return !!self->priv->manager_iface_proxy;
 }
 
@@ -142,10 +157,13 @@
 mm_manager_new_finish (GAsyncResult  *res,
                        GError       **error)
 {
-    GDBusObjectManager *ret;
+    GObject *ret;
+    GObject *source_object;
 
-    ret = mm_gdbus_object_manager_client_new_finish (res, error);
-    return (ret ? MM_MANAGER (ret) : NULL);
+    source_object = g_async_result_get_source_object (res);
+    ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+    g_object_unref (source_object);
+    return MM_MANAGER (ret);
 }
 
 /**
@@ -207,19 +225,15 @@
                      GCancellable                   *cancellable,
                      GError                        **error)
 {
-    GInitable *ret;
-
-    ret = g_initable_new (MM_TYPE_MANAGER,
-                          cancellable,
-                          error,
-                          "name", MM_DBUS_SERVICE,
-                          "object-path", MM_DBUS_PATH,
-                          "flags", flags,
-                          "connection", connection,
-                          "get-proxy-type-func", get_proxy_type,
-                          NULL);
-
-    return (ret ? MM_MANAGER (ret) : NULL);
+    return MM_MANAGER (g_initable_new (MM_TYPE_MANAGER,
+                                       cancellable,
+                                       error,
+                                       "name", MM_DBUS_SERVICE,
+                                       "object-path", MM_DBUS_PATH,
+                                       "flags", flags,
+                                       "connection", connection,
+                                       "get-proxy-type-func", get_proxy_type,
+                                       NULL));
 }
 
 /*****************************************************************************/
diff --git a/src/mm-context.c b/src/mm-context.c
index 88d7138..061c5c9 100644
--- a/src/mm-context.c
+++ b/src/mm-context.c
@@ -281,7 +281,7 @@
 {
     g_print ("\n"
              "ModemManager " MM_DIST_VERSION "\n"
-             "Copyright (C) 2008-2017 The ModemManager authors\n"
+             "Copyright (C) 2008-2019 The ModemManager authors\n"
              "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>\n"
              "This is free software: you are free to change and redistribute it.\n"
              "There is NO WARRANTY, to the extent permitted by law.\n"
diff --git a/src/mm-port-mbim.c b/src/mm-port-mbim.c
index 11c6111..dbc70fe 100644
--- a/src/mm-port-mbim.c
+++ b/src/mm-port-mbim.c
@@ -188,6 +188,7 @@
                  mm_port_get_device (MM_PORT (self)));
     }
 
+    self->priv->in_progress = FALSE;
     g_task_return_boolean (task, TRUE);
     g_object_unref (task);
 }
@@ -211,6 +212,7 @@
         /* Ignore error and complete */
         mm_info ("[%s] MBIM device is not QMI capable",
                  mm_port_get_device (MM_PORT (self)));
+        self->priv->in_progress = FALSE;
         g_task_return_boolean (task, TRUE);
         g_object_unref (task);
         return;
@@ -242,10 +244,9 @@
 
     self = g_task_get_source_object (task);
 
-    /* Reset the progress flag */
-    self->priv->in_progress = FALSE;
     if (!mbim_device_open_full_finish (mbim_device, res, &error)) {
         g_clear_object (&self->priv->mbim_device);
+        self->priv->in_progress = FALSE;
         g_task_return_error (task, error);
         g_object_unref (task);
         return;
@@ -270,6 +271,7 @@
     }
 #endif
 
+    self->priv->in_progress = FALSE;
     g_task_return_boolean (task, TRUE);
     g_object_unref (task);