Loading core/api/system-current.txt +13 −0 Original line number Diff line number Diff line Loading @@ -6399,6 +6399,19 @@ package android.net.sip { } package android.net.util { public final class SocketUtils { method public static void bindSocketToInterface(@NonNull java.io.FileDescriptor, @NonNull String) throws android.system.ErrnoException; method public static void closeSocket(@Nullable java.io.FileDescriptor) throws java.io.IOException; method @NonNull public static java.net.SocketAddress makeNetlinkSocketAddress(int, int); method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, int); method @Deprecated @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, @NonNull byte[]); method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, int, @NonNull byte[]); } } package android.net.vcn { public class VcnManager { Loading core/java/android/net/VpnService.java +2 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import com.android.internal.net.NetworkUtilsInternal; import com.android.internal.net.VpnConfig; import java.net.DatagramSocket; Loading Loading @@ -254,7 +255,7 @@ public class VpnService extends Service { * @return {@code true} on success. */ public boolean protect(int socket) { return NetworkUtils.protectFromVpn(socket); return NetworkUtilsInternal.protectFromVpn(socket); } /** Loading packages/Connectivity/framework/src/android/net/util/SocketUtils.java→core/java/android/net/util/SocketUtils.java +3 −2 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import static android.system.OsConstants.SO_BINDTODEVICE; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.net.NetworkUtils; import android.system.ErrnoException; import android.system.NetlinkSocketAddress; import android.system.Os; import android.system.PacketSocketAddress; import com.android.internal.net.NetworkUtilsInternal; import libcore.io.IoBridge; import java.io.FileDescriptor; Loading @@ -51,7 +52,7 @@ public final class SocketUtils { // of struct ifreq is a NULL-terminated interface name. // TODO: add a setsockoptString() Os.setsockoptIfreq(socket, SOL_SOCKET, SO_BINDTODEVICE, iface); NetworkUtils.protectFromVpn(socket); NetworkUtilsInternal.protectFromVpn(socket); } /** Loading core/java/com/android/internal/net/NetworkUtilsInternal.java +16 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.system.OsConstants.AF_INET6; import android.annotation.NonNull; import android.system.Os; import java.io.FileDescriptor; /** @hide */ public class NetworkUtilsInternal { Loading @@ -35,6 +37,20 @@ public class NetworkUtilsInternal { */ public static native void setAllowNetworkingForProcess(boolean allowNetworking); /** * Protect {@code fd} from VPN connections. After protecting, data sent through * this socket will go directly to the underlying network, so its traffic will not be * forwarded through the VPN. */ public static native boolean protectFromVpn(FileDescriptor fd); /** * Protect {@code socketfd} from VPN connections. After protecting, data sent through * this socket will go directly to the underlying network, so its traffic will not be * forwarded through the VPN. */ public static native boolean protectFromVpn(int socketfd); /** * Returns true if the hostname is weakly validated. * @param hostname Name of host to validate. Loading core/jni/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ cc_library_shared { "android_os_VintfRuntimeInfo.cpp", "android_os_incremental_IncrementalManager.cpp", "android_net_LocalSocketImpl.cpp", "android_net_NetUtils.cpp", "android_net_NetworkUtils.cpp", "android_service_DataLoaderService.cpp", "android_util_AssetManager.cpp", "android_util_Binder.cpp", Loading Loading
core/api/system-current.txt +13 −0 Original line number Diff line number Diff line Loading @@ -6399,6 +6399,19 @@ package android.net.sip { } package android.net.util { public final class SocketUtils { method public static void bindSocketToInterface(@NonNull java.io.FileDescriptor, @NonNull String) throws android.system.ErrnoException; method public static void closeSocket(@Nullable java.io.FileDescriptor) throws java.io.IOException; method @NonNull public static java.net.SocketAddress makeNetlinkSocketAddress(int, int); method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, int); method @Deprecated @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, @NonNull byte[]); method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, int, @NonNull byte[]); } } package android.net.vcn { public class VcnManager { Loading
core/java/android/net/VpnService.java +2 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import com.android.internal.net.NetworkUtilsInternal; import com.android.internal.net.VpnConfig; import java.net.DatagramSocket; Loading Loading @@ -254,7 +255,7 @@ public class VpnService extends Service { * @return {@code true} on success. */ public boolean protect(int socket) { return NetworkUtils.protectFromVpn(socket); return NetworkUtilsInternal.protectFromVpn(socket); } /** Loading
packages/Connectivity/framework/src/android/net/util/SocketUtils.java→core/java/android/net/util/SocketUtils.java +3 −2 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ import static android.system.OsConstants.SO_BINDTODEVICE; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.net.NetworkUtils; import android.system.ErrnoException; import android.system.NetlinkSocketAddress; import android.system.Os; import android.system.PacketSocketAddress; import com.android.internal.net.NetworkUtilsInternal; import libcore.io.IoBridge; import java.io.FileDescriptor; Loading @@ -51,7 +52,7 @@ public final class SocketUtils { // of struct ifreq is a NULL-terminated interface name. // TODO: add a setsockoptString() Os.setsockoptIfreq(socket, SOL_SOCKET, SO_BINDTODEVICE, iface); NetworkUtils.protectFromVpn(socket); NetworkUtilsInternal.protectFromVpn(socket); } /** Loading
core/java/com/android/internal/net/NetworkUtilsInternal.java +16 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.system.OsConstants.AF_INET6; import android.annotation.NonNull; import android.system.Os; import java.io.FileDescriptor; /** @hide */ public class NetworkUtilsInternal { Loading @@ -35,6 +37,20 @@ public class NetworkUtilsInternal { */ public static native void setAllowNetworkingForProcess(boolean allowNetworking); /** * Protect {@code fd} from VPN connections. After protecting, data sent through * this socket will go directly to the underlying network, so its traffic will not be * forwarded through the VPN. */ public static native boolean protectFromVpn(FileDescriptor fd); /** * Protect {@code socketfd} from VPN connections. After protecting, data sent through * this socket will go directly to the underlying network, so its traffic will not be * forwarded through the VPN. */ public static native boolean protectFromVpn(int socketfd); /** * Returns true if the hostname is weakly validated. * @param hostname Name of host to validate. Loading
core/jni/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ cc_library_shared { "android_os_VintfRuntimeInfo.cpp", "android_os_incremental_IncrementalManager.cpp", "android_net_LocalSocketImpl.cpp", "android_net_NetUtils.cpp", "android_net_NetworkUtils.cpp", "android_service_DataLoaderService.cpp", "android_util_AssetManager.cpp", "android_util_Binder.cpp", Loading