Make unregisterAfterReplacement tear down CONNECTING networks.

Bug: 245823767
Test: new test coverage
Change-Id: Icb47e8375f3f8bff4ac8d0833c9efd8d0ba7cda0
This commit is contained in:
Lorenzo Colitti
2022-09-16 19:53:03 +09:00
parent 26ebf8c97a
commit 82350ea269
2 changed files with 67 additions and 3 deletions

View File

@@ -3639,8 +3639,18 @@ public class ConnectivityService extends IConnectivityManager.Stub
break;
}
case NetworkAgent.EVENT_UNREGISTER_AFTER_REPLACEMENT: {
// If nai is not yet created, or is already destroyed, ignore.
if (!shouldDestroyNativeNetwork(nai)) break;
if (!nai.isCreated()) {
Log.d(TAG, "unregisterAfterReplacement on uncreated " + nai.toShortString()
+ ", tearing down instead");
teardownUnneededNetwork(nai);
break;
}
if (nai.isDestroyed()) {
Log.d(TAG, "unregisterAfterReplacement on destroyed " + nai.toShortString()
+ ", ignoring");
break;
}
final int timeoutMs = (int) arg.second;
if (timeoutMs < 0 || timeoutMs > NetworkAgent.MAX_TEARDOWN_DELAY_MS) {