Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ofono-binder] Allows ignoring APN errors via config file #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions binder.conf
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,10 @@
# Default 3 (GSM_WCDMA_AUTO)
#
#umtsNetworkMode=3

# Ignore APN errors
#
# APN attachment may fail with some specific errors.
# If you want to ignore those errors to prevent power drain, add error codes here.
#
# ignoreApnErrors=501
27 changes: 24 additions & 3 deletions src/binder_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <gbinder_reader.h>
#include <gbinder_writer.h>

#include <gutil_ints.h>
#include <gutil_macros.h>
#include <gutil_misc.h>

Expand Down Expand Up @@ -136,6 +137,7 @@ typedef struct binder_network_object {
gboolean force_gsm_when_radio_off;
BinderDataProfileConfig data_profile_config;
GSList* data_profiles;
GUtilInts* ignore_apn_errors;
} BinderNetworkObject;

typedef BinderBaseClass BinderNetworkObjectClass;
Expand Down Expand Up @@ -1372,6 +1374,21 @@ binder_network_can_set_initial_attach_apn(
!self->set_data_profiles_req;
}

static
gboolean
binder_attach_apn_retry(
RadioRequest* req,
RADIO_TX_STATUS status,
RADIO_RESP resp,
RADIO_ERROR error,
const GBinderReader* args,
void* user_data)
{
BinderNetworkObject* self = THIS(user_data);

return error != RADIO_ERROR_NONE && !gutil_ints_contains(self->ignore_apn_errors, error);
}

static
void
binder_network_set_initial_attach_apn(
Expand All @@ -1389,15 +1406,15 @@ binder_network_set_initial_attach_apn(
if (iface >= RADIO_INTERFACE_1_5) {
/* setInitialAttachApn_1_4(int32 serial, DataProfileInfo profile); */
req = radio_request_new2(self->g, RADIO_REQ_SET_INITIAL_ATTACH_APN_1_5,
&writer, NULL, NULL, NULL);
&writer, NULL, NULL, self);

gbinder_writer_append_struct(&writer,
binder_network_new_radio_data_profile_1_5(&writer, &profile, dpc),
&binder_data_profile_1_5_type, NULL);
} else if (iface >= RADIO_INTERFACE_1_4) {
/* setInitialAttachApn_1_4(int32 serial, DataProfileInfo profile); */
req = radio_request_new2(self->g, RADIO_REQ_SET_INITIAL_ATTACH_APN_1_4,
&writer, NULL, NULL, NULL);
&writer, NULL, NULL, self);

gbinder_writer_append_struct(&writer,
binder_network_new_radio_data_profile_1_4(&writer, &profile, dpc),
Expand All @@ -1408,7 +1425,7 @@ binder_network_set_initial_attach_apn(
* bool modemCognitive, bool isRoaming);
*/
req = radio_request_new2(self->g, RADIO_REQ_SET_INITIAL_ATTACH_APN,
&writer, NULL, NULL, NULL);
&writer, NULL, NULL, self);

gbinder_writer_append_struct(&writer,
binder_network_new_radio_data_profile(&writer, &profile, dpc),
Expand All @@ -1418,6 +1435,7 @@ binder_network_set_initial_attach_apn(
}

DBG_(self, "\"%s\"", ctx->apn);
radio_request_set_retry_func(req, binder_attach_apn_retry);
radio_request_set_retry(req, BINDER_RETRY_MS, -1);
radio_request_set_timeout(req, INTINITE_TIMEOUT);
radio_request_drop(self->set_ia_apn_req);
Expand Down Expand Up @@ -2237,6 +2255,7 @@ binder_network_new(
self->network_mode_timeout_ms = config->network_mode_timeout_ms;
self->force_gsm_when_radio_off = config->force_gsm_when_radio_off;
self->data_profile_config = *dpc;
self->ignore_apn_errors = gutil_ints_ref(config->ignore_apn_errors);

/* Register listeners */
self->ind_id[IND_NETWORK_STATE] =
Expand Down Expand Up @@ -2463,6 +2482,8 @@ binder_network_object_finalize(
binder_sim_settings_remove_handler(net->settings, self->settings_event_id);
binder_sim_settings_unref(net->settings);

gutil_ints_unref(self->ignore_apn_errors);

g_slist_free_full(self->data_profiles, g_free);
g_free(self->log_prefix);

Expand Down
6 changes: 6 additions & 0 deletions src/binder_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static const char* const binder_radio_ifaces[] = {
#define BINDER_CONF_SLOT_LTE_MODE "lteNetworkMode"
#define BINDER_CONF_SLOT_UMTS_MODE "umtsNetworkMode"
#define BINDER_CONF_SLOT_TECHNOLOGIES "technologies"
#define BINDER_CONF_SLOT_IGNORE_APN_ERRORS "ignoreApnErrors"

/* Defaults */
#define BINDER_DEFAULT_RADIO_INTERFACE RADIO_INTERFACE_1_2
Expand Down Expand Up @@ -1554,6 +1555,10 @@ binder_plugin_create_slot(
DBG("%s: " BINDER_CONF_SLOT_DISABLE_FEATURES " 0x%04x", group, ival);
}

/* ignoreApnErrors */
config->ignore_apn_errors = binder_plugin_config_get_ints(file, group,
BINDER_CONF_SLOT_IGNORE_APN_ERRORS);

/* deviceStateTracking */
if (ofono_conf_get_mask(file, group,
BINDER_CONF_SLOT_DEVMON, &ival,
Expand Down Expand Up @@ -1726,6 +1731,7 @@ binder_plugin_slot_free(
binder_sim_settings_unref(slot->sim_settings);
gutil_ints_unref(slot->config.local_hangup_reasons);
gutil_ints_unref(slot->config.remote_hangup_reasons);
gutil_ints_unref(slot->config.ignore_apn_errors);
gbinder_servicemanager_remove_handler(slot->svcmgr, slot->radio_watch_id);
gbinder_servicemanager_cancel(slot->svcmgr, slot->list_call_id);
gbinder_servicemanager_unref(slot->svcmgr);
Expand Down
1 change: 1 addition & 0 deletions src/binder_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef struct binder_slot_config {
BinderDataProfileConfig data_profile_config;
GUtilInts* local_hangup_reasons;
GUtilInts* remote_hangup_reasons;
GUtilInts* ignore_apn_errors;
} BinderSlotConfig;

#define BINDER_DRIVER "binder"
Expand Down