[NS A18] Reverse listens and request-availables
This is a long standing bug that happens to now be trivial to fix, and also be beneficial for refactoring Test: FrameworksNetTests NetworkStackTests Change-Id: I38110f3a4a75936ea755788e7f9fee67863e14be
This commit is contained in:
@@ -6453,6 +6453,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
newNetwork.name(), score, newNetwork.getCurrentScore()));
|
newNetwork.name(), score, newNetwork.getCurrentScore()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify requested networks are available after the default net is switched, but
|
||||||
|
// before LegacyTypeTracker sends legacy broadcasts
|
||||||
|
for (NetworkRequestInfo nri : addedRequests) notifyNetworkAvailable(newNetwork, nri);
|
||||||
|
|
||||||
// Second pass: process all listens.
|
// Second pass: process all listens.
|
||||||
if (wasBackgroundNetwork != newNetwork.isBackgroundNetwork()) {
|
if (wasBackgroundNetwork != newNetwork.isBackgroundNetwork()) {
|
||||||
// If the network went from background to foreground or vice versa, we need to update
|
// If the network went from background to foreground or vice versa, we need to update
|
||||||
@@ -6463,10 +6467,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
} else {
|
} else {
|
||||||
processListenRequests(newNetwork, false);
|
processListenRequests(newNetwork, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do this after the default net is switched, but
|
|
||||||
// before LegacyTypeTracker sends legacy broadcasts
|
|
||||||
for (NetworkRequestInfo nri : addedRequests) notifyNetworkAvailable(newNetwork, nri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3134,14 +3134,11 @@ public class ConnectivityServiceTest {
|
|||||||
.addTransportType(TRANSPORT_CELLULAR).build();
|
.addTransportType(TRANSPORT_CELLULAR).build();
|
||||||
final TestNetworkCallback cellCallback = new TestNetworkCallback();
|
final TestNetworkCallback cellCallback = new TestNetworkCallback();
|
||||||
mCm.requestNetwork(cellRequest, cellCallback);
|
mCm.requestNetwork(cellRequest, cellCallback);
|
||||||
// NOTE: This request causes the network's capabilities to change. This
|
|
||||||
// is currently delivered before the onAvailable() callbacks.
|
|
||||||
// TODO: Fix this.
|
|
||||||
cellCallback.expectCapabilitiesWith(NET_CAPABILITY_FOREGROUND, mCellNetworkAgent);
|
|
||||||
cellCallback.expectAvailableCallbacksValidated(mCellNetworkAgent);
|
cellCallback.expectAvailableCallbacksValidated(mCellNetworkAgent);
|
||||||
fgCallback.expectAvailableCallbacksValidated(mCellNetworkAgent);
|
fgCallback.expectAvailableCallbacksValidated(mCellNetworkAgent);
|
||||||
// Expect a network capabilities update with FOREGROUND, because the most recent
|
// Expect a network capabilities update with FOREGROUND, because the most recent
|
||||||
// request causes its state to change.
|
// request causes its state to change.
|
||||||
|
cellCallback.expectCapabilitiesWith(NET_CAPABILITY_FOREGROUND, mCellNetworkAgent);
|
||||||
callback.expectCapabilitiesWith(NET_CAPABILITY_FOREGROUND, mCellNetworkAgent);
|
callback.expectCapabilitiesWith(NET_CAPABILITY_FOREGROUND, mCellNetworkAgent);
|
||||||
assertTrue(isForegroundNetwork(mCellNetworkAgent));
|
assertTrue(isForegroundNetwork(mCellNetworkAgent));
|
||||||
assertTrue(isForegroundNetwork(mWiFiNetworkAgent));
|
assertTrue(isForegroundNetwork(mWiFiNetworkAgent));
|
||||||
|
|||||||
Reference in New Issue
Block a user