api,libmm-glib,cli: add command to disable facility lock
This commit is contained in:

committed by
Aleksander Morgado

parent
b1dde0aec3
commit
25ffe4211a
@@ -70,6 +70,10 @@ _mmcli()
|
||||
COMPREPLY=( $(compgen -W "[response]" -- $cur) )
|
||||
return 0
|
||||
;;
|
||||
'--3gpp-disable-facility-lock')
|
||||
COMPREPLY=( $(compgen -W "[FACILITY,CONTROL_KEY]" -- $cur) )
|
||||
return 0
|
||||
;;
|
||||
'--cdma-activate')
|
||||
COMPREPLY=( $(compgen -W "[CARRIER]" -- $cur) )
|
||||
return 0
|
||||
|
@@ -51,6 +51,7 @@ static gboolean register_home_flag;
|
||||
static gchar *register_in_operator_str;
|
||||
static gchar *set_eps_ue_mode_operation_str;
|
||||
static gchar *set_initial_eps_bearer_settings_str;
|
||||
static gchar *disable_facility_lock_str;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{ "3gpp-scan", 0, 0, G_OPTION_ARG_NONE, &scan_flag,
|
||||
@@ -73,6 +74,10 @@ static GOptionEntry entries[] = {
|
||||
"Set the initial EPS bearer settings",
|
||||
"[\"key=value,...\"]"
|
||||
},
|
||||
{ "3gpp-disable-facility-lock", 0, 0, G_OPTION_ARG_STRING, &disable_facility_lock_str,
|
||||
"Disable facility personalization",
|
||||
"[facility,key]"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@@ -104,7 +109,8 @@ mmcli_modem_3gpp_options_enabled (void)
|
||||
register_home_flag +
|
||||
!!register_in_operator_str +
|
||||
!!set_eps_ue_mode_operation_str +
|
||||
!!set_initial_eps_bearer_settings_str);
|
||||
!!set_initial_eps_bearer_settings_str +
|
||||
!!disable_facility_lock_str);
|
||||
|
||||
if (n_actions > 1) {
|
||||
g_printerr ("error: too many 3GPP actions requested\n");
|
||||
@@ -138,13 +144,19 @@ context_free (void)
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_modem_3gpp (void)
|
||||
ensure_modem_enabled (void)
|
||||
{
|
||||
if (mm_modem_get_state (mm_object_peek_modem (ctx->object)) < MM_MODEM_STATE_ENABLED) {
|
||||
g_printerr ("error: modem not enabled yet\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Success */
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_modem_3gpp (void)
|
||||
{
|
||||
if (!ctx->modem_3gpp) {
|
||||
g_printerr ("error: modem has no 3GPP capabilities\n");
|
||||
exit (EXIT_FAILURE);
|
||||
@@ -279,6 +291,33 @@ parse_eps_ue_mode_operation (MMModem3gppEpsUeModeOperation *uemode)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
disable_facility_lock_process_reply (gboolean result,
|
||||
const GError *error)
|
||||
{
|
||||
if (!result) {
|
||||
g_printerr ("error: couldn't disable facility lock: '%s'\n",
|
||||
error ? error->message : "unknown error");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_print ("successfully disabled facility lock\n");
|
||||
}
|
||||
|
||||
static void
|
||||
disable_facility_lock_ready (MMModem3gpp *modem_3gpp,
|
||||
GAsyncResult *result,
|
||||
gpointer nothing)
|
||||
{
|
||||
gboolean operation_result;
|
||||
GError *error = NULL;
|
||||
|
||||
operation_result = mm_modem_3gpp_disable_facility_lock_finish (modem_3gpp, result, &error);
|
||||
disable_facility_lock_process_reply (operation_result, error);
|
||||
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static void
|
||||
get_modem_ready (GObject *source,
|
||||
GAsyncResult *result)
|
||||
@@ -292,6 +331,34 @@ get_modem_ready (GObject *source,
|
||||
|
||||
ensure_modem_3gpp ();
|
||||
|
||||
/* Request to disable facility lock */
|
||||
if (disable_facility_lock_str) {
|
||||
gchar **properties;
|
||||
gchar *control_key;
|
||||
MMModem3gppFacility facility;
|
||||
|
||||
properties = g_strsplit (disable_facility_lock_str, ",", -1);
|
||||
if (!properties[0] || !(control_key = properties[1]) ||
|
||||
!(facility = mm_common_get_3gpp_facility_from_string (properties[0], NULL))) {
|
||||
g_printerr ("Error parsing properties string.\n");
|
||||
g_free (properties[0]);
|
||||
g_free (properties[1]);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_debug ("Disable facility lock...");
|
||||
mm_modem_3gpp_disable_facility_lock (ctx->modem_3gpp,
|
||||
facility,
|
||||
control_key,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)disable_facility_lock_ready,
|
||||
NULL);
|
||||
g_strfreev (properties);
|
||||
return;
|
||||
}
|
||||
|
||||
ensure_modem_enabled ();
|
||||
|
||||
/* Request to scan networks? */
|
||||
if (scan_flag) {
|
||||
g_debug ("Asynchronously scanning for networks...");
|
||||
@@ -391,6 +458,35 @@ mmcli_modem_3gpp_run_synchronous (GDBusConnection *connection)
|
||||
if (scan_flag)
|
||||
g_assert_not_reached ();
|
||||
|
||||
/* Request to remove carrier lock */
|
||||
if (disable_facility_lock_str) {
|
||||
gchar **properties;
|
||||
gchar *control_key;
|
||||
MMModem3gppFacility facility;
|
||||
gboolean result;
|
||||
|
||||
properties = g_strsplit (disable_facility_lock_str, ",", -1);
|
||||
if (!properties[0] || !(control_key = properties[1]) ||
|
||||
!(facility = mm_common_get_3gpp_facility_from_string (properties[0], NULL))) {
|
||||
g_printerr ("Error parsing properties string.\n");
|
||||
g_free (properties[0]);
|
||||
g_free (properties[1]);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_debug ("Disable facility lock...");
|
||||
result = mm_modem_3gpp_disable_facility_lock_sync (ctx->modem_3gpp,
|
||||
facility,
|
||||
control_key,
|
||||
NULL,
|
||||
&error);
|
||||
g_strfreev (properties);
|
||||
disable_facility_lock_process_reply (result, error);
|
||||
return;
|
||||
}
|
||||
|
||||
ensure_modem_enabled ();
|
||||
|
||||
/* Request to register the modem? */
|
||||
if (register_in_operator_str || register_home_flag) {
|
||||
gboolean result;
|
||||
|
@@ -342,6 +342,23 @@ network-originated request. This option allows for that.
|
||||
.TP
|
||||
.B \-\-3gpp\-ussd\-cancel
|
||||
Cancel an ongoing USSD session for a given modem.
|
||||
.TP
|
||||
.B \-\-3gpp\-disable\-facility\-lock=FACILITY,CONTROL_KEY
|
||||
Disable selected facility lock using provided control key.
|
||||
.RS 9
|
||||
.TP
|
||||
\fB'FACILITY'\fR
|
||||
One of the following types of lock:
|
||||
.Bd -literal -compact
|
||||
\fB'net-pers'\fR - network personalization
|
||||
\fB'net-sub-pers'\fR - network subset personalization
|
||||
\fB'provider-pers'\fR - provider personalization
|
||||
\fB'corp-pers'\fR - corporate personalization
|
||||
.Ed
|
||||
.TP
|
||||
\fB'CONTROL_KEY'\fR
|
||||
Alphanumeric code to unlock facility.
|
||||
.RE
|
||||
|
||||
.SH CDMA OPTIONS
|
||||
All CDMA (Code Division Multiple Access) options require the
|
||||
|
@@ -185,6 +185,33 @@
|
||||
-->
|
||||
<property name="EnabledFacilityLocks" type="u" access="read" />
|
||||
|
||||
<!--
|
||||
DisableFacilityLock:
|
||||
@properties: A tuple of facility type and control key.
|
||||
|
||||
Sends control key to modem to disable selected facility lock
|
||||
|
||||
<variablelist>
|
||||
<varlistentry><term>"facility"</term>
|
||||
<listitem>
|
||||
<para>
|
||||
A <link linkend="MMModem3gppFacility">MMModem3gppFacility</link> value
|
||||
representing the type of the facility lock to disable.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry><term>"control key"</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Alphanumeric key required to unlock facility.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
-->
|
||||
<method name="DisableFacilityLock">
|
||||
<arg name="properties" type="(us)" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SubscriptionState:
|
||||
|
||||
|
@@ -1260,6 +1260,56 @@ mm_modem_3gpp_set_initial_eps_bearer_settings_sync (MMModem3gpp *self,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
mm_modem_3gpp_disable_facility_lock (MMModem3gpp *self,
|
||||
MMModem3gppFacility facility,
|
||||
const gchar *control_key,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GVariant *properties;
|
||||
|
||||
properties = g_variant_ref_sink (g_variant_new ("(us)", (guint)facility, control_key));
|
||||
mm_gdbus_modem3gpp_call_disable_facility_lock (MM_GDBUS_MODEM3GPP (self),
|
||||
properties,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
g_variant_unref (properties);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_modem_3gpp_disable_facility_lock_finish (MMModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return mm_gdbus_modem3gpp_call_disable_facility_lock_finish (MM_GDBUS_MODEM3GPP (self),
|
||||
res,
|
||||
error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_modem_3gpp_disable_facility_lock_sync (MMModem3gpp *self,
|
||||
MMModem3gppFacility facility,
|
||||
const gchar *control_key,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GVariant *properties;
|
||||
gboolean result;
|
||||
|
||||
properties = g_variant_ref_sink (g_variant_new ("(us)", (guint)facility, control_key));
|
||||
result = mm_gdbus_modem3gpp_call_disable_facility_lock_sync (MM_GDBUS_MODEM3GPP (self),
|
||||
properties,
|
||||
cancellable,
|
||||
error);
|
||||
g_variant_unref (properties);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_modem_3gpp_init (MMModem3gpp *self)
|
||||
{
|
||||
|
@@ -172,6 +172,21 @@ gboolean mm_modem_3gpp_set_initial_eps_bearer_settings_sync (MMModem3gpp
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void mm_modem_3gpp_disable_facility_lock (MMModem3gpp *self,
|
||||
MMModem3gppFacility facility,
|
||||
const gchar *control_key,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_modem_3gpp_disable_facility_lock_finish (MMModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
gboolean mm_modem_3gpp_disable_facility_lock_sync (MMModem3gpp *self,
|
||||
MMModem3gppFacility facility,
|
||||
const gchar *control_key,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
#ifndef MM_DISABLE_DEPRECATED
|
||||
|
||||
G_DEPRECATED
|
||||
|
Reference in New Issue
Block a user