From 34805e23bb384730d4e89e783398fa011cdebf27 Mon Sep 17 00:00:00 2001 From: Jason Jeremy Iman Date: Sun, 25 Oct 2020 15:34:38 +0900 Subject: [PATCH] arc: Use ChromeOS host's IP address for WiFi ADB Wireless debugging in ARC shows guest IP address which is not routable from the local network for other devices. This patch updates the shown IP address to host's IP address. This allows clients to know the correct IP address to connect to. The IP address used is taken from wifi IP of the host set in a property: 'vendor.arc.net.ipv4.host_wifi_address'. ARC R patch: ag/12907009 Bug: 169703040 Bug: 315430652 Test: Manually tested for ARC on tm-arc. Change-Id: Ib66e84872d9004fa3a946f1af9a774709d048f5a --- .../AdbIpAddressPreferenceController.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/development/AdbIpAddressPreferenceController.java b/src/com/android/settings/development/AdbIpAddressPreferenceController.java index 36d1b99e301..e6a60ade01e 100644 --- a/src/com/android/settings/development/AdbIpAddressPreferenceController.java +++ b/src/com/android/settings/development/AdbIpAddressPreferenceController.java @@ -22,8 +22,10 @@ import android.net.ConnectivityManager; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.wifi.WifiManager; +import android.os.Build; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.SystemProperties; import android.util.Log; import androidx.preference.Preference; @@ -100,12 +102,23 @@ public class AdbIpAddressPreferenceController extends AbstractConnectivityPrefer } public String getIpv4Address() { + // ARC specific - from here + // Get the host's Wi-Fi IP address instead of guest's IP. + if (Build.IS_ARC) { + final String[] addrs = + SystemProperties.get("vendor.arc.net.ipv4.host_wifi_address").split(","); + // ADB over Wi-Fi uses the first available available network configuration. + if (addrs.length > 0) { + return addrs[0]; + } + } + // ARC specific - till here. return getDefaultIpAddresses(mCM); } @Override protected void updateConnectivity() { - String ipAddress = getDefaultIpAddresses(mCM); + String ipAddress = getIpv4Address(); if (ipAddress != null) { int port = getPort(); if (port <= 0) {