Disable tryCell when UpstreamMonitor stop
tryCell configuration would not be force disabled UpstreamMonitor stop. If tethering stop with using mobile upstream and swap with SIM fron no dun to dun supported, dun request would be filed even tethering is not active. Bug: 173068192 Test: atest TetheringTests Change-Id: I5505655f52da9fdca2fd43a58e043a9ab727741d
This commit is contained in:
@@ -191,7 +191,7 @@ public class UpstreamNetworkMonitor {
|
|||||||
* check even tethering is not active yet.
|
* check even tethering is not active yet.
|
||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
releaseMobileNetworkRequest();
|
setTryCell(false);
|
||||||
|
|
||||||
releaseCallback(mListenAllCallback);
|
releaseCallback(mListenAllCallback);
|
||||||
mListenAllCallback = null;
|
mListenAllCallback = null;
|
||||||
|
|||||||
@@ -398,11 +398,6 @@ public class TetheringTest {
|
|||||||
StateMachine mUpstreamNetworkMonitorSM;
|
StateMachine mUpstreamNetworkMonitorSM;
|
||||||
ArrayList<IpServer> mIpv6CoordinatorNotifyList;
|
ArrayList<IpServer> mIpv6CoordinatorNotifyList;
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
mUpstreamNetworkMonitorSM = null;
|
|
||||||
mIpv6CoordinatorNotifyList = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpfCoordinator getBpfCoordinator(
|
public BpfCoordinator getBpfCoordinator(
|
||||||
BpfCoordinator.Dependencies deps) {
|
BpfCoordinator.Dependencies deps) {
|
||||||
@@ -685,7 +680,6 @@ public class TetheringTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Tethering makeTethering() {
|
private Tethering makeTethering() {
|
||||||
mTetheringDependencies.reset();
|
|
||||||
return new Tethering(mTetheringDependencies);
|
return new Tethering(mTetheringDependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1086,6 +1080,11 @@ public class TetheringTest {
|
|||||||
verify(mUpstreamNetworkMonitor, times(1)).setCurrentUpstream(upstreamState.network);
|
verify(mUpstreamNetworkMonitor, times(1)).setCurrentUpstream(upstreamState.network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void verifyDisableTryCellWhenTetheringStop(InOrder inOrder) {
|
||||||
|
runStopUSBTethering();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void upstreamSelectionTestCommon(final boolean automatic, InOrder inOrder,
|
private void upstreamSelectionTestCommon(final boolean automatic, InOrder inOrder,
|
||||||
TestNetworkAgent mobile, TestNetworkAgent wifi) throws Exception {
|
TestNetworkAgent mobile, TestNetworkAgent wifi) throws Exception {
|
||||||
// Enable automatic upstream selection.
|
// Enable automatic upstream selection.
|
||||||
@@ -1109,6 +1108,7 @@ public class TetheringTest {
|
|||||||
wifi.fakeConnect();
|
wifi.fakeConnect();
|
||||||
mCm.makeDefaultNetwork(wifi, BROADCAST_FIRST);
|
mCm.makeDefaultNetwork(wifi, BROADCAST_FIRST);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(false);
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1131,6 +1131,7 @@ public class TetheringTest {
|
|||||||
|
|
||||||
mCm.makeDefaultNetwork(wifi, BROADCAST_FIRST, doDispatchAll);
|
mCm.makeDefaultNetwork(wifi, BROADCAST_FIRST, doDispatchAll);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(false);
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
|
||||||
|
|
||||||
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST);
|
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST);
|
||||||
@@ -1139,6 +1140,7 @@ public class TetheringTest {
|
|||||||
|
|
||||||
mCm.makeDefaultNetwork(wifi, CALLBACKS_FIRST);
|
mCm.makeDefaultNetwork(wifi, CALLBACKS_FIRST);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(false);
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
|
||||||
|
|
||||||
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST, doDispatchAll);
|
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST, doDispatchAll);
|
||||||
@@ -1157,6 +1159,7 @@ public class TetheringTest {
|
|||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
mobile.fakeDisconnect();
|
mobile.fakeDisconnect();
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(true);
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
||||||
|
|
||||||
mobile = new TestNetworkAgent(mCm, buildMobile464xlatUpstreamState());
|
mobile = new TestNetworkAgent(mCm, buildMobile464xlatUpstreamState());
|
||||||
@@ -1174,6 +1177,7 @@ public class TetheringTest {
|
|||||||
mCm.makeDefaultNetwork(null, CALLBACKS_FIRST, doDispatchAll);
|
mCm.makeDefaultNetwork(null, CALLBACKS_FIRST, doDispatchAll);
|
||||||
mobile.fakeDisconnect();
|
mobile.fakeDisconnect();
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(true);
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
||||||
|
|
||||||
mobile = new TestNetworkAgent(mCm, buildMobileDualStackUpstreamState());
|
mobile = new TestNetworkAgent(mCm, buildMobileDualStackUpstreamState());
|
||||||
@@ -1189,6 +1193,8 @@ public class TetheringTest {
|
|||||||
mobile.fakeDisconnect();
|
mobile.fakeDisconnect();
|
||||||
mobile.sendLinkProperties();
|
mobile.sendLinkProperties();
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
|
||||||
|
verifyDisableTryCellWhenTetheringStop(inOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1211,6 +1217,10 @@ public class TetheringTest {
|
|||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
mCm.makeDefaultNetwork(wifi, CALLBACKS_FIRST, null);
|
mCm.makeDefaultNetwork(wifi, CALLBACKS_FIRST, null);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(false);
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
|
||||||
|
|
||||||
|
verifyDisableTryCellWhenTetheringStop(inOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1226,6 +1236,7 @@ public class TetheringTest {
|
|||||||
// automatic mode would request dun again and choose it as upstream.
|
// automatic mode would request dun again and choose it as upstream.
|
||||||
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST);
|
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(true);
|
||||||
ArgumentCaptor<NetworkCallback> captor = ArgumentCaptor.forClass(NetworkCallback.class);
|
ArgumentCaptor<NetworkCallback> captor = ArgumentCaptor.forClass(NetworkCallback.class);
|
||||||
inOrder.verify(mCm).requestNetwork(any(), eq(0), eq(TYPE_MOBILE_DUN), any(), any());
|
inOrder.verify(mCm).requestNetwork(any(), eq(0), eq(TYPE_MOBILE_DUN), any(), any());
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
||||||
@@ -1237,11 +1248,14 @@ public class TetheringTest {
|
|||||||
// Lose and regain upstream again.
|
// Lose and regain upstream again.
|
||||||
dun.fakeDisconnect(CALLBACKS_FIRST, doDispatchAll);
|
dun.fakeDisconnect(CALLBACKS_FIRST, doDispatchAll);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(true);
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(null);
|
||||||
inOrder.verify(mCm, never()).unregisterNetworkCallback(any(NetworkCallback.class));
|
inOrder.verify(mCm, never()).unregisterNetworkCallback(any(NetworkCallback.class));
|
||||||
dun.fakeConnect(CALLBACKS_FIRST, doDispatchAll);
|
dun.fakeConnect(CALLBACKS_FIRST, doDispatchAll);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(dun.networkId);
|
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(dun.networkId);
|
||||||
|
|
||||||
|
verifyDisableTryCellWhenTetheringStop(inOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1257,6 +1271,7 @@ public class TetheringTest {
|
|||||||
// list).
|
// list).
|
||||||
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST);
|
mCm.makeDefaultNetwork(mobile, CALLBACKS_FIRST);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(false);
|
||||||
inOrder.verify(mUpstreamNetworkMonitor, never()).setCurrentUpstream(any());
|
inOrder.verify(mUpstreamNetworkMonitor, never()).setCurrentUpstream(any());
|
||||||
// BUG: when wifi disconnect, the dun request would not be filed again because wifi is
|
// BUG: when wifi disconnect, the dun request would not be filed again because wifi is
|
||||||
// no longer be default network which do not have CONNECTIVIY_ACTION broadcast.
|
// no longer be default network which do not have CONNECTIVIY_ACTION broadcast.
|
||||||
@@ -1278,8 +1293,11 @@ public class TetheringTest {
|
|||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
// BUG: dun has higher priority than wifi but tethering don't file dun request because
|
// BUG: dun has higher priority than wifi but tethering don't file dun request because
|
||||||
// current upstream is wifi.
|
// current upstream is wifi.
|
||||||
|
inOrder.verify(mUpstreamNetworkMonitor).setTryCell(false);
|
||||||
inOrder.verify(mCm, never()).requestNetwork(any(), eq(0), eq(TYPE_MOBILE_DUN), any(),
|
inOrder.verify(mCm, never()).requestNetwork(any(), eq(0), eq(TYPE_MOBILE_DUN), any(),
|
||||||
any());
|
any());
|
||||||
|
|
||||||
|
verifyDisableTryCellWhenTetheringStop(inOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseDunUpstreamTestCommon(final boolean automatic, InOrder inOrder,
|
private void chooseDunUpstreamTestCommon(final boolean automatic, InOrder inOrder,
|
||||||
|
|||||||
Reference in New Issue
Block a user