modem-mbim: enter LOCKED state when SIM is incompatible

According to MBIM specification, the subscriber state is INITIALIZED
when SIM card is incompatible with enabled modem personalization lock.
This patch introduce additional check for enabled PIN lock in such case
and fixes depersonalization of one lock if several are enabled.
This commit is contained in:
Michal Mazur
2021-08-19 17:34:21 +02:00
parent d5c2ea931e
commit 5828af115c

View File

@@ -1225,7 +1225,8 @@ unlock_required_subscriber_ready_state_ready (MbimDevice *device,
}
/* Initialized but locked? */
if (ready_state == MBIM_SUBSCRIBER_READY_STATE_DEVICE_LOCKED) {
if (ready_state == MBIM_SUBSCRIBER_READY_STATE_DEVICE_LOCKED ||
ready_state == MBIM_SUBSCRIBER_READY_STATE_INITIALIZED) {
MbimMessage *message;
/* Query which lock is to unlock */
@@ -1240,13 +1241,6 @@ unlock_required_subscriber_ready_state_ready (MbimDevice *device,
goto out;
}
/* Initialized! */
if (ready_state == MBIM_SUBSCRIBER_READY_STATE_INITIALIZED) {
g_task_return_boolean (task, TRUE);
g_object_unref (task);
goto out;
}
g_assert_not_reached ();
out:
@@ -2662,6 +2656,11 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self,
/*****************************************************************************/
/* Facility locks disabling (3GPP interface) */
typedef struct _DisableFacilityLockContext DisableFacilityLockContext;
struct _DisableFacilityLockContext {
MbimPinType pin_type;
};
static gboolean
modem_3gpp_disable_facility_lock_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
@@ -2675,12 +2674,15 @@ disable_facility_lock_ready (MbimDevice *device,
GAsyncResult *res,
GTask *task)
{
DisableFacilityLockContext *ctx;
MbimMessage *response = NULL;
guint32 remaining_attempts;
MbimPinState pin_state;
MbimPinType pin_type;
GError *error = NULL;
ctx = g_task_get_task_data (task);
response = mbim_device_command_finish (device, res, &error);
if (!response || !mbim_message_response_get_result (response,
MBIM_MESSAGE_TYPE_COMMAND_DONE,
@@ -2692,7 +2694,8 @@ disable_facility_lock_ready (MbimDevice *device,
&remaining_attempts,
&error)) {
g_task_return_error (task, error);
} else if (pin_state == MBIM_PIN_STATE_LOCKED) {
} else if (pin_type == ctx->pin_type &&
pin_state == MBIM_PIN_STATE_LOCKED) {
g_task_return_new_error (task,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
@@ -2715,6 +2718,7 @@ modem_3gpp_disable_facility_lock (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
DisableFacilityLockContext *ctx;
MbimMessage *message;
MbimPinType pin_type;
MbimDevice *device;
@@ -2737,6 +2741,10 @@ modem_3gpp_disable_facility_lock (MMIfaceModem3gpp *self,
mm_obj_dbg (self, "Trying to disable %s lock using key: %s",
mbim_pin_type_get_string (pin_type), key);
ctx = g_new0 (DisableFacilityLockContext, 1);
ctx->pin_type = pin_type;
g_task_set_task_data (task, ctx, g_free);
message = mbim_message_pin_set_new (pin_type,
MBIM_PIN_OPERATION_DISABLE,
key,