Merge changes I01ffdde2,Iecab1226 am: a5786a15e1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1696089 Change-Id: If24eabfdfa80b036b541c4d3e1bf8064fe80f213
This commit is contained in:
@@ -87,6 +87,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -431,6 +432,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
||||
public void onNewSnapshot(@NonNull TelephonySubscriptionSnapshot snapshot) {
|
||||
// Startup VCN instances
|
||||
synchronized (mLock) {
|
||||
final TelephonySubscriptionSnapshot oldSnapshot = mLastSnapshot;
|
||||
mLastSnapshot = snapshot;
|
||||
|
||||
// Start any VCN instances as necessary
|
||||
@@ -478,10 +480,28 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
||||
entry.getValue().updateSubscriptionSnapshot(mLastSnapshot);
|
||||
}
|
||||
}
|
||||
|
||||
final Map<ParcelUuid, Set<Integer>> oldSubGrpMappings =
|
||||
getSubGroupToSubIdMappings(oldSnapshot);
|
||||
final Map<ParcelUuid, Set<Integer>> currSubGrpMappings =
|
||||
getSubGroupToSubIdMappings(mLastSnapshot);
|
||||
if (!currSubGrpMappings.equals(oldSubGrpMappings)) {
|
||||
notifyAllPolicyListenersLocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private Map<ParcelUuid, Set<Integer>> getSubGroupToSubIdMappings(
|
||||
@NonNull TelephonySubscriptionSnapshot snapshot) {
|
||||
final Map<ParcelUuid, Set<Integer>> subGrpMappings = new ArrayMap<>();
|
||||
for (ParcelUuid subGrp : mVcns.keySet()) {
|
||||
subGrpMappings.put(subGrp, snapshot.getAllSubIdsInGroup(subGrp));
|
||||
}
|
||||
return subGrpMappings;
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
private void stopVcnLocked(@NonNull ParcelUuid uuidToTeardown) {
|
||||
final Vcn vcnToTeardown = mVcns.remove(uuidToTeardown);
|
||||
@@ -815,6 +835,8 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
||||
if (isVcnManagedNetwork) {
|
||||
ncBuilder.removeCapability(
|
||||
NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED);
|
||||
} else {
|
||||
ncBuilder.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED);
|
||||
}
|
||||
|
||||
if (isRestrictedCarrierWifi) {
|
||||
|
||||
@@ -77,6 +77,7 @@ import android.os.test.TestLooper;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
@@ -98,6 +99,7 @@ import java.io.FileNotFoundException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -326,6 +328,17 @@ public class VcnManagementServiceTest {
|
||||
return subIdToGroupMap.get(invocation.getArgument(0));
|
||||
}).when(snapshot).getGroupForSubId(anyInt());
|
||||
|
||||
doAnswer(invocation -> {
|
||||
final ParcelUuid subGrp = invocation.getArgument(0);
|
||||
final Set<Integer> subIds = new ArraySet<>();
|
||||
for (Entry<Integer, ParcelUuid> entry : subIdToGroupMap.entrySet()) {
|
||||
if (entry.getValue().equals(subGrp)) {
|
||||
subIds.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
return subIds;
|
||||
}).when(snapshot).getAllSubIdsInGroup(any());
|
||||
|
||||
final TelephonySubscriptionTrackerCallback cb = getTelephonySubscriptionTrackerCallback();
|
||||
cb.onNewSnapshot(snapshot);
|
||||
|
||||
@@ -914,6 +927,18 @@ public class VcnManagementServiceTest {
|
||||
verify(mMockPolicyListener).onPolicyChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVcnSubIdChangeUpdatesPolicyListener() throws Exception {
|
||||
startAndGetVcnInstance(TEST_UUID_2);
|
||||
mVcnMgmtSvc.addVcnUnderlyingNetworkPolicyListener(mMockPolicyListener);
|
||||
|
||||
triggerSubscriptionTrackerCbAndGetSnapshot(
|
||||
Collections.singleton(TEST_UUID_2),
|
||||
Collections.singletonMap(TEST_SUBSCRIPTION_ID, TEST_UUID_2));
|
||||
|
||||
verify(mMockPolicyListener).onPolicyChanged();
|
||||
}
|
||||
|
||||
private void triggerVcnSafeMode(
|
||||
@NonNull ParcelUuid subGroup,
|
||||
@NonNull TelephonySubscriptionSnapshot snapshot,
|
||||
|
||||
Reference in New Issue
Block a user