broadband-modem: support disabling facility lock on MBIM and QMI modems
This commit is contained in:

committed by
Aleksander Morgado

parent
e8edcedc9e
commit
7f425d9b15
@@ -2764,6 +2764,99 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self,
|
||||
mbim_message_unref (message);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Facility locks disabling (3GPP interface) */
|
||||
|
||||
static gboolean
|
||||
modem_3gpp_disable_facility_lock_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
disable_facility_lock_ready (MbimDevice *device,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MbimMessage *response = NULL;
|
||||
guint32 remaining_attempts;
|
||||
MbimPinState pin_state;
|
||||
MbimPinType pin_type;
|
||||
GError *error = NULL;
|
||||
|
||||
response = mbim_device_command_finish (device, res, &error);
|
||||
if (!response || !mbim_message_response_get_result (response,
|
||||
MBIM_MESSAGE_TYPE_COMMAND_DONE,
|
||||
&error)) {
|
||||
g_task_return_error (task, error);
|
||||
} else if (!mbim_message_pin_response_parse (response,
|
||||
&pin_type,
|
||||
&pin_state,
|
||||
&remaining_attempts,
|
||||
&error)) {
|
||||
g_task_return_error (task, error);
|
||||
} else if (pin_state == MBIM_PIN_STATE_LOCKED) {
|
||||
g_task_return_new_error (task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Disabling PIN lock %s failed, remaining attempts: %u",
|
||||
mbim_pin_state_get_string (pin_state),
|
||||
remaining_attempts);
|
||||
} else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
|
||||
if (response)
|
||||
mbim_message_unref (response);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_3gpp_disable_facility_lock (MMIfaceModem3gpp *self,
|
||||
MMModem3gppFacility facility,
|
||||
guint8 slot,
|
||||
const gchar *key,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MbimMessage *message;
|
||||
MbimPinType pin_type;
|
||||
MbimDevice *device;
|
||||
GTask *task;
|
||||
|
||||
if (!peek_device (self, &device, callback, user_data))
|
||||
return;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
/* Set type of pin lock to disable */
|
||||
pin_type = mbim_pin_type_from_mm_modem_3gpp_facility (facility);
|
||||
if (pin_type == MBIM_PIN_TYPE_UNKNOWN) {
|
||||
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
|
||||
"Not supported type of facility lock.");
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_obj_dbg (self, "Trying to disable %s lock using key: %s",
|
||||
mbim_pin_type_get_string (pin_type), key);
|
||||
|
||||
message = mbim_message_pin_set_new (pin_type,
|
||||
MBIM_PIN_OPERATION_DISABLE,
|
||||
key,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
mbim_device_command (device,
|
||||
message,
|
||||
10,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)disable_facility_lock_ready,
|
||||
task);
|
||||
mbim_message_unref (message);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Initial EPS bearer info loading */
|
||||
|
||||
@@ -6360,6 +6453,8 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||
iface->register_in_network_finish = modem_3gpp_register_in_network_finish;
|
||||
iface->scan_networks = modem_3gpp_scan_networks;
|
||||
iface->scan_networks_finish = modem_3gpp_scan_networks_finish;
|
||||
iface->disable_facility_lock = modem_3gpp_disable_facility_lock;
|
||||
iface->disable_facility_lock_finish = modem_3gpp_disable_facility_lock_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -2443,6 +2443,89 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self,
|
||||
get_facility_lock_status_via_uim (task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Facility locks disabling (3GPP interface) */
|
||||
|
||||
static gboolean
|
||||
modem_3gpp_disable_facility_lock_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
disable_facility_lock_ready (QmiClientUim *client,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
QmiMessageUimDepersonalizationOutput *output;
|
||||
GError *error = NULL;
|
||||
|
||||
output = qmi_client_uim_depersonalization_finish (client, res, &error);
|
||||
if (!output ||
|
||||
!qmi_message_uim_depersonalization_output_get_result (output, &error)) {
|
||||
g_prefix_error (&error, "QMI message Depersonalization failed: ");
|
||||
g_task_return_error (task, error);
|
||||
} else {
|
||||
g_task_return_boolean (task, TRUE);
|
||||
}
|
||||
|
||||
if (output)
|
||||
qmi_message_uim_depersonalization_output_unref (output);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_3gpp_disable_facility_lock (MMIfaceModem3gpp *self,
|
||||
MMModem3gppFacility facility,
|
||||
guint8 slot,
|
||||
const gchar *key,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
QmiUimCardApplicationPersonalizationFeature feature;
|
||||
QmiMessageUimDepersonalizationInput *input;
|
||||
QmiClient *client = NULL;
|
||||
GTask *task;
|
||||
|
||||
if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self),
|
||||
QMI_SERVICE_UIM, &client,
|
||||
callback, user_data))
|
||||
return;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
/* Choose facility to disable */
|
||||
feature = qmi_personalization_feature_from_mm_modem_3gpp_facility (facility);
|
||||
if (feature == QMI_UIM_CARD_APPLICATION_PERSONALIZATION_FEATURE_UNKNOWN) {
|
||||
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
|
||||
"Not supported type of facility lock.");
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_obj_dbg (self, "Trying to disable %s lock on slot %d using key: %s",
|
||||
qmi_uim_card_application_personalization_feature_get_string (feature),
|
||||
slot, key);
|
||||
|
||||
input = qmi_message_uim_depersonalization_input_new ();
|
||||
qmi_message_uim_depersonalization_input_set_info (input,
|
||||
feature,
|
||||
QMI_UIM_DEPERSONALIZATION_OPERATION_DEACTIVATE,
|
||||
key,
|
||||
NULL);
|
||||
qmi_message_uim_depersonalization_input_set_slot (input, slot, NULL);
|
||||
|
||||
qmi_client_uim_depersonalization (QMI_CLIENT_UIM (client),
|
||||
input,
|
||||
30,
|
||||
NULL,
|
||||
(GAsyncReadyCallback) disable_facility_lock_ready,
|
||||
task);
|
||||
qmi_message_uim_depersonalization_input_unref (input);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Scan networks (3GPP interface) */
|
||||
|
||||
@@ -11231,6 +11314,8 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||
iface->load_initial_eps_bearer_settings_finish = modem_3gpp_load_initial_eps_bearer_settings_finish;
|
||||
iface->set_initial_eps_bearer_settings = modem_3gpp_set_initial_eps_bearer_settings;
|
||||
iface->set_initial_eps_bearer_settings_finish = modem_3gpp_set_initial_eps_bearer_settings_finish;
|
||||
iface->disable_facility_lock = modem_3gpp_disable_facility_lock;
|
||||
iface->disable_facility_lock_finish = modem_3gpp_disable_facility_lock_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user