Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb49322' into 'master'
Improve network registration process

See merge request mer-core/ofono!256
  • Loading branch information
monich committed Mar 16, 2020
2 parents 6584919 + 6d4638f commit 544f02e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ofono/drivers/ril/ril_constants.h
Expand Up @@ -382,6 +382,12 @@ enum ril_unsolicited_response_filter {
RIL_UR_DATA_CALL_DORMANCY_CHANGED = 0x04
};

/* RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE result */
enum ril_network_selection_mode {
RIL_NETWORK_SELECTION_MODE_AUTO = 0,
RIL_NETWORK_SELECTION_MODE_MANUAL = 1
};

#endif /*__RIL_CONSTANTS_H */

/*
Expand Down
41 changes: 39 additions & 2 deletions ofono/drivers/ril/ril_netreg.c
Expand Up @@ -301,10 +301,9 @@ static void ril_netreg_register_cb(GRilIoChannel *io, int status,
}
}

static void ril_netreg_register_auto(struct ofono_netreg *netreg,
static void ril_netreg_set_register_auto(struct ril_netreg *nd,
ofono_netreg_register_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
GRilIoRequest *req = grilio_request_new();

ofono_info("nw select automatic");
Expand All @@ -317,6 +316,44 @@ static void ril_netreg_register_auto(struct ofono_netreg *netreg,
grilio_request_unref(req);
}

static void ril_netreg_query_register_auto_cb(GRilIoChannel *io, int status,
const void *data, guint len,
void *user_data)
{
struct ril_netreg_cbd *cbd = user_data;
ofono_netreg_register_cb_t cb = cbd->cb.reg;

if (status == RIL_E_SUCCESS) {
GRilIoParser rilp;
gint32 net_mode;

grilio_parser_init(&rilp, data, len);
if (grilio_parser_get_int32(&rilp, NULL) /* Array length */ &&
grilio_parser_get_int32(&rilp, &net_mode) &&
net_mode == RIL_NETWORK_SELECTION_MODE_AUTO) {
struct ofono_error error;
ofono_info("nw selection is already auto");
cb(ril_error_ok(&error), cbd->data);
return;
}
}

ril_netreg_set_register_auto(cbd->nd, cb, cbd->data);
}

static void ril_netreg_register_auto(struct ofono_netreg *netreg,
ofono_netreg_register_cb_t cb, void *data)
{
struct ril_netreg *nd = ril_netreg_get_data(netreg);
GRilIoRequest *req = grilio_request_new();

grilio_queue_send_request_full(nd->q, req,
RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE,
ril_netreg_query_register_auto_cb, ril_netreg_cbd_free,
ril_netreg_cbd_new(nd, cb, data));
grilio_request_unref(req);
}

static void ril_netreg_register_manual(struct ofono_netreg *netreg,
const char *mcc, const char *mnc,
ofono_netreg_register_cb_t cb, void *data)
Expand Down

0 comments on commit 544f02e

Please sign in to comment.