Determining when the NMDeviceModem is available and when different connections are available is easier if the modem's state is tracked, instead of using the separate Enabled and Connected properties. These properties could not accurately represent the SIM lock state and prevented NetworkManager from making the modem available for auto-activation when locked, even if a PIN was available.
In this new scheme, the NMDeviceModem is UNAVAILABLE when the ModemManager modem state is FAILED, UNKNOWN, or INITIALIZING. It transitions to the NM DISCONNECTED state when the modem has finished initializing and has not failed.
Once the NMDeviceModem is in DISCONNECTED state it can be activated even if the SIM is locked and a PIN is required; the PIN will be requested when starting activation, either from the connection itself or via a secrets request. This makes auto-activation of WWAN connections possible.
This also allows us to consolidate code dealing with modem enable/disable into the base NMModem class using the modem state, and to log more modem information for debugging purposes.
6080425 wwan: use modem states instead of enabled/connected properties
include/NetworkManager.h | 6 ++
introspection/nm-device.xml | 10 +++
src/devices/bluetooth/nm-device-bt.c | 33 +++++++
src/devices/nm-device.c | 4 +
src/devices/wwan/nm-device-modem.c | 128 +++++++++++++++++++-------
src/devices/wwan/nm-modem-broadband.c | 101 ++++++++-------------
src/devices/wwan/nm-modem-old.c | 138 +++++++++++-----------------
src/devices/wwan/nm-modem.c | 160 ++++++++++++++++++++++++---------
src/devices/wwan/nm-modem.h | 35 ++++++--
9 files changed, 391 insertions(+), 224 deletions(-)