Merge "Rename getAllNetworkStateSnapshot which should be pluralized"
This commit is contained in:
@@ -7,7 +7,7 @@ package android.net {
|
|||||||
|
|
||||||
public class ConnectivityManager {
|
public class ConnectivityManager {
|
||||||
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void factoryReset();
|
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void factoryReset();
|
||||||
method @NonNull @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.NETWORK_SETTINGS}) public java.util.List<android.net.NetworkStateSnapshot> getAllNetworkStateSnapshot();
|
method @NonNull @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.NETWORK_SETTINGS}) public java.util.List<android.net.NetworkStateSnapshot> getAllNetworkStateSnapshots();
|
||||||
method @Nullable public android.net.ProxyInfo getGlobalProxy();
|
method @Nullable public android.net.ProxyInfo getGlobalProxy();
|
||||||
method @NonNull public static android.util.Range<java.lang.Integer> getIpSecNetIdRange();
|
method @NonNull public static android.util.Range<java.lang.Integer> getIpSecNetIdRange();
|
||||||
method @NonNull public static String getPrivateDnsMode(@NonNull android.content.Context);
|
method @NonNull public static String getPrivateDnsMode(@NonNull android.content.Context);
|
||||||
|
|||||||
@@ -1435,9 +1435,9 @@ public class ConnectivityManager {
|
|||||||
android.Manifest.permission.NETWORK_STACK,
|
android.Manifest.permission.NETWORK_STACK,
|
||||||
android.Manifest.permission.NETWORK_SETTINGS})
|
android.Manifest.permission.NETWORK_SETTINGS})
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<NetworkStateSnapshot> getAllNetworkStateSnapshot() {
|
public List<NetworkStateSnapshot> getAllNetworkStateSnapshots() {
|
||||||
try {
|
try {
|
||||||
return mService.getAllNetworkStateSnapshot();
|
return mService.getAllNetworkStateSnapshots();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ interface IConnectivityManager
|
|||||||
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
||||||
NetworkState[] getAllNetworkState();
|
NetworkState[] getAllNetworkState();
|
||||||
|
|
||||||
List<NetworkStateSnapshot> getAllNetworkStateSnapshot();
|
List<NetworkStateSnapshot> getAllNetworkStateSnapshots();
|
||||||
|
|
||||||
boolean isActiveNetworkMetered();
|
boolean isActiveNetworkMetered();
|
||||||
|
|
||||||
|
|||||||
@@ -2176,7 +2176,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
PermissionUtils.enforceNetworkStackPermission(mContext);
|
PermissionUtils.enforceNetworkStackPermission(mContext);
|
||||||
|
|
||||||
final ArrayList<NetworkState> result = new ArrayList<>();
|
final ArrayList<NetworkState> result = new ArrayList<>();
|
||||||
for (NetworkStateSnapshot snapshot : getAllNetworkStateSnapshot()) {
|
for (NetworkStateSnapshot snapshot : getAllNetworkStateSnapshots()) {
|
||||||
// NetworkStateSnapshot doesn't contain NetworkInfo, so need to fetch it from the
|
// NetworkStateSnapshot doesn't contain NetworkInfo, so need to fetch it from the
|
||||||
// NetworkAgentInfo.
|
// NetworkAgentInfo.
|
||||||
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(snapshot.network);
|
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(snapshot.network);
|
||||||
@@ -2191,7 +2191,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<NetworkStateSnapshot> getAllNetworkStateSnapshot() {
|
public List<NetworkStateSnapshot> getAllNetworkStateSnapshots() {
|
||||||
// This contains IMSI details, so make sure the caller is privileged.
|
// This contains IMSI details, so make sure the caller is privileged.
|
||||||
PermissionUtils.enforceNetworkStackPermission(mContext);
|
PermissionUtils.enforceNetworkStackPermission(mContext);
|
||||||
|
|
||||||
|
|||||||
@@ -1804,7 +1804,7 @@ public class ConnectivityServiceTest {
|
|||||||
assertNull(mCm.getActiveNetworkForUid(Process.myUid()));
|
assertNull(mCm.getActiveNetworkForUid(Process.myUid()));
|
||||||
// Test getAllNetworks()
|
// Test getAllNetworks()
|
||||||
assertEmpty(mCm.getAllNetworks());
|
assertEmpty(mCm.getAllNetworks());
|
||||||
assertEmpty(mCm.getAllNetworkStateSnapshot());
|
assertEmpty(mCm.getAllNetworkStateSnapshots());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11742,7 +11742,7 @@ public class ConnectivityServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllNetworkStateSnapshot() throws Exception {
|
public void testGetAllNetworkStateSnapshots() throws Exception {
|
||||||
verifyNoNetwork();
|
verifyNoNetwork();
|
||||||
|
|
||||||
// Setup test cellular network with specified LinkProperties and NetworkCapabilities,
|
// Setup test cellular network with specified LinkProperties and NetworkCapabilities,
|
||||||
@@ -11766,7 +11766,7 @@ public class ConnectivityServiceTest {
|
|||||||
mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, cellLp, cellNcTemplate);
|
mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, cellLp, cellNcTemplate);
|
||||||
mCellNetworkAgent.connect(true);
|
mCellNetworkAgent.connect(true);
|
||||||
cellCb.expectAvailableCallbacksUnvalidated(mCellNetworkAgent);
|
cellCb.expectAvailableCallbacksUnvalidated(mCellNetworkAgent);
|
||||||
List<NetworkStateSnapshot> snapshots = mCm.getAllNetworkStateSnapshot();
|
List<NetworkStateSnapshot> snapshots = mCm.getAllNetworkStateSnapshots();
|
||||||
assertLength(1, snapshots);
|
assertLength(1, snapshots);
|
||||||
|
|
||||||
// Compose the expected cellular snapshot for verification.
|
// Compose the expected cellular snapshot for verification.
|
||||||
@@ -11788,7 +11788,7 @@ public class ConnectivityServiceTest {
|
|||||||
mWiFiNetworkAgent.getNetwork(), wifiNc, new LinkProperties(), null,
|
mWiFiNetworkAgent.getNetwork(), wifiNc, new LinkProperties(), null,
|
||||||
ConnectivityManager.TYPE_WIFI);
|
ConnectivityManager.TYPE_WIFI);
|
||||||
|
|
||||||
snapshots = mCm.getAllNetworkStateSnapshot();
|
snapshots = mCm.getAllNetworkStateSnapshots();
|
||||||
assertLength(2, snapshots);
|
assertLength(2, snapshots);
|
||||||
assertContainsAll(snapshots, cellSnapshot, wifiSnapshot);
|
assertContainsAll(snapshots, cellSnapshot, wifiSnapshot);
|
||||||
|
|
||||||
@@ -11797,20 +11797,20 @@ public class ConnectivityServiceTest {
|
|||||||
// temporary shortage of connectivity of a connected network.
|
// temporary shortage of connectivity of a connected network.
|
||||||
mCellNetworkAgent.suspend();
|
mCellNetworkAgent.suspend();
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
snapshots = mCm.getAllNetworkStateSnapshot();
|
snapshots = mCm.getAllNetworkStateSnapshots();
|
||||||
assertLength(1, snapshots);
|
assertLength(1, snapshots);
|
||||||
assertEquals(wifiSnapshot, snapshots.get(0));
|
assertEquals(wifiSnapshot, snapshots.get(0));
|
||||||
|
|
||||||
// Disconnect wifi, verify the snapshots contain nothing.
|
// Disconnect wifi, verify the snapshots contain nothing.
|
||||||
mWiFiNetworkAgent.disconnect();
|
mWiFiNetworkAgent.disconnect();
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
snapshots = mCm.getAllNetworkStateSnapshot();
|
snapshots = mCm.getAllNetworkStateSnapshots();
|
||||||
assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork());
|
assertEquals(mCellNetworkAgent.getNetwork(), mCm.getActiveNetwork());
|
||||||
assertLength(0, snapshots);
|
assertLength(0, snapshots);
|
||||||
|
|
||||||
mCellNetworkAgent.resume();
|
mCellNetworkAgent.resume();
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
snapshots = mCm.getAllNetworkStateSnapshot();
|
snapshots = mCm.getAllNetworkStateSnapshots();
|
||||||
assertLength(1, snapshots);
|
assertLength(1, snapshots);
|
||||||
assertEquals(cellSnapshot, snapshots.get(0));
|
assertEquals(cellSnapshot, snapshots.get(0));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user