gprs: Don't use pri_set_apn for auto activated cids

There are two problems with using pri_set_apn.  The first issue is that
this function was built to be used by the set_property handler and
assumes the presence of a pending DBusMessage.

The second issue is that it touches the settings store.

In the case of auto-activated contexts no pending message exists.  Also,
we should not be touching the settings store as the APN might
potentially be a value that has not been provisioned.  Or in some cases
bogus.
This commit is contained in:
Denis Kenzior 2017-05-09 11:29:49 -05:00
parent 24f36da04d
commit d9cb969dcf
1 changed files with 17 additions and 1 deletions

View File

@ -2009,6 +2009,12 @@ void ofono_gprs_cid_activated(struct ofono_gprs *gprs, unsigned int cid,
return;
}
if (strlen(apn) > OFONO_GPRS_MAX_APN_LENGTH
|| is_valid_apn(apn) == FALSE) {
ofono_error("Context activated with an invalid APN");
return;
}
pri_ctx = find_usable_context(gprs, apn);
if (!pri_ctx) {
@ -2036,9 +2042,19 @@ void ofono_gprs_cid_activated(struct ofono_gprs *gprs, unsigned int cid,
return;
}
/*
* We weren't able to find a context with a matching APN and allocated
* a brand new one instead. Set the APN accordingly
*/
if (strlen(pri_ctx->context.apn) == 0) {
DBusConnection *conn = ofono_dbus_get_connection();
pri_set_apn(pri_ctx, conn, NULL, apn);
strcpy(pri_ctx->context.apn, apn);
ofono_dbus_signal_property_changed(conn, pri_ctx->path,
OFONO_CONNECTION_CONTEXT_INTERFACE,
"AccessPointName",
DBUS_TYPE_STRING, &apn);
}
/* Prevent ofono_gprs_status_notify from changing the 'attached'