allowed-apns: Do not try to unregister unnecessarily

allowed-apns plugin will try to uregister the AllowedAccessPoints
interface whenever the sim state changes, even when not registered.
This results in the (benign) error being printed inside
ofono_modem_remove_interface:

Interface org.ofono.AllowedAccessPoints not found on the interface_list
This commit is contained in:
Denis Kenzior 2020-02-07 11:06:32 -06:00
parent 90dadace21
commit 8e78d4dba5
1 changed files with 6 additions and 0 deletions

View File

@ -52,6 +52,7 @@ struct allowed_apns_ctx {
struct ofono_sim_context *sim_context;
DBusMessage *pending;
DBusMessage *reply;
bool registered;
};
static void context_destroy(gpointer data)
@ -162,6 +163,9 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *data)
DBusConnection *conn = ofono_dbus_get_connection();
if (new_state != OFONO_SIM_STATE_READY) {
if (!ctx->registered)
return;
g_dbus_unregister_interface(conn,
ofono_modem_get_path(ctx->modem),
ALLOWED_ACCESS_POINTS_INTERFACE);
@ -169,6 +173,7 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *data)
ofono_modem_remove_interface(ctx->modem,
ALLOWED_ACCESS_POINTS_INTERFACE);
ctx->registered = false;
return;
}
@ -183,6 +188,7 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *data)
return;
}
ctx->registered = true;
ofono_modem_add_interface(ctx->modem,
ALLOWED_ACCESS_POINTS_INTERFACE);
}