qmi: retrieve MM_MODEM_3GPP_FACILITY_SIM
This facility cannot be retrieved via 'DMS UIM Get CK Status' and seems currently unimplemented for mm-broadband-modem-qmi. The SIM enabled status is however available via 'DMS UIM Get PIN Status'. Using this message to add the retrieval of PIN status just after the other facilities were queried. Succesfully tested with Gobi2000 (05c6:9205), both retrieval of 3gpp SIM lock status and enabling/disabling the PIN.
This commit is contained in:
committed by
Aleksander Morgado
parent
d44690489b
commit
bc410ce03f
@@ -3346,6 +3346,68 @@ modem_3gpp_load_enabled_facility_locks_finish (MMIfaceModem3gpp *self,
|
||||
g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))));
|
||||
}
|
||||
|
||||
static void
|
||||
get_sim_lock_status_via_pin_status_ready (QmiClientDms *client,
|
||||
GAsyncResult *res,
|
||||
LoadEnabledFacilityLocksContext *ctx)
|
||||
{
|
||||
QmiMessageDmsUimGetPinStatusOutput *output;
|
||||
gboolean enabled;
|
||||
|
||||
output = qmi_client_dms_uim_get_pin_status_finish (client, res, NULL);
|
||||
if (!output ||
|
||||
!qmi_message_dms_uim_get_pin_status_output_get_result (output, NULL)) {
|
||||
mm_dbg ("Couldn't query PIN status, assuming SIM PIN is disabled");
|
||||
enabled = FALSE;
|
||||
} else {
|
||||
QmiDmsUimPinStatus current_status;
|
||||
|
||||
if (qmi_message_dms_uim_get_pin_status_output_get_pin1_status (
|
||||
output,
|
||||
¤t_status,
|
||||
NULL, /* verify_retries_left */
|
||||
NULL, /* unblock_retries_left */
|
||||
NULL)) {
|
||||
enabled = mm_pin_enabled_from_qmi_uim_pin_status (current_status);
|
||||
mm_dbg ("PIN is reported %s", (enabled ? "enabled" : "disabled"));
|
||||
} else {
|
||||
mm_dbg ("Couldn't find PIN1 status in the result, assuming SIM PIN is disabled");
|
||||
enabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (output)
|
||||
qmi_message_dms_uim_get_pin_status_output_unref (output);
|
||||
|
||||
if (enabled) {
|
||||
ctx->locks |= (MM_MODEM_3GPP_FACILITY_SIM);
|
||||
} else {
|
||||
ctx->locks &= ~(MM_MODEM_3GPP_FACILITY_SIM);
|
||||
}
|
||||
|
||||
/* No more facilities to query, all done */
|
||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||
GUINT_TO_POINTER (ctx->locks),
|
||||
NULL);
|
||||
load_enabled_facility_locks_context_complete_and_free (ctx);
|
||||
}
|
||||
|
||||
/* the SIM lock cannot be queried with the qmi_get_ck_status function,
|
||||
* therefore using the PIN status */
|
||||
static void
|
||||
get_sim_lock_status_via_pin_status (LoadEnabledFacilityLocksContext *ctx)
|
||||
{
|
||||
mm_dbg ("Retrieving PIN status to check for enabled PIN");
|
||||
/* if the SIM is locked or not can only be queried by locking at
|
||||
* the PIN status */
|
||||
qmi_client_dms_uim_get_pin_status (QMI_CLIENT_DMS (ctx->client),
|
||||
NULL,
|
||||
5,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)get_sim_lock_status_via_pin_status_ready,
|
||||
ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
dms_uim_get_ck_status_ready (QmiClientDms *client,
|
||||
GAsyncResult *res,
|
||||
@@ -3424,11 +3486,7 @@ get_next_facility_lock_status (LoadEnabledFacilityLocksContext *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
/* No more facilities to query, all done */
|
||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
||||
GUINT_TO_POINTER (ctx->locks),
|
||||
NULL);
|
||||
load_enabled_facility_locks_context_complete_and_free (ctx);
|
||||
get_sim_lock_status_via_pin_status (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -98,6 +98,32 @@ mm_modem_lock_from_qmi_uim_pin_status (QmiDmsUimPinStatus status,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
mm_pin_enabled_from_qmi_uim_pin_status (QmiDmsUimPinStatus status)
|
||||
{
|
||||
switch (status) {
|
||||
case QMI_DMS_UIM_PIN_STATUS_ENABLED_NOT_VERIFIED:
|
||||
case QMI_DMS_UIM_PIN_STATUS_ENABLED_VERIFIED:
|
||||
case QMI_DMS_UIM_PIN_STATUS_BLOCKED:
|
||||
case QMI_DMS_UIM_PIN_STATUS_PERMANENTLY_BLOCKED:
|
||||
case QMI_DMS_UIM_PIN_STATUS_UNBLOCKED:
|
||||
case QMI_DMS_UIM_PIN_STATUS_CHANGED:
|
||||
/* assume the PIN to be enabled then */
|
||||
return TRUE;
|
||||
|
||||
case QMI_DMS_UIM_PIN_STATUS_DISABLED:
|
||||
case QMI_DMS_UIM_PIN_STATUS_NOT_INITIALIZED:
|
||||
/* assume the PIN to be disabled then */
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
/* by default assume disabled */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
QmiDmsUimFacility
|
||||
mm_3gpp_facility_to_qmi_uim_facility (MMModem3gppFacility mm)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ MMModemMode mm_modem_mode_from_qmi_radio_interface (QmiDmsRadioInterface network
|
||||
MMModemLock mm_modem_lock_from_qmi_uim_pin_status (QmiDmsUimPinStatus status,
|
||||
gboolean pin1);
|
||||
|
||||
gboolean mm_pin_enabled_from_qmi_uim_pin_status (QmiDmsUimPinStatus status);
|
||||
QmiDmsUimFacility mm_3gpp_facility_to_qmi_uim_facility (MMModem3gppFacility mm);
|
||||
|
||||
GArray *mm_modem_bands_from_qmi_band_capabilities (QmiDmsBandCapability qmi_bands,
|
||||
|
||||
Reference in New Issue
Block a user