Update Mobile Data State on subscription changes.

This CL ensures that Vcn instances refresh their mobile data state
when they receive a new TelephonySubscriptionSnapshot. A new snapshot
may contain different subId -> subGroup mappings, which can affect
whether a Vcn instance's subGroup has mobile data enabled or not. This
in turn can change which VcnGatewayConnections are brought up by the
Vcn.

Bug: 191394092
Test: atest FrameworksVcnTests CtsVcnTestCases
Original-Change: https://android-review.googlesource.com/1740514
Merged-In: Ib59b4ed7900a177b17ed4a6e197e271b10937f65
Change-Id: Ib59b4ed7900a177b17ed4a6e197e271b10937f65
This commit is contained in:
Cody Kesting
2021-06-18 02:18:22 +00:00
parent cc265a58de
commit 1dba7e09df
2 changed files with 25 additions and 0 deletions

View File

@@ -242,6 +242,27 @@ public class VcnTest {
verifyUpdateSubscriptionSnapshotNotifiesGatewayConnections(VCN_STATUS_CODE_SAFE_MODE);
}
@Test
public void testSubscriptionSnapshotUpdatesMobileDataState() {
final NetworkRequestListener requestListener = verifyAndGetRequestListener();
startVcnGatewayWithCapabilities(requestListener, TEST_CAPS[0]);
// Expect mobile data enabled from setUp()
assertTrue(mVcn.isMobileDataEnabled());
final TelephonySubscriptionSnapshot updatedSnapshot =
mock(TelephonySubscriptionSnapshot.class);
doReturn(TEST_SUB_IDS_IN_GROUP)
.when(updatedSnapshot)
.getAllSubIdsInGroup(eq(TEST_SUB_GROUP));
doReturn(false).when(mTelephonyManager).isDataEnabled();
mVcn.updateSubscriptionSnapshot(updatedSnapshot);
mTestLooper.dispatchAll();
assertFalse(mVcn.isMobileDataEnabled());
}
private void triggerVcnRequestListeners(NetworkRequestListener requestListener) {
for (final int[] caps : TEST_CAPS) {
startVcnGatewayWithCapabilities(requestListener, caps);