Don't call maybeTrackInterface on the wrong thread. am: 6123533817 am: dc3c209dd1 am: 962ae21798
Change-Id: I210dea104a8dd0eb4671b2da7b9ddeec103accc0
This commit is contained in:
@@ -193,9 +193,11 @@ final class EthernetTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIncludeTestInterfaces(boolean include) {
|
public void setIncludeTestInterfaces(boolean include) {
|
||||||
|
mHandler.post(() -> {
|
||||||
mIncludeTestInterfaces = include;
|
mIncludeTestInterfaces = include;
|
||||||
updateIfaceMatchRegexp();
|
updateIfaceMatchRegexp();
|
||||||
trackAvailableInterfaces();
|
mHandler.post(() -> trackAvailableInterfaces());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestTetheredInterface(ITetheredInterfaceCallback callback) {
|
public void requestTetheredInterface(ITetheredInterfaceCallback callback) {
|
||||||
@@ -307,7 +309,7 @@ final class EthernetTracker {
|
|||||||
ipConfiguration = createDefaultIpConfiguration();
|
ipConfiguration = createDefaultIpConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "Started tracking interface " + iface);
|
Log.d(TAG, "Tracking interface in client mode: " + iface);
|
||||||
mFactory.addInterface(iface, hwAddress, nc, ipConfiguration);
|
mFactory.addInterface(iface, hwAddress, nc, ipConfiguration);
|
||||||
} else {
|
} else {
|
||||||
maybeUpdateServerModeInterfaceState(iface, true);
|
maybeUpdateServerModeInterfaceState(iface, true);
|
||||||
@@ -349,6 +351,9 @@ final class EthernetTracker {
|
|||||||
private void maybeUpdateServerModeInterfaceState(String iface, boolean available) {
|
private void maybeUpdateServerModeInterfaceState(String iface, boolean available) {
|
||||||
if (available == mTetheredInterfaceWasAvailable || !iface.equals(mDefaultInterface)) return;
|
if (available == mTetheredInterfaceWasAvailable || !iface.equals(mDefaultInterface)) return;
|
||||||
|
|
||||||
|
Log.d(TAG, (available ? "Tracking" : "No longer tracking")
|
||||||
|
+ " interface in server mode: " + iface);
|
||||||
|
|
||||||
final int pendingCbs = mTetheredInterfaceRequests.beginBroadcast();
|
final int pendingCbs = mTetheredInterfaceRequests.beginBroadcast();
|
||||||
for (int i = 0; i < pendingCbs; i++) {
|
for (int i = 0; i < pendingCbs; i++) {
|
||||||
ITetheredInterfaceCallback item = mTetheredInterfaceRequests.getBroadcastItem(i);
|
ITetheredInterfaceCallback item = mTetheredInterfaceRequests.getBroadcastItem(i);
|
||||||
@@ -363,14 +368,18 @@ final class EthernetTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void maybeTrackInterface(String iface) {
|
private void maybeTrackInterface(String iface) {
|
||||||
if (DBG) Log.i(TAG, "maybeTrackInterface " + iface);
|
if (!iface.matches(mIfaceMatch)) {
|
||||||
// If we don't already track this interface, and if this interface matches
|
|
||||||
// our regex, start tracking it.
|
|
||||||
if (!iface.matches(mIfaceMatch) || mFactory.hasInterface(iface)
|
|
||||||
|| iface.equals(mDefaultInterface)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we don't already track this interface, and if this interface matches
|
||||||
|
// our regex, start tracking it.
|
||||||
|
if (mFactory.hasInterface(iface) || iface.equals(mDefaultInterface)) {
|
||||||
|
if (DBG) Log.w(TAG, "Ignoring already-tracked interface " + iface);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (DBG) Log.i(TAG, "maybeTrackInterface: " + iface);
|
||||||
|
|
||||||
// TODO: avoid making an interface default if it has configured NetworkCapabilities.
|
// TODO: avoid making an interface default if it has configured NetworkCapabilities.
|
||||||
if (mDefaultInterface == null) {
|
if (mDefaultInterface == null) {
|
||||||
mDefaultInterface = iface;
|
mDefaultInterface = iface;
|
||||||
|
|||||||
Reference in New Issue
Block a user