Rename destroyAndAwaitReplacement to unregisterAfterReplacement.
Rename requested by API council. Fix: 224764301 Test: existing CTS tests updated Change-Id: Ibab9c9cd64bf0dde1e22705e81cff11d356fc719
This commit is contained in:
@@ -236,7 +236,6 @@ package android.net {
|
|||||||
public abstract class NetworkAgent {
|
public abstract class NetworkAgent {
|
||||||
ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, int, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider);
|
ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, int, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider);
|
||||||
ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, @NonNull android.net.NetworkScore, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider);
|
ctor public NetworkAgent(@NonNull android.content.Context, @NonNull android.os.Looper, @NonNull String, @NonNull android.net.NetworkCapabilities, @NonNull android.net.LinkProperties, @NonNull android.net.NetworkScore, @NonNull android.net.NetworkAgentConfig, @Nullable android.net.NetworkProvider);
|
||||||
method public void destroyAndAwaitReplacement(@IntRange(from=0, to=0x1388) int);
|
|
||||||
method @Nullable public android.net.Network getNetwork();
|
method @Nullable public android.net.Network getNetwork();
|
||||||
method public void markConnected();
|
method public void markConnected();
|
||||||
method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData);
|
method public void onAddKeepalivePacketFilter(int, @NonNull android.net.KeepalivePacketData);
|
||||||
@@ -271,6 +270,7 @@ package android.net {
|
|||||||
method public void setTeardownDelayMillis(@IntRange(from=0, to=0x1388) int);
|
method public void setTeardownDelayMillis(@IntRange(from=0, to=0x1388) int);
|
||||||
method public final void setUnderlyingNetworks(@Nullable java.util.List<android.net.Network>);
|
method public final void setUnderlyingNetworks(@Nullable java.util.List<android.net.Network>);
|
||||||
method public void unregister();
|
method public void unregister();
|
||||||
|
method public void unregisterAfterReplacement(@IntRange(from=0, to=0x1388) int);
|
||||||
field public static final int VALIDATION_STATUS_NOT_VALID = 2; // 0x2
|
field public static final int VALIDATION_STATUS_NOT_VALID = 2; // 0x2
|
||||||
field public static final int VALIDATION_STATUS_VALID = 1; // 0x1
|
field public static final int VALIDATION_STATUS_VALID = 1; // 0x1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,5 +47,5 @@ oneway interface INetworkAgentRegistry {
|
|||||||
void sendAddDscpPolicy(in DscpPolicy policy);
|
void sendAddDscpPolicy(in DscpPolicy policy);
|
||||||
void sendRemoveDscpPolicy(int policyId);
|
void sendRemoveDscpPolicy(int policyId);
|
||||||
void sendRemoveAllDscpPolicies();
|
void sendRemoveAllDscpPolicies();
|
||||||
void sendDestroyAndAwaitReplacement(int timeoutMillis);
|
void sendUnregisterAfterReplacement(int timeoutMillis);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ public abstract class NetworkAgent {
|
|||||||
* arg1 = timeout in milliseconds
|
* arg1 = timeout in milliseconds
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final int EVENT_DESTROY_AND_AWAIT_REPLACEMENT = BASE + 29;
|
public static final int EVENT_UNREGISTER_AFTER_REPLACEMENT = BASE + 29;
|
||||||
|
|
||||||
private static NetworkInfo getLegacyNetworkInfo(final NetworkAgentConfig config) {
|
private static NetworkInfo getLegacyNetworkInfo(final NetworkAgentConfig config) {
|
||||||
final NetworkInfo ni = new NetworkInfo(config.legacyType, config.legacySubType,
|
final NetworkInfo ni = new NetworkInfo(config.legacyType, config.legacySubType,
|
||||||
@@ -984,9 +984,9 @@ public abstract class NetworkAgent {
|
|||||||
* @param timeoutMillis the timeout after which this network will be unregistered even if
|
* @param timeoutMillis the timeout after which this network will be unregistered even if
|
||||||
* {@link #unregister} was not called.
|
* {@link #unregister} was not called.
|
||||||
*/
|
*/
|
||||||
public void destroyAndAwaitReplacement(
|
public void unregisterAfterReplacement(
|
||||||
@IntRange(from = 0, to = MAX_TEARDOWN_DELAY_MS) int timeoutMillis) {
|
@IntRange(from = 0, to = MAX_TEARDOWN_DELAY_MS) int timeoutMillis) {
|
||||||
queueOrSendMessage(reg -> reg.sendDestroyAndAwaitReplacement(timeoutMillis));
|
queueOrSendMessage(reg -> reg.sendUnregisterAfterReplacement(timeoutMillis));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
NetworkMonitor will continue to attempt validation, and if it fails after this time has passed,
|
NetworkMonitor will continue to attempt validation, and if it fails after this time has passed,
|
||||||
the network will be marked unvalidated.
|
the network will be marked unvalidated.
|
||||||
|
|
||||||
Only supported up to S. On T+, the Wi-Fi code should use destroyAndAwaitReplacement in order
|
Only supported up to S. On T+, the Wi-Fi code should use unregisterAfterReplacement in order
|
||||||
to ensure that apps see the network disconnect and reconnect. -->
|
to ensure that apps see the network disconnect and reconnect. -->
|
||||||
<integer translatable="false" name="config_validationFailureAfterRoamIgnoreTimeMillis">-1</integer>
|
<integer translatable="false" name="config_validationFailureAfterRoamIgnoreTimeMillis">-1</integer>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -3648,7 +3648,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NetworkAgent.EVENT_DESTROY_AND_AWAIT_REPLACEMENT: {
|
case NetworkAgent.EVENT_UNREGISTER_AFTER_REPLACEMENT: {
|
||||||
// If nai is not yet created, or is already destroyed, ignore.
|
// If nai is not yet created, or is already destroyed, ignore.
|
||||||
if (!shouldDestroyNativeNetwork(nai)) break;
|
if (!shouldDestroyNativeNetwork(nai)) break;
|
||||||
|
|
||||||
@@ -4213,7 +4213,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldIgnoreValidationFailureAfterRoam(NetworkAgentInfo nai) {
|
private boolean shouldIgnoreValidationFailureAfterRoam(NetworkAgentInfo nai) {
|
||||||
// T+ devices should use destroyAndAwaitReplacement.
|
// T+ devices should use unregisterAfterReplacement.
|
||||||
if (SdkLevel.isAtLeastT()) return false;
|
if (SdkLevel.isAtLeastT()) return false;
|
||||||
final long blockTimeOut = Long.valueOf(mResources.get().getInteger(
|
final long blockTimeOut = Long.valueOf(mResources.get().getInteger(
|
||||||
R.integer.config_validationFailureAfterRoamIgnoreTimeMillis));
|
R.integer.config_validationFailureAfterRoamIgnoreTimeMillis));
|
||||||
|
|||||||
@@ -736,8 +736,8 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo>, NetworkRa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendDestroyAndAwaitReplacement(final int timeoutMillis) {
|
public void sendUnregisterAfterReplacement(final int timeoutMillis) {
|
||||||
mHandler.obtainMessage(NetworkAgent.EVENT_DESTROY_AND_AWAIT_REPLACEMENT,
|
mHandler.obtainMessage(NetworkAgent.EVENT_UNREGISTER_AFTER_REPLACEMENT,
|
||||||
new Pair<>(NetworkAgentInfo.this, timeoutMillis)).sendToTarget();
|
new Pair<>(NetworkAgentInfo.this, timeoutMillis)).sendToTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1152,7 +1152,7 @@ class NetworkAgentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDestroyAndAwaitReplacement() {
|
fun testUnregisterAfterReplacement() {
|
||||||
// Keeps an eye on all test networks.
|
// Keeps an eye on all test networks.
|
||||||
val matchAllCallback = TestableNetworkCallback(timeoutMs = DEFAULT_TIMEOUT_MS)
|
val matchAllCallback = TestableNetworkCallback(timeoutMs = DEFAULT_TIMEOUT_MS)
|
||||||
registerNetworkCallback(makeTestNetworkRequest(), matchAllCallback)
|
registerNetworkCallback(makeTestNetworkRequest(), matchAllCallback)
|
||||||
@@ -1180,15 +1180,15 @@ class NetworkAgentTest {
|
|||||||
// Mark the first network as awaiting replacement. This should destroy the underlying
|
// Mark the first network as awaiting replacement. This should destroy the underlying
|
||||||
// native network and send onNetworkDestroyed, but will not send any NetworkCallbacks,
|
// native network and send onNetworkDestroyed, but will not send any NetworkCallbacks,
|
||||||
// because for callback and scoring purposes network1 is still connected.
|
// because for callback and scoring purposes network1 is still connected.
|
||||||
agent1.destroyAndAwaitReplacement(5_000 /* timeoutMillis */)
|
agent1.unregisterAfterReplacement(5_000 /* timeoutMillis */)
|
||||||
agent1.expectCallback<OnNetworkDestroyed>()
|
agent1.expectCallback<OnNetworkDestroyed>()
|
||||||
assertThrows(IOException::class.java) { network1.bindSocket(DatagramSocket()) }
|
assertThrows(IOException::class.java) { network1.bindSocket(DatagramSocket()) }
|
||||||
assertNotNull(mCM.getLinkProperties(network1))
|
assertNotNull(mCM.getLinkProperties(network1))
|
||||||
|
|
||||||
// Calling destroyAndAwaitReplacement more than once has no effect.
|
// Calling unregisterAfterReplacement more than once has no effect.
|
||||||
// If it did, this test would fail because the 1ms timeout means that the network would be
|
// If it did, this test would fail because the 1ms timeout means that the network would be
|
||||||
// torn down before the replacement arrives.
|
// torn down before the replacement arrives.
|
||||||
agent1.destroyAndAwaitReplacement(1 /* timeoutMillis */)
|
agent1.unregisterAfterReplacement(1 /* timeoutMillis */)
|
||||||
|
|
||||||
// Connect a third network. Because network1 is awaiting replacement, network3 is preferred
|
// Connect a third network. Because network1 is awaiting replacement, network3 is preferred
|
||||||
// as soon as it validates (until then, it is outscored by network1).
|
// as soon as it validates (until then, it is outscored by network1).
|
||||||
@@ -1216,14 +1216,14 @@ class NetworkAgentTest {
|
|||||||
matchAllCallback.expectCallback<Losing>(network3)
|
matchAllCallback.expectCallback<Losing>(network3)
|
||||||
testCallback.expectAvailableCallbacks(network4, validated = true)
|
testCallback.expectAvailableCallbacks(network4, validated = true)
|
||||||
mCM.unregisterNetworkCallback(agent4callback)
|
mCM.unregisterNetworkCallback(agent4callback)
|
||||||
agent3.destroyAndAwaitReplacement(5_000)
|
agent3.unregisterAfterReplacement(5_000)
|
||||||
agent3.expectCallback<OnNetworkUnwanted>()
|
agent3.expectCallback<OnNetworkUnwanted>()
|
||||||
matchAllCallback.expectCallback<Lost>(network3, 1000L)
|
matchAllCallback.expectCallback<Lost>(network3, 1000L)
|
||||||
agent3.expectCallback<OnNetworkDestroyed>()
|
agent3.expectCallback<OnNetworkDestroyed>()
|
||||||
|
|
||||||
// Now mark network4 awaiting replacement with a low timeout, and check that if no
|
// Now mark network4 awaiting replacement with a low timeout, and check that if no
|
||||||
// replacement arrives, it is torn down.
|
// replacement arrives, it is torn down.
|
||||||
agent4.destroyAndAwaitReplacement(100 /* timeoutMillis */)
|
agent4.unregisterAfterReplacement(100 /* timeoutMillis */)
|
||||||
matchAllCallback.expectCallback<Lost>(network4, 1000L /* timeoutMs */)
|
matchAllCallback.expectCallback<Lost>(network4, 1000L /* timeoutMs */)
|
||||||
testCallback.expectCallback<Lost>(network4, 1000L /* timeoutMs */)
|
testCallback.expectCallback<Lost>(network4, 1000L /* timeoutMs */)
|
||||||
agent4.expectCallback<OnNetworkDestroyed>()
|
agent4.expectCallback<OnNetworkDestroyed>()
|
||||||
@@ -1234,7 +1234,7 @@ class NetworkAgentTest {
|
|||||||
val (agent5, network5) = connectNetwork()
|
val (agent5, network5) = connectNetwork()
|
||||||
matchAllCallback.expectAvailableThenValidatedCallbacks(network5)
|
matchAllCallback.expectAvailableThenValidatedCallbacks(network5)
|
||||||
testCallback.expectAvailableThenValidatedCallbacks(network5)
|
testCallback.expectAvailableThenValidatedCallbacks(network5)
|
||||||
agent5.destroyAndAwaitReplacement(5_000 /* timeoutMillis */)
|
agent5.unregisterAfterReplacement(5_000 /* timeoutMillis */)
|
||||||
agent5.unregister()
|
agent5.unregister()
|
||||||
matchAllCallback.expectCallback<Lost>(network5, 1000L /* timeoutMs */)
|
matchAllCallback.expectCallback<Lost>(network5, 1000L /* timeoutMs */)
|
||||||
testCallback.expectCallback<Lost>(network5, 1000L /* timeoutMs */)
|
testCallback.expectCallback<Lost>(network5, 1000L /* timeoutMs */)
|
||||||
@@ -1257,7 +1257,7 @@ class NetworkAgentTest {
|
|||||||
it.hasCapability(NET_CAPABILITY_VALIDATED)
|
it.hasCapability(NET_CAPABILITY_VALIDATED)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifiAgent.destroyAndAwaitReplacement(5_000 /* timeoutMillis */)
|
wifiAgent.unregisterAfterReplacement(5_000 /* timeoutMillis */)
|
||||||
wifiAgent.expectCallback<OnNetworkDestroyed>()
|
wifiAgent.expectCallback<OnNetworkDestroyed>()
|
||||||
|
|
||||||
// Once the network is awaiting replacement, changing LinkProperties, NetworkCapabilities or
|
// Once the network is awaiting replacement, changing LinkProperties, NetworkCapabilities or
|
||||||
|
|||||||
Reference in New Issue
Block a user