Merge "Update Mobile Data State on subscription changes." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-06-22 00:55:20 +00:00
committed by Android (Google) Code Review
2 changed files with 25 additions and 0 deletions

View File

@@ -453,6 +453,10 @@ public class Vcn extends Handler {
for (VcnGatewayConnection gatewayConnection : mVcnGatewayConnections.values()) {
gatewayConnection.updateSubscriptionSnapshot(mLastSnapshot);
}
// Update the mobile data state after updating the subscription snapshot as a change in
// subIds for a subGroup may affect the mobile data state.
handleMobileDataToggled();
}
private void handleMobileDataToggled() {

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);