Merge "Update Mobile Data State on subscription changes." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c9d806644a
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user