Use system property gateway if not using WiFi

When running with WiFi the IPv4 gateway for the radio interface is known
and can be hardcoded, even if TAP is enabled. This is because the
gateway is the internal address in the router namespace. Without WiFi
the radio interface is eth0, the public interface. The gateway for this
interface can be dynamic if running with TAP networking so in that case
it can't use a hardcoded gateway the way it used to. The DHCP client
will set the net.eth0.gw system property to the gateway of the host
network so use that property to give the correct gateway to the radio
interface.
Bug: 72886046
Test: manual, build and ran the emulator (steps from CTS tests)
Change-Id: I110a1216cccc846a48befe4c8cb2e602ed63752f
(cherry picked from commit cf111309af68ab095371ef495d2c78e1faf885a6)
(cherry picked from commit 0de94de9dc67db550f50bf2ffe3360b7ce02907d)
diff --git a/reference-ril/reference-ril.c b/reference-ril/reference-ril.c
index 1a1eb9b..b04db97 100644
--- a/reference-ril/reference-ril.c
+++ b/reference-ril/reference-ril.c
@@ -34,8 +34,8 @@
 #include "misc.h"
 #include <getopt.h>
 #include <sys/socket.h>
+#include <cutils/properties.h>
 #include <cutils/sockets.h>
-#include <sys/system_properties.h>
 #include <termios.h>
 #include <qemu_pipe.h>
 #include <sys/wait.h>
@@ -567,7 +567,7 @@
 static bool hasWifiCapability()
 {
     char propValue[PROP_VALUE_MAX];
-    return __system_property_get("ro.kernel.qemu.wifi", propValue) != 0 &&
+    return property_get("ro.kernel.qemu.wifi", propValue, "") > 0 &&
            strcmp("1", propValue) == 0;
 }
 
@@ -726,7 +726,7 @@
                 snprintf(propName, sizeof propName, "net.eth0.dns%d", nn);
 
                 /* Ignore if undefined */
-                if (__system_property_get(propName, propValue) == 0) {
+                if (property_get(propName, propValue, "") <= 0) {
                     continue;
                 }
 
@@ -740,7 +740,13 @@
             /* 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 = hasWifi ? "192.168.200.1" : "10.0.2.2";
+            if (hasWifi) {
+                responses[i].gateways = "192.168.200.1";
+            } else if (property_get("net.eth0.gw", propValue, "") > 0) {
+                responses[i].gateways = propValue;
+            } else {
+                responses[i].gateways = "";
+            }
             responses[i].mtu = DEFAULT_MTU;
         }
         else {