[FUI22] Support getAllNetworkStateSnapshot

Currently, ConnectivityService has getAllNetworkState but it is
not ideal to expose as system API since the plan is to get rid
of NetworkState. Thus, create a new one that returns
NetworkStateSnapshot to fulfill the needs.

Note the original getAllNetworkState cannot be deleted now since
it has @UnsupportedAppUsage annotation.

Test: atest FrameworksNetTests
Bug: 174123988
Change-Id: Icddd434552b0e9ecbc8299e7242ec88cf3145aca
This commit is contained in:
junyulai
2021-03-03 12:09:05 +08:00
parent 4297526f8b
commit b12113700c
3 changed files with 23 additions and 0 deletions

View File

@@ -1258,6 +1258,25 @@ public class ConnectivityManager {
}
}
/**
* Return a list of {@link NetworkStateSnapshot}s, one for each network that is currently
* connected.
* @hide
*/
@SystemApi(client = MODULE_LIBRARIES)
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK,
android.Manifest.permission.NETWORK_SETTINGS})
@NonNull
public List<NetworkStateSnapshot> getAllNetworkStateSnapshot() {
try {
return mService.getAllNetworkStateSnapshot();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Returns the {@link Network} object currently serving a given type, or
* null if the given type is not connected.