Loading core/java/android/net/InterfaceConfiguration.java +24 −2 Original line number Diff line number Diff line Loading @@ -39,14 +39,36 @@ public class InterfaceConfiguration implements Parcelable { public String toString() { StringBuffer str = new StringBuffer(); str.append("ipddress "); str.append(addr.toString()); str.append(" netmask "); str.append(mask.toString()); str.append("ipddress "); str.append((addr != null) ? addr.toString() : "NULL"); str.append(" netmask "); str.append((mask != null) ? mask.toString() : "NULL"); str.append(" flags ").append(interfaceFlags); str.append(" hwaddr ").append(hwAddr); return str.toString(); } /** * This function determines if the interface is up and has a valid IP * configuration (IP address has a non zero octet). * * Note: It is supposed to be quick and hence should not initiate * any network activity */ public boolean isActive() { try { if(interfaceFlags.contains("up")) { for (byte b : addr.getAddress()) { if (b != 0) return true; } } } catch (NullPointerException e) { return false; } return false; } /** Implement the Parcelable interface {@hide} */ public int describeContents() { return 0; Loading services/java/com/android/server/connectivity/Tethering.java +4 −4 Original line number Diff line number Diff line Loading @@ -1233,18 +1233,18 @@ public class Tethering extends INetworkManagementEventObserver.Stub { for (String iface : ifaces) { for (String regex : mUpstreamIfaceRegexs) { if (iface.matches(regex)) { // verify it is up! // verify it is active InterfaceConfiguration ifcg = null; try { ifcg = service.getInterfaceConfig(iface); if (ifcg.isActive()) { return iface; } } catch (Exception e) { Log.e(TAG, "Error getting iface config :" + e); // ignore - try next continue; } if (ifcg.interfaceFlags.contains("up")) { return iface; } } } } Loading Loading
core/java/android/net/InterfaceConfiguration.java +24 −2 Original line number Diff line number Diff line Loading @@ -39,14 +39,36 @@ public class InterfaceConfiguration implements Parcelable { public String toString() { StringBuffer str = new StringBuffer(); str.append("ipddress "); str.append(addr.toString()); str.append(" netmask "); str.append(mask.toString()); str.append("ipddress "); str.append((addr != null) ? addr.toString() : "NULL"); str.append(" netmask "); str.append((mask != null) ? mask.toString() : "NULL"); str.append(" flags ").append(interfaceFlags); str.append(" hwaddr ").append(hwAddr); return str.toString(); } /** * This function determines if the interface is up and has a valid IP * configuration (IP address has a non zero octet). * * Note: It is supposed to be quick and hence should not initiate * any network activity */ public boolean isActive() { try { if(interfaceFlags.contains("up")) { for (byte b : addr.getAddress()) { if (b != 0) return true; } } } catch (NullPointerException e) { return false; } return false; } /** Implement the Parcelable interface {@hide} */ public int describeContents() { return 0; Loading
services/java/com/android/server/connectivity/Tethering.java +4 −4 Original line number Diff line number Diff line Loading @@ -1233,18 +1233,18 @@ public class Tethering extends INetworkManagementEventObserver.Stub { for (String iface : ifaces) { for (String regex : mUpstreamIfaceRegexs) { if (iface.matches(regex)) { // verify it is up! // verify it is active InterfaceConfiguration ifcg = null; try { ifcg = service.getInterfaceConfig(iface); if (ifcg.isActive()) { return iface; } } catch (Exception e) { Log.e(TAG, "Error getting iface config :" + e); // ignore - try next continue; } if (ifcg.interfaceFlags.contains("up")) { return iface; } } } } Loading