[PATCH v2 2/3] sim: Create new dbus method to clear the forbidden network operator list
Sean Nyekjaer <[email protected]> Thu, 03 Jul 2025 13:48:20 +0200
| Newsgroups | dev.linux.lists.ofono |
|---|---|
| Message-ID | <[email protected]> |
To clear the list:
busctl call org.ofono /sim76xx_0 org.ofono.SimManager
ClearForbiddenNetworkOperators
---
src/sim.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/sim.c b/src/sim.c
index 7d9a180abd0c5b7adedebfe7026125dbada9752e..4f72bd9ac1abf484fed77008c03cae9186b63c9e 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -143,6 +143,11 @@ struct msisdn_set_request {
DBusMessage *msg;
};
+struct fplmn_set_request {
+ struct ofono_sim *sim;
+ DBusMessage *msg;
+};
+
struct service_number {
char *id;
struct ofono_phone_number ph;
@@ -649,6 +654,41 @@ static gboolean set_own_numbers(struct ofono_sim *sim,
return TRUE;
}
+static void sim_efplmn_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_sim *sim = data;
+ DBusMessage *reply;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("Unable to clear Forbidden PLMN");
+ reply = __ofono_error_failed(sim->pending);
+ } else {
+ reply = dbus_message_new_method_return(sim->pending);
+ }
+
+ __ofono_dbus_pending_reply(&sim->pending, reply);
+}
+
+static DBusMessage *sim_clear_forbidden_plmn(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ struct ofono_sim *sim = data;
+ DBusMessageIter iter;
+ DBusMessageIter var;
+ static uint8_t plmn_list[12] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+
+ if (sim->pending)
+ return __ofono_error_busy(msg);
+
+ sim->pending = dbus_message_ref(msg);
+
+ sim->driver->write_file_transparent(sim, SIM_EF_PLMN_FILEID, 0, 12,
+ plmn_list, NULL, 0, sim_efplmn_cb, sim);
+
+ return NULL;
+}
+
static void sim_set_slot_callback(const struct ofono_error *error, void *data)
{
struct ofono_sim *sim = data;
@@ -687,6 +727,7 @@ static DBusMessage *sim_set_property(DBusConnection *conn, DBusMessage *msg,
DBusMessageIter var;
DBusMessageIter var_elem;
const char *name, *value;
+ ofono_bool_t clear_fplmn;
if (!dbus_message_iter_init(msg, &iter))
return __ofono_error_invalid_args(msg);
@@ -1297,6 +1338,8 @@ static const GDBusMethodTable sim_methods[] = {
{ GDBUS_ASYNC_METHOD("SetProperty",
GDBUS_ARGS({ "property", "s" }, { "value", "v" }),
NULL, sim_set_property) },
+ { GDBUS_ASYNC_METHOD("ClearForbiddenNetworkOperators",
+ NULL, NULL, sim_clear_forbidden_plmn) },
{ GDBUS_ASYNC_METHOD("ChangePin",
GDBUS_ARGS({ "type", "s" }, { "oldpin", "s" },
{ "newpin", "s" }), NULL,
--
2.49.0