am 05f14e2b: Merge "DO NOT MERGE Pick upstream intf with valid IP conf" into gingerbread
* commit '05f14e2bcf78be62b35e85902408ea66103a3881': DO NOT MERGE Pick upstream intf with valid IP conf
This commit is contained in:
@@ -51,6 +51,24 @@ public class InterfaceConfiguration implements Parcelable {
|
|||||||
append(addr & 0xff);
|
append(addr & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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")) {
|
||||||
|
if (ipAddr != 0) return true;
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Implement the Parcelable interface {@hide} */
|
/** Implement the Parcelable interface {@hide} */
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1173,18 +1173,18 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
for (String iface : ifaces) {
|
for (String iface : ifaces) {
|
||||||
for (String regex : mUpstreamIfaceRegexs) {
|
for (String regex : mUpstreamIfaceRegexs) {
|
||||||
if (iface.matches(regex)) {
|
if (iface.matches(regex)) {
|
||||||
// verify it is up!
|
// verify it is active
|
||||||
InterfaceConfiguration ifcg = null;
|
InterfaceConfiguration ifcg = null;
|
||||||
try {
|
try {
|
||||||
ifcg = service.getInterfaceConfig(iface);
|
ifcg = service.getInterfaceConfig(iface);
|
||||||
|
if (ifcg.isActive()) {
|
||||||
|
return iface;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error getting iface config :" + e);
|
Log.e(TAG, "Error getting iface config :" + e);
|
||||||
// ignore - try next
|
// ignore - try next
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ifcg.interfaceFlags.contains("up")) {
|
|
||||||
return iface;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user