Don't call maybeTrackInterface on the wrong thread. am: bd66333a24 am: fbe05a3c1a am: b8327f43aa am: cbbac4940d

Change-Id: I21e3c0cc4bc64c540fc0e19590b4b143bce8215a
This commit is contained in:
Lorenzo Colitti
2020-03-26 10:35:33 +00:00
committed by Automerger Merge Worker

View File

@@ -193,9 +193,11 @@ final class EthernetTracker {
}
public void setIncludeTestInterfaces(boolean include) {
mIncludeTestInterfaces = include;
updateIfaceMatchRegexp();
trackAvailableInterfaces();
mHandler.post(() -> {
mIncludeTestInterfaces = include;
updateIfaceMatchRegexp();
mHandler.post(() -> trackAvailableInterfaces());
});
}
public void requestTetheredInterface(ITetheredInterfaceCallback callback) {
@@ -307,7 +309,7 @@ final class EthernetTracker {
ipConfiguration = createDefaultIpConfiguration();
}
Log.d(TAG, "Started tracking interface " + iface);
Log.d(TAG, "Tracking interface in client mode: " + iface);
mFactory.addInterface(iface, hwAddress, nc, ipConfiguration);
} else {
maybeUpdateServerModeInterfaceState(iface, true);
@@ -349,6 +351,9 @@ final class EthernetTracker {
private void maybeUpdateServerModeInterfaceState(String iface, boolean available) {
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();
for (int i = 0; i < pendingCbs; i++) {
ITetheredInterfaceCallback item = mTetheredInterfaceRequests.getBroadcastItem(i);
@@ -363,14 +368,18 @@ final class EthernetTracker {
}
private void maybeTrackInterface(String iface) {
if (DBG) Log.i(TAG, "maybeTrackInterface " + iface);
// 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)) {
if (!iface.matches(mIfaceMatch)) {
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.
if (mDefaultInterface == null) {
mDefaultInterface = iface;