Hi, thanks for the work Fil. I have couple comments about the patch.
Fil: > --- > .../com/android/server/ConnectivityService.java | 68 > ++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > > diff --git > a/services/core/java/com/android/server/ConnectivityService.java > b/services/core/java/com/android/server/ConnectivityService.java > index 1489fd8713a..fadc4f4f914 100644 > --- a/services/core/java/com/android/server/ConnectivityService.java > +++ b/services/core/java/com/android/server/ConnectivityService.java > @@ -145,11 +145,13 @@ import java.io.IOException; > import java.io.PrintWriter; > import java.net.Inet4Address; > import java.net.InetAddress; > +import java.net.NetworkInterface; > import java.net.UnknownHostException; > import java.util.ArrayDeque; > import java.util.ArrayList; > import java.util.Arrays; > import java.util.Collection; > +import java.util.Enumeration; > import java.util.HashMap; > import java.util.HashSet; > import java.util.SortedSet; > @@ -1017,9 +1019,75 @@ public class ConnectivityService extends > IConnectivityManager.Stub > final int uid = Binder.getCallingUid(); > NetworkState state = getUnfilteredActiveNetworkState(uid); > NetworkInfo ni = getFilteredNetworkInfo(state.networkInfo, > state.linkProperties, uid); > + > + // TODO RepWifi extension. Remove when a low-level, long-lived > solution is found. > + if (ni == null) { > + ni = getNetworkInfoByInterfaceName(IFACE_NAME_WIFI); > + } > + if (ni == null) { > + ni = getNetworkInfoByInterfaceName(IFACE_NAME_TETHER); > + } > + > maybeLogBlockedNetworkInfo(ni, uid); > return ni; > } > + > + // TODO RepWifi extension. Remove when a low-level, long-lived > solution is found. > + private static final String IFACE_NAME_WIFI = "wlan0"; > + private static final String IFACE_NAME_TETHER = "rndis0"; I think these are now used before this declaration and could be therefore moved bit more upwards. See the line "ni = getNetworkInfoByInterfaceName(IFACE_NAME_TETHER);". > + private NetworkInfo getNetworkInfoByInterfaceName(String ifname) { > + try { > + > + int type = 0; > + String typeName = null; > + > + if (ifname == IFACE_NAME_WIFI) { > + type = ConnectivityManager.TYPE_WIFI; > + typeName = "WIFI"; > + > + } else if (ifname == IFACE_NAME_TETHER) { > + type = ConnectivityManager.TYPE_ETHERNET; > + typeName = "ETHERNET"; > + > + } else { > + return null; > + } > + > + NetworkInterface nifRep = > NetworkInterface.getByName(ifname); > + if (nifRep == null) { > + return null; > + } > + > + Enumeration<InetAddress> ads = nifRep.getInetAddresses(); > + if (ads == null) { > + return null; > + } > + > + while (ads.hasMoreElements()) { > + > + InetAddress a = ads.nextElement(); > + > + if (a.getHostAddress() != null && > a.isSiteLocalAddress()) { > + // if the interface has a valid IP address in the > range of a > + // local network we consider it is connected to an > AP. I think this needs to be widened. The AP could also give a public IP, right? _______________________________________________ Replicant mailing list Replicant@osuosl.org https://lists.osuosl.org/mailman/listinfo/replicant