iface-modem: use external dispatcher to attempt FCC unlock

We remove the built-in FCC unlock procedures from the ModemManager, we
will no longer run them automatically, and instead rely on external
scripts/programs to do that.

Packages providing the external FCC unlock tools can install them in
${pkglibdir}/fcc-unlock.d.

Users manually enabling external FCC unlock tools can install them in
${pkgsysconfdir}/fcc-unlock.d.

The user-enabled path takes precedence over the package-enabled one.
This commit is contained in:
Aleksander Morgado
2021-10-25 21:39:46 +02:00
parent 21c775703c
commit 81302efa66
13 changed files with 439 additions and 139 deletions

View File

@@ -41,7 +41,6 @@
static void iface_modem_location_init (MMIfaceModemLocation *iface);
#if defined WITH_QMI
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
#endif
@@ -49,7 +48,6 @@ static MMIfaceModemLocation *iface_modem_location_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimFoxconn, mm_broadband_modem_mbim_foxconn, MM_TYPE_BROADBAND_MODEM_MBIM, 0,
#if defined WITH_QMI
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
#endif
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init))
@@ -67,59 +65,6 @@ struct _MMBroadbandModemMbimFoxconnPrivate {
#if defined WITH_QMI
/*****************************************************************************/
/* FCC unlock (Modem interface) */
static gboolean
fcc_unlock_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
return g_task_propagate_boolean (G_TASK (res), error);
}
static void
dms_foxconn_set_fcc_authentication_ready (QmiClientDms *client,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationOutput) output = NULL;
output = qmi_client_dms_foxconn_set_fcc_authentication_finish (client, res, &error);
if (!output || !qmi_message_dms_foxconn_set_fcc_authentication_output_get_result (output, &error))
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
fcc_unlock (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
QmiClient *client = NULL;
g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationInput) input = NULL;
if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self),
QMI_SERVICE_DMS, &client,
callback, user_data))
return;
task = g_task_new (self, NULL, callback, user_data);
input = qmi_message_dms_foxconn_set_fcc_authentication_input_new ();
qmi_message_dms_foxconn_set_fcc_authentication_input_set_value (input, 0x00, NULL);
qmi_client_dms_foxconn_set_fcc_authentication (QMI_CLIENT_DMS (client),
input,
5,
NULL,
(GAsyncReadyCallback)dms_foxconn_set_fcc_authentication_ready,
task);
}
/*****************************************************************************/
/* Firmware update settings
*
@@ -554,13 +499,6 @@ iface_modem_location_init (MMIfaceModemLocation *iface)
#if defined WITH_QMI
static void
iface_modem_init (MMIfaceModem *iface)
{
iface->fcc_unlock = fcc_unlock;
iface->fcc_unlock_finish = fcc_unlock_finish;
}
static void
iface_modem_firmware_init (MMIfaceModemFirmware *iface)
{