From c0d9f8a28f4b266a6d38a981ea9898c1dd747c40 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Sun, 21 Mar 2021 15:00:46 +0000 Subject: Add NDK API for getprocnetwork The API is the getter couterpart for setprocnetwork. Use it in NetworkUtils so that the NDK API can be the source of truth for the process network. Bug: 171540887 Test: atest CtsNetTestCases Merged-In: I4c7a302df580cec6315e10d0d49a89cf93597ef0 Change-Id: Ibcb8960af2be87d8dd4cf3692293ff65df2904a7 --- include/android/multinetwork.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h index 424299d664..fa7759393c 100644 --- a/include/android/multinetwork.h +++ b/include/android/multinetwork.h @@ -83,13 +83,26 @@ int android_setsocknetwork(net_handle_t network, int fd) __INTRODUCED_IN(23); * * To clear a previous process binding, invoke with NETWORK_UNSPECIFIED. * - * This is the equivalent of: [android.net.ConnectivityManager#setProcessDefaultNetwork()](https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network)) + * This is the equivalent of: [android.net.ConnectivityManager#bindProcessToNetwork()](https://developer.android.com/reference/android/net/ConnectivityManager.html#bindProcessToNetwork(android.net.Network)) * * Available since API level 23. */ int android_setprocnetwork(net_handle_t network) __INTRODUCED_IN(23); +/** + * Gets the |network| bound to the current process, as per android_setprocnetwork. + * + * This is the equivalent of: [android.net.ConnectivityManager#getBoundNetworkForProcess()](https://developer.android.com/reference/android/net/ConnectivityManager.html#getBoundNetworkForProcess(android.net.Network)) + * Returns 0 on success, or -1 setting errno to EINVAL if a null pointer is + * passed in. + * + * + * Available since API level 31. + */ +int android_getprocnetwork(net_handle_t *network) __INTRODUCED_IN(31); + + /** * Perform hostname resolution via the DNS servers associated with |network|. * -- cgit v1.2.3-59-g8ed1b