aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem-mbim.c87
-rw-r--r--src/mm-iface-modem-3gpp.c96
-rw-r--r--src/mm-iface-modem-3gpp.h10
3 files changed, 193 insertions, 0 deletions
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index 6abeb541..48a235a9 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -145,6 +145,7 @@ struct _MMBroadbandModemMbimPrivate {
gboolean is_intel_reset_supported;
gboolean is_slot_info_status_supported;
gboolean is_ms_sar_supported;
+ gboolean is_google_carrier_lock_supported;
/* Process unsolicited notifications */
guint notification_id;
@@ -3386,6 +3387,16 @@ query_device_services_ready (MbimDevice *device,
continue;
}
+ if (service == MBIM_SERVICE_GOOGLE) {
+ for (j = 0; j < device_services[i]->cids_count; j++) {
+ if (device_services[i]->cids[j] == MBIM_CID_GOOGLE_CARRIER_LOCK) {
+ mm_obj_dbg (self, "Google carrier lock is supported");
+ self->priv->is_google_carrier_lock_supported = TRUE;
+ }
+ }
+ continue;
+ }
+
/* no optional features to check in remaining services */
}
mbim_device_service_element_array_free (device_services);
@@ -5121,6 +5132,14 @@ basic_connect_notification_subscriber_ready_status (MMBroadbandModemMbim *self,
active_sim_event = TRUE;
}
+ if ((self->priv->enabled_cache.last_ready_state != MBIM_SUBSCRIBER_READY_STATE_DEVICE_LOCKED &&
+ ready_state == MBIM_SUBSCRIBER_READY_STATE_DEVICE_LOCKED) ||
+ (self->priv->enabled_cache.last_ready_state == MBIM_SUBSCRIBER_READY_STATE_DEVICE_LOCKED &&
+ ready_state != MBIM_SUBSCRIBER_READY_STATE_DEVICE_LOCKED)) {
+ mm_obj_dbg (self, "Lock state change detected");
+ active_sim_event = TRUE;
+ }
+
self->priv->enabled_cache.last_ready_state = ready_state;
if (active_sim_event) {
@@ -9618,6 +9637,71 @@ set_packet_service_state (MMIfaceModem3gpp *self,
task);
}
+/*****************************************************************************/
+/* Set carrier lock */
+
+static gboolean
+modem_set_carrier_lock_finish (MMIfaceModem3gpp *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (res), error);
+}
+
+static void
+set_carrier_lock_ready (MbimDevice *device,
+ GAsyncResult *res,
+ GTask *task)
+{
+ g_autoptr(MbimMessage) response = NULL;
+ 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_boolean (task, TRUE);
+ } else if (g_error_matches (error, MBIM_STATUS_ERROR, MBIM_STATUS_ERROR_OPERATION_NOT_ALLOWED)) {
+ g_clear_error (&error);
+ g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "operation not allowed");
+ } else
+ g_task_return_error (task, error);
+
+ g_object_unref (task);
+}
+
+static void
+modem_set_carrier_lock (MMIfaceModem3gpp *_self,
+ const guint8 *data,
+ gsize data_size,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (_self);
+ MbimDevice *device;
+ g_autoptr(MbimMessage) message = NULL;
+ GTask *task;
+
+ if (!peek_device (self, &device, callback, user_data))
+ return;
+
+ task = g_task_new (self, NULL, callback, user_data);
+
+ if (!self->priv->is_google_carrier_lock_supported) {
+ g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Google carrier lock is not supported");
+ g_object_unref (task);
+ return;
+ }
+
+ mm_obj_dbg (self, "Sending carrier lock request...");
+ message = mbim_message_google_carrier_lock_set_new (data_size, data, NULL);
+ mbim_device_command (device,
+ message,
+ 10,
+ NULL,
+ (GAsyncReadyCallback)set_carrier_lock_ready,
+ task);
+}
/*****************************************************************************/
@@ -9853,6 +9937,9 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
iface->disable_facility_lock_finish = modem_3gpp_disable_facility_lock_finish;
iface->set_packet_service_state = set_packet_service_state;
iface->set_packet_service_state_finish = set_packet_service_state_finish;
+ /* carrier lock */
+ iface->set_carrier_lock = modem_set_carrier_lock;
+ iface->set_carrier_lock_finish = modem_set_carrier_lock_finish;
}
static void
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index 5d501042..9fd376fd 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -3360,6 +3360,98 @@ load_imei_ready (MMIfaceModem3gpp *self,
interface_initialization_step (task);
}
+/*****************************************************************************/
+
+typedef struct {
+ MmGdbusModem3gpp *skeleton;
+ GDBusMethodInvocation *invocation;
+ MMIfaceModem3gpp *self;
+ GVariant *data;
+} HandleSetCarrierLockContext;
+
+static void
+handle_set_carrier_lock_context_free (HandleSetCarrierLockContext *ctx)
+{
+ g_object_unref (ctx->skeleton);
+ g_object_unref (ctx->invocation);
+ g_object_unref (ctx->self);
+ g_variant_unref (ctx->data);
+ g_free (ctx);
+}
+
+static void
+handle_set_carrier_lock_ready (MMIfaceModem3gpp *self,
+ GAsyncResult *res,
+ HandleSetCarrierLockContext *ctx)
+{
+ GError *error = NULL;
+
+ if (!MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_carrier_lock_finish (self, res, &error))
+ g_dbus_method_invocation_take_error (ctx->invocation, error);
+ else
+ mm_gdbus_modem3gpp_complete_set_carrier_lock (ctx->skeleton, ctx->invocation);
+ handle_set_carrier_lock_context_free (ctx);
+}
+
+static void
+handle_set_carrier_lock_auth_ready (MMBaseModem *self,
+ GAsyncResult *res,
+ HandleSetCarrierLockContext *ctx)
+{
+ GError *error = NULL;
+ const guint8 *data;
+ gsize data_size;
+
+ if (!mm_base_modem_authorize_finish (self, res, &error)) {
+ g_dbus_method_invocation_take_error (ctx->invocation, error);
+ handle_set_carrier_lock_context_free (ctx);
+ return;
+ }
+
+ /* If carrier lock is not implemented, report an error */
+ if (!MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_carrier_lock ||
+ !MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_carrier_lock_finish) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Cannot send set carrier lock request to modem: "
+ "operation not supported");
+ handle_set_carrier_lock_context_free (ctx);
+ return;
+ }
+ data = (const guint8 *) g_variant_get_fixed_array (ctx->data, &data_size, sizeof (guint8));
+
+ MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_carrier_lock (ctx->self,
+ data,
+ data_size,
+ (GAsyncReadyCallback)handle_set_carrier_lock_ready,
+ ctx);
+}
+
+static gboolean
+handle_set_carrier_lock (MmGdbusModem3gpp *skeleton,
+ GDBusMethodInvocation *invocation,
+ GVariant *data,
+ MMIfaceModem3gpp *self)
+{
+ HandleSetCarrierLockContext *ctx;
+
+ ctx = g_new0 (HandleSetCarrierLockContext, 1);
+ ctx->skeleton = g_object_ref (skeleton);
+ ctx->invocation = g_object_ref (invocation);
+ ctx->self = g_object_ref (self);
+ ctx->data = g_variant_ref (data);
+
+ mm_base_modem_authorize (MM_BASE_MODEM (self),
+ invocation,
+ MM_AUTHORIZATION_DEVICE_CONTROL,
+ (GAsyncReadyCallback)handle_set_carrier_lock_auth_ready,
+ ctx);
+ return TRUE;
+}
+
+/*****************************************************************************/
+
static void
interface_initialization_step (GTask *task)
{
@@ -3498,6 +3590,10 @@ interface_initialization_step (GTask *task)
"handle-disable-facility-lock",
G_CALLBACK (handle_disable_facility_lock),
self);
+ g_signal_connect (ctx->skeleton,
+ "handle-set-carrier-lock",
+ G_CALLBACK (handle_set_carrier_lock),
+ self);
/* Finally, export the new interface */
mm_gdbus_object_skeleton_set_modem3gpp (MM_GDBUS_OBJECT_SKELETON (self),
diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h
index 424e33eb..e2ae5ee8 100644
--- a/src/mm-iface-modem-3gpp.h
+++ b/src/mm-iface-modem-3gpp.h
@@ -273,6 +273,16 @@ struct _MMIfaceModem3gpp {
gboolean (* set_nr5g_registration_settings_finish) (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error);
+
+ /* Set carrier lock */
+ void (* set_carrier_lock) (MMIfaceModem3gpp *self,
+ const guint8 *data,
+ gsize data_size,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*set_carrier_lock_finish) (MMIfaceModem3gpp *self,
+ GAsyncResult *res,
+ GError **error);
};
GType mm_iface_modem_3gpp_get_type (void);