Snap for 4710485 from d4a95a168974bf4052f63b9925de9594be684d66 to pi-release

Change-Id: I240679b58fa328769ae8e0240bcf53676a489ade
This commit is contained in:
android-build-team Robot
2018-04-10 07:27:46 +00:00
2 changed files with 31 additions and 1 deletions

View File

@@ -26,6 +26,8 @@ import android.util.Slog;
* @hide
*/
public class NetworkState implements Parcelable {
private static final boolean SANITY_CHECK_ROAMING = false;
public static final NetworkState EMPTY = new NetworkState(null, null, null, null, null, null);
public final NetworkInfo networkInfo;
@@ -47,7 +49,7 @@ public class NetworkState implements Parcelable {
// This object is an atomic view of a network, so the various components
// should always agree on roaming state.
if (networkInfo != null && networkCapabilities != null) {
if (SANITY_CHECK_ROAMING && networkInfo != null && networkCapabilities != null) {
if (networkInfo.isRoaming() == networkCapabilities
.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING)) {
Slog.wtf("NetworkState", "Roaming state disagreement between " + networkInfo

View File

@@ -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;
@@ -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 =