Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0442bbca authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN Committed by Automerger Merge Worker
Browse files

Merge "Move SocketUtils out of the connectivity module" am: 4eb9b18e am:...

Merge "Move SocketUtils out of the connectivity module" am: 4eb9b18e am: b3bc93fb am: 1efb1bf4

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1592273

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9de14464ebb9d43e7c4fdc683c23ddbbcc7ef269
parents def97266 1efb1bf4
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -7494,6 +7494,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 {
+2 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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);
    }

    /**
+3 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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);
    }

    /**
+16 −0
Original line number Diff line number Diff line
@@ -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 {

@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,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