Snap for 4623514 from a8bec8983b382917b517e97fa09be5afda468b0c to pi-release
Change-Id: I13f6e477db378a280d9091ce284c4dc7c34db162
diff --git a/reference-ril/reference-ril.c b/reference-ril/reference-ril.c
index 3ab7bee..1ba2508 100644
--- a/reference-ril/reference-ril.c
+++ b/reference-ril/reference-ril.c
@@ -50,7 +50,10 @@
#define MAX_AT_RESPONSE 0x1000
/* pathname returned from RIL_REQUEST_SETUP_DATA_CALL / RIL_REQUEST_SETUP_DEFAULT_PDP */
-#define PPP_TTY_PATH "eth0"
+// This is used if Wifi is not supported, plain old eth0
+#define PPP_TTY_PATH_ETH0 "eth0"
+// This is used if Wifi is supported to separate radio and wifi interface
+#define PPP_TTY_PATH_RADIO0 "radio0"
// Default MTU value
#define DEFAULT_MTU 1500
@@ -508,6 +511,13 @@
RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
}
+static bool hasWifi()
+{
+ char propValue[PROP_VALUE_MAX];
+ return __system_property_get("ro.kernel.qemu.wifi", propValue) != 0 &&
+ strcmp("1", propValue) == 0;
+}
+
static void requestOrSendDataCallList(RIL_Token *t)
{
ATResponse *p_response;
@@ -515,6 +525,8 @@
int err;
int n = 0;
char *out;
+ char propValue[PROP_VALUE_MAX];
+ bool has_wifi = hasWifi();
err = at_send_command_multiline ("AT+CGACT?", "+CGACT:", &p_response);
if (err != 0 || p_response->success == 0) {
@@ -620,9 +632,15 @@
if (err < 0)
goto error;
- int ifname_size = strlen(PPP_TTY_PATH) + 1;
- responses[i].ifname = alloca(ifname_size);
- strlcpy(responses[i].ifname, PPP_TTY_PATH, ifname_size);
+ if (has_wifi) {
+ int ifname_size = strlen(PPP_TTY_PATH_RADIO0) + 1;
+ responses[i].ifname = alloca(ifname_size);
+ strlcpy(responses[i].ifname, PPP_TTY_PATH_RADIO0, ifname_size);
+ } else {
+ int ifname_size = strlen(PPP_TTY_PATH_ETH0) + 1;
+ responses[i].ifname = alloca(ifname_size);
+ strlcpy(responses[i].ifname, PPP_TTY_PATH_ETH0, ifname_size);
+ }
err = at_tok_nextstr(&line, &out);
if (err < 0)
@@ -666,7 +684,10 @@
}
responses[i].dnses = dnslist;
- responses[i].gateways = "10.0.2.2 fe80::2";
+ /* There is only one gateway in the emulator. If WiFi is
+ * configured the interface visible to RIL will be behind a NAT
+ * where the gateway is different. */
+ responses[i].gateways = has_wifi ? "192.168.200.1" : "10.0.2.2";
responses[i].mtu = DEFAULT_MTU;
}
else {