Always send all available state when calling onAvailable().

The state that needs to be transferred includes:
    - NetworkCapabilities
    - LinkProperties
    - whether the network is currently suspended

Additionally:
    - Rename notifyNetworkCallback() to notifyNetworkAvailable()
      in order to clarify its real function.
    - fix previous copy/paste error in unittest

Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - USB tethering with mobile and Wi-Fi upstream toggling
Bug: 32163131
Change-Id: Ib4460bcd5d08863a9feac9e8ab41a238897bb3ea
This commit is contained in:
Erik Kline
2017-02-15 19:59:17 +09:00
parent 1d6742c945
commit 99f301bdfd
3 changed files with 33 additions and 19 deletions

View File

@@ -1170,15 +1170,11 @@ public class ConnectivityServiceTest extends AndroidTestCase {
void expectAvailableCallbacks(MockNetworkAgent agent, boolean expectSuspended, int timeoutMs) {
expectCallback(CallbackState.AVAILABLE, agent, timeoutMs);
final boolean HAS_DATASYNC_ON_AVAILABLE = false;
if (HAS_DATASYNC_ON_AVAILABLE) {
if (expectSuspended) {
expectCallback(CallbackState.SUSPENDED, agent, timeoutMs);
}
expectCallback(CallbackState.NETWORK_CAPABILITIES, agent, timeoutMs);
expectCallback(CallbackState.LINK_PROPERTIES, agent, timeoutMs);
if (expectSuspended) {
expectCallback(CallbackState.SUSPENDED, agent, timeoutMs);
}
expectCallback(CallbackState.NETWORK_CAPABILITIES, agent, timeoutMs);
expectCallback(CallbackState.LINK_PROPERTIES, agent, timeoutMs);
}
void expectAvailableCallbacks(MockNetworkAgent agent) {
@@ -1190,7 +1186,7 @@ public class ConnectivityServiceTest extends AndroidTestCase {
}
void expectAvailableAndValidatedCallbacks(MockNetworkAgent agent) {
expectAvailableCallbacks(agent, true, TIMEOUT_MS);
expectAvailableCallbacks(agent, false, TIMEOUT_MS);
expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, agent);
}