Loading core/java/android/net/BaseNetworkStateTracker.java +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker { protected NetworkInfo mNetworkInfo; protected LinkProperties mLinkProperties; protected NetworkCapabilities mNetworkCapabilities; protected Network mNetwork = new Network(ConnectivityManager.INVALID_NET_ID); protected Network mNetwork = new Network(ConnectivityManager.NETID_UNSET); private AtomicBoolean mTeardownRequested = new AtomicBoolean(false); private AtomicBoolean mPrivateDnsRouteSet = new AtomicBoolean(false); Loading core/java/android/net/ConnectivityManager.java +11 −16 Original line number Diff line number Diff line Loading @@ -529,11 +529,6 @@ public class ConnectivityManager { */ public static final int CONNECTIVITY_CHANGE_DELAY_DEFAULT = 3000; /** * @hide */ public final static int INVALID_NET_ID = 0; /** * @hide */ Loading Loading @@ -2508,13 +2503,16 @@ public class ConnectivityManager { * @return {@code true} on success, {@code false} if the {@link Network} is no longer valid. */ public static boolean setProcessDefaultNetwork(Network network) { if (network == null) { return NetworkUtils.unbindProcessToNetwork(); } else { return NetworkUtils.bindProcessToNetwork(network.netId); } return NetworkUtils.bindProcessToNetwork(network == null ? NETID_UNSET : network.netId); } /** * A NetID indicating no Network is selected. * Keep in sync with bionic/libc/dns/include/resolv_netid.h * @hide */ public static final int NETID_UNSET = 0; /** * Returns the {@link Network} currently bound to this process via * {@link #setProcessDefaultNetwork}, or {@code null} if no {@link Network} is explicitly bound. Loading @@ -2523,7 +2521,7 @@ public class ConnectivityManager { */ public static Network getProcessDefaultNetwork() { int netId = NetworkUtils.getNetworkBoundToProcess(); if (netId == 0) return null; if (netId == NETID_UNSET) return null; return new Network(netId); } Loading @@ -2538,10 +2536,7 @@ public class ConnectivityManager { * @deprecated This is strictly for legacy usage to support {@link #startUsingNetworkFeature}. */ public static boolean setProcessDefaultNetworkForHostResolution(Network network) { if (network == null) { return NetworkUtils.unbindProcessToNetworkForHostResolution(); } else { return NetworkUtils.bindProcessToNetworkForHostResolution(network.netId); } return NetworkUtils.bindProcessToNetworkForHostResolution( network == null ? NETID_UNSET : network.netId); } } core/java/android/net/NetworkUtils.java +3 −16 Original line number Diff line number Diff line Loading @@ -116,16 +116,10 @@ public class NetworkUtils { * {@link Network#getSocketFactory}) will be bound to this network. Note that if this * {@code Network} ever disconnects all sockets created in this way will cease to work. This * is by design so an application doesn't accidentally use sockets it thinks are still bound to * a particular {@code Network}. * a particular {@code Network}. Passing NETID_UNSET clears the binding. */ public native static boolean bindProcessToNetwork(int netId); /** * Clear any process specific {@code Network} binding. This reverts a call to * {@link #bindProcessToNetwork}. */ public native static boolean unbindProcessToNetwork(); /** * Return the netId last passed to {@link #bindProcessToNetwork}, or NETID_UNSET if * {@link #unbindProcessToNetwork} has been called since {@link #bindProcessToNetwork}. Loading @@ -134,20 +128,13 @@ public class NetworkUtils { /** * Binds host resolutions performed by this process to the network designated by {@code netId}. * {@link #bindProcessToNetwork} takes precedence over this setting. * {@link #bindProcessToNetwork} takes precedence over this setting. Passing NETID_UNSET clears * the binding. * * @deprecated This is strictly for legacy usage to support startUsingNetworkFeature(). */ public native static boolean bindProcessToNetworkForHostResolution(int netId); /** * Clears any process specific {@link Network} binding for host resolution. This does * not clear bindings enacted via {@link #bindProcessToNetwork}. * * @deprecated This is strictly for legacy usage to support startUsingNetworkFeature(). */ public native static boolean unbindProcessToNetworkForHostResolution(); /** * Explicitly binds {@code socketfd} to the network designated by {@code netId}. This * overrides any binding via {@link #bindProcessToNetwork}. Loading core/jni/android_net_NetUtils.cpp +0 −12 Original line number Diff line number Diff line Loading @@ -258,11 +258,6 @@ static jboolean android_net_utils_bindProcessToNetwork(JNIEnv *env, jobject thiz return (jboolean) !setNetworkForProcess(netId); } static jboolean android_net_utils_unbindProcessToNetwork(JNIEnv *env, jobject thiz) { return (jboolean) !setNetworkForProcess(NETID_UNSET); } static jint android_net_utils_getNetworkBoundToProcess(JNIEnv *env, jobject thiz) { return getNetworkForProcess(); Loading @@ -274,11 +269,6 @@ static jboolean android_net_utils_bindProcessToNetworkForHostResolution(JNIEnv * return (jboolean) !setNetworkForResolv(netId); } static jboolean android_net_utils_unbindProcessToNetworkForHostResolution(JNIEnv *env, jobject thiz) { return (jboolean) !setNetworkForResolv(NETID_UNSET); } static jboolean android_net_utils_bindSocketToNetwork(JNIEnv *env, jobject thiz, jint socket, jint netId) { Loading Loading @@ -309,9 +299,7 @@ static JNINativeMethod gNetworkUtilMethods[] = { { "markSocket", "(II)V", (void*) android_net_utils_markSocket }, { "bindProcessToNetwork", "(I)Z", (void*) android_net_utils_bindProcessToNetwork }, { "getNetworkBoundToProcess", "()I", (void*) android_net_utils_getNetworkBoundToProcess }, { "unbindProcessToNetwork", "()Z", (void*) android_net_utils_unbindProcessToNetwork }, { "bindProcessToNetworkForHostResolution", "(I)Z", (void*) android_net_utils_bindProcessToNetworkForHostResolution }, { "unbindProcessToNetworkForHostResolution", "()Z", (void*) android_net_utils_unbindProcessToNetworkForHostResolution }, { "bindSocketToNetwork", "(II)Z", (void*) android_net_utils_bindSocketToNetwork }, { "protectFromVpn", "(I)Z", (void*)android_net_utils_protectFromVpn }, }; Loading services/core/java/com/android/server/ConnectivityService.java +3 −5 Original line number Diff line number Diff line Loading @@ -179,8 +179,6 @@ import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; import static android.net.ConnectivityManager.INVALID_NET_ID; /** * @hide */ Loading Loading @@ -1841,8 +1839,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { LinkProperties lp = null; int netId = INVALID_NET_ID; LinkProperties lp; int netId; synchronized (nai) { lp = nai.linkProperties; netId = nai.network.netId; Loading Loading @@ -2239,7 +2237,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } catch (Exception e) { loge("Exception removing network: " + e); } finally { mNetTrackers[prevNetType].setNetId(INVALID_NET_ID); // mNetTrackers[prevNetType].setNetId(INVALID_NET_ID); } } Loading Loading
core/java/android/net/BaseNetworkStateTracker.java +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker { protected NetworkInfo mNetworkInfo; protected LinkProperties mLinkProperties; protected NetworkCapabilities mNetworkCapabilities; protected Network mNetwork = new Network(ConnectivityManager.INVALID_NET_ID); protected Network mNetwork = new Network(ConnectivityManager.NETID_UNSET); private AtomicBoolean mTeardownRequested = new AtomicBoolean(false); private AtomicBoolean mPrivateDnsRouteSet = new AtomicBoolean(false); Loading
core/java/android/net/ConnectivityManager.java +11 −16 Original line number Diff line number Diff line Loading @@ -529,11 +529,6 @@ public class ConnectivityManager { */ public static final int CONNECTIVITY_CHANGE_DELAY_DEFAULT = 3000; /** * @hide */ public final static int INVALID_NET_ID = 0; /** * @hide */ Loading Loading @@ -2508,13 +2503,16 @@ public class ConnectivityManager { * @return {@code true} on success, {@code false} if the {@link Network} is no longer valid. */ public static boolean setProcessDefaultNetwork(Network network) { if (network == null) { return NetworkUtils.unbindProcessToNetwork(); } else { return NetworkUtils.bindProcessToNetwork(network.netId); } return NetworkUtils.bindProcessToNetwork(network == null ? NETID_UNSET : network.netId); } /** * A NetID indicating no Network is selected. * Keep in sync with bionic/libc/dns/include/resolv_netid.h * @hide */ public static final int NETID_UNSET = 0; /** * Returns the {@link Network} currently bound to this process via * {@link #setProcessDefaultNetwork}, or {@code null} if no {@link Network} is explicitly bound. Loading @@ -2523,7 +2521,7 @@ public class ConnectivityManager { */ public static Network getProcessDefaultNetwork() { int netId = NetworkUtils.getNetworkBoundToProcess(); if (netId == 0) return null; if (netId == NETID_UNSET) return null; return new Network(netId); } Loading @@ -2538,10 +2536,7 @@ public class ConnectivityManager { * @deprecated This is strictly for legacy usage to support {@link #startUsingNetworkFeature}. */ public static boolean setProcessDefaultNetworkForHostResolution(Network network) { if (network == null) { return NetworkUtils.unbindProcessToNetworkForHostResolution(); } else { return NetworkUtils.bindProcessToNetworkForHostResolution(network.netId); } return NetworkUtils.bindProcessToNetworkForHostResolution( network == null ? NETID_UNSET : network.netId); } }
core/java/android/net/NetworkUtils.java +3 −16 Original line number Diff line number Diff line Loading @@ -116,16 +116,10 @@ public class NetworkUtils { * {@link Network#getSocketFactory}) will be bound to this network. Note that if this * {@code Network} ever disconnects all sockets created in this way will cease to work. This * is by design so an application doesn't accidentally use sockets it thinks are still bound to * a particular {@code Network}. * a particular {@code Network}. Passing NETID_UNSET clears the binding. */ public native static boolean bindProcessToNetwork(int netId); /** * Clear any process specific {@code Network} binding. This reverts a call to * {@link #bindProcessToNetwork}. */ public native static boolean unbindProcessToNetwork(); /** * Return the netId last passed to {@link #bindProcessToNetwork}, or NETID_UNSET if * {@link #unbindProcessToNetwork} has been called since {@link #bindProcessToNetwork}. Loading @@ -134,20 +128,13 @@ public class NetworkUtils { /** * Binds host resolutions performed by this process to the network designated by {@code netId}. * {@link #bindProcessToNetwork} takes precedence over this setting. * {@link #bindProcessToNetwork} takes precedence over this setting. Passing NETID_UNSET clears * the binding. * * @deprecated This is strictly for legacy usage to support startUsingNetworkFeature(). */ public native static boolean bindProcessToNetworkForHostResolution(int netId); /** * Clears any process specific {@link Network} binding for host resolution. This does * not clear bindings enacted via {@link #bindProcessToNetwork}. * * @deprecated This is strictly for legacy usage to support startUsingNetworkFeature(). */ public native static boolean unbindProcessToNetworkForHostResolution(); /** * Explicitly binds {@code socketfd} to the network designated by {@code netId}. This * overrides any binding via {@link #bindProcessToNetwork}. Loading
core/jni/android_net_NetUtils.cpp +0 −12 Original line number Diff line number Diff line Loading @@ -258,11 +258,6 @@ static jboolean android_net_utils_bindProcessToNetwork(JNIEnv *env, jobject thiz return (jboolean) !setNetworkForProcess(netId); } static jboolean android_net_utils_unbindProcessToNetwork(JNIEnv *env, jobject thiz) { return (jboolean) !setNetworkForProcess(NETID_UNSET); } static jint android_net_utils_getNetworkBoundToProcess(JNIEnv *env, jobject thiz) { return getNetworkForProcess(); Loading @@ -274,11 +269,6 @@ static jboolean android_net_utils_bindProcessToNetworkForHostResolution(JNIEnv * return (jboolean) !setNetworkForResolv(netId); } static jboolean android_net_utils_unbindProcessToNetworkForHostResolution(JNIEnv *env, jobject thiz) { return (jboolean) !setNetworkForResolv(NETID_UNSET); } static jboolean android_net_utils_bindSocketToNetwork(JNIEnv *env, jobject thiz, jint socket, jint netId) { Loading Loading @@ -309,9 +299,7 @@ static JNINativeMethod gNetworkUtilMethods[] = { { "markSocket", "(II)V", (void*) android_net_utils_markSocket }, { "bindProcessToNetwork", "(I)Z", (void*) android_net_utils_bindProcessToNetwork }, { "getNetworkBoundToProcess", "()I", (void*) android_net_utils_getNetworkBoundToProcess }, { "unbindProcessToNetwork", "()Z", (void*) android_net_utils_unbindProcessToNetwork }, { "bindProcessToNetworkForHostResolution", "(I)Z", (void*) android_net_utils_bindProcessToNetworkForHostResolution }, { "unbindProcessToNetworkForHostResolution", "()Z", (void*) android_net_utils_unbindProcessToNetworkForHostResolution }, { "bindSocketToNetwork", "(II)Z", (void*) android_net_utils_bindSocketToNetwork }, { "protectFromVpn", "(I)Z", (void*)android_net_utils_protectFromVpn }, }; Loading
services/core/java/com/android/server/ConnectivityService.java +3 −5 Original line number Diff line number Diff line Loading @@ -179,8 +179,6 @@ import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; import static android.net.ConnectivityManager.INVALID_NET_ID; /** * @hide */ Loading Loading @@ -1841,8 +1839,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { LinkProperties lp = null; int netId = INVALID_NET_ID; LinkProperties lp; int netId; synchronized (nai) { lp = nai.linkProperties; netId = nai.network.netId; Loading Loading @@ -2239,7 +2237,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } catch (Exception e) { loge("Exception removing network: " + e); } finally { mNetTrackers[prevNetType].setNetId(INVALID_NET_ID); // mNetTrackers[prevNetType].setNetId(INVALID_NET_ID); } } Loading