Loading core/java/android/net/IpSecManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -337,6 +337,9 @@ public final class IpSecManager { */ public void applyTransportModeTransform(@NonNull Socket socket, @PolicyDirection int direction, @NonNull IpSecTransform transform) throws IOException { // Ensure creation of FD. See b/77548890 for more details. socket.getSoLinger(); applyTransportModeTransform(socket.getFileDescriptor$(), direction, transform); } Loading Loading @@ -441,6 +444,9 @@ public final class IpSecManager { * @throws IOException indicating that the transform could not be removed from the socket */ public void removeTransportModeTransforms(@NonNull Socket socket) throws IOException { // Ensure creation of FD. See b/77548890 for more details. socket.getSoLinger(); removeTransportModeTransforms(socket.getFileDescriptor$()); } Loading tests/net/java/android/net/IpSecManagerTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.system.Os; import com.android.server.IpSecService; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import org.junit.Before; Loading Loading @@ -194,6 +195,33 @@ public class IpSecManagerTest { verify(mMockIpSecService).closeUdpEncapsulationSocket(DUMMY_RESOURCE_ID); } @Test public void testApplyTransportModeTransformEnsuresSocketCreation() throws Exception { Socket socket = new Socket(); IpSecConfig dummyConfig = new IpSecConfig(); IpSecTransform dummyTransform = new IpSecTransform(null, dummyConfig); // Even if underlying SocketImpl is not initalized, this should force the init, and // thereby succeed. mIpSecManager.applyTransportModeTransform( socket, IpSecManager.DIRECTION_IN, dummyTransform); // Check to make sure the FileDescriptor is non-null assertNotNull(socket.getFileDescriptor$()); } @Test public void testRemoveTransportModeTransformsForcesSocketCreation() throws Exception { Socket socket = new Socket(); // Even if underlying SocketImpl is not initalized, this should force the init, and // thereby succeed. mIpSecManager.removeTransportModeTransforms(socket); // Check to make sure the FileDescriptor is non-null assertNotNull(socket.getFileDescriptor$()); } @Test public void testOpenEncapsulationSocketOnRandomPort() throws Exception { IpSecUdpEncapResponse udpEncapResp = Loading Loading
core/java/android/net/IpSecManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -337,6 +337,9 @@ public final class IpSecManager { */ public void applyTransportModeTransform(@NonNull Socket socket, @PolicyDirection int direction, @NonNull IpSecTransform transform) throws IOException { // Ensure creation of FD. See b/77548890 for more details. socket.getSoLinger(); applyTransportModeTransform(socket.getFileDescriptor$(), direction, transform); } Loading Loading @@ -441,6 +444,9 @@ public final class IpSecManager { * @throws IOException indicating that the transform could not be removed from the socket */ public void removeTransportModeTransforms(@NonNull Socket socket) throws IOException { // Ensure creation of FD. See b/77548890 for more details. socket.getSoLinger(); removeTransportModeTransforms(socket.getFileDescriptor$()); } Loading
tests/net/java/android/net/IpSecManagerTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.system.Os; import com.android.server.IpSecService; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import org.junit.Before; Loading Loading @@ -194,6 +195,33 @@ public class IpSecManagerTest { verify(mMockIpSecService).closeUdpEncapsulationSocket(DUMMY_RESOURCE_ID); } @Test public void testApplyTransportModeTransformEnsuresSocketCreation() throws Exception { Socket socket = new Socket(); IpSecConfig dummyConfig = new IpSecConfig(); IpSecTransform dummyTransform = new IpSecTransform(null, dummyConfig); // Even if underlying SocketImpl is not initalized, this should force the init, and // thereby succeed. mIpSecManager.applyTransportModeTransform( socket, IpSecManager.DIRECTION_IN, dummyTransform); // Check to make sure the FileDescriptor is non-null assertNotNull(socket.getFileDescriptor$()); } @Test public void testRemoveTransportModeTransformsForcesSocketCreation() throws Exception { Socket socket = new Socket(); // Even if underlying SocketImpl is not initalized, this should force the init, and // thereby succeed. mIpSecManager.removeTransportModeTransforms(socket); // Check to make sure the FileDescriptor is non-null assertNotNull(socket.getFileDescriptor$()); } @Test public void testOpenEncapsulationSocketOnRandomPort() throws Exception { IpSecUdpEncapResponse udpEncapResp = Loading