Merge changes Iec53a9fd,Iac4cfe70 am: 8621e44c39 am: 4a4e693e3e
am: 9d98567b3c
Change-Id: Ie225d000aeafb4a0b1e3910967c619fd932f239f
This commit is contained in:
@@ -849,6 +849,18 @@ public class LinkPropertiesTest {
|
||||
assertEquals(new ArraySet<>(expectRemoved), (new ArraySet<>(result.removed)));
|
||||
}
|
||||
|
||||
private void assertParcelingIsLossless(LinkProperties source) {
|
||||
Parcel p = Parcel.obtain();
|
||||
source.writeToParcel(p, /* flags */ 0);
|
||||
p.setDataPosition(0);
|
||||
final byte[] marshalled = p.marshall();
|
||||
p = Parcel.obtain();
|
||||
p.unmarshall(marshalled, 0, marshalled.length);
|
||||
p.setDataPosition(0);
|
||||
LinkProperties dest = LinkProperties.CREATOR.createFromParcel(p);
|
||||
assertEquals(source, dest);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkPropertiesParcelable() throws Exception {
|
||||
LinkProperties source = new LinkProperties();
|
||||
@@ -870,15 +882,12 @@ public class LinkPropertiesTest {
|
||||
|
||||
source.setNat64Prefix(new IpPrefix("2001:db8:1:2:64:64::/96"));
|
||||
|
||||
Parcel p = Parcel.obtain();
|
||||
source.writeToParcel(p, /* flags */ 0);
|
||||
p.setDataPosition(0);
|
||||
final byte[] marshalled = p.marshall();
|
||||
p = Parcel.obtain();
|
||||
p.unmarshall(marshalled, 0, marshalled.length);
|
||||
p.setDataPosition(0);
|
||||
LinkProperties dest = LinkProperties.CREATOR.createFromParcel(p);
|
||||
assertParcelingIsLossless(source);
|
||||
}
|
||||
|
||||
assertEquals(source, dest);
|
||||
@Test
|
||||
public void testParcelUninitialized() throws Exception {
|
||||
LinkProperties empty = new LinkProperties();
|
||||
assertParcelingIsLossless(empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4683,7 +4683,7 @@ public class ConnectivityServiceTest {
|
||||
mCellNetworkAgent.sendLinkProperties(cellLp);
|
||||
mCellNetworkAgent.connect(true);
|
||||
networkCallback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent);
|
||||
verify(mNetworkManagementService, times(1)).startClatd(MOBILE_IFNAME);
|
||||
verify(mMockNetd, times(1)).clatdStart(MOBILE_IFNAME);
|
||||
Nat464Xlat clat = mService.getNat464Xlat(mCellNetworkAgent);
|
||||
|
||||
// Clat iface up, expect stack link updated.
|
||||
@@ -4710,7 +4710,7 @@ public class ConnectivityServiceTest {
|
||||
mCellNetworkAgent.sendLinkProperties(cellLp);
|
||||
waitForIdle();
|
||||
networkCallback.expectCallback(CallbackState.LINK_PROPERTIES, mCellNetworkAgent);
|
||||
verify(mNetworkManagementService, times(1)).stopClatd(MOBILE_IFNAME);
|
||||
verify(mMockNetd, times(1)).clatdStop(MOBILE_IFNAME);
|
||||
|
||||
// Clat iface removed, expect linkproperties revert to original one
|
||||
clat.interfaceRemoved(CLAT_PREFIX + MOBILE_IFNAME);
|
||||
|
||||
@@ -32,11 +32,13 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.INetd;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.NetworkMisc;
|
||||
import android.net.NetworkStack;
|
||||
import android.os.INetworkManagementService;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.text.format.DateUtils;
|
||||
@@ -66,6 +68,8 @@ public class LingerMonitorTest {
|
||||
LingerMonitor mMonitor;
|
||||
|
||||
@Mock ConnectivityService mConnService;
|
||||
@Mock INetd mNetd;
|
||||
@Mock INetworkManagementService mNMS;
|
||||
@Mock Context mCtx;
|
||||
@Mock NetworkMisc mMisc;
|
||||
@Mock NetworkNotificationManager mNotifier;
|
||||
@@ -352,7 +356,7 @@ public class LingerMonitorTest {
|
||||
caps.addCapability(0);
|
||||
caps.addTransportType(transport);
|
||||
NetworkAgentInfo nai = new NetworkAgentInfo(null, null, new Network(netId), info, null,
|
||||
caps, 50, mCtx, null, mMisc, mConnService);
|
||||
caps, 50, mCtx, null, mMisc, mConnService, mNetd, mNMS);
|
||||
nai.everValidated = true;
|
||||
return nai;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
package com.android.server.connectivity;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -27,6 +25,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.INetd;
|
||||
import android.net.InterfaceConfiguration;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
@@ -57,6 +56,7 @@ public class Nat464XlatTest {
|
||||
|
||||
@Mock ConnectivityService mConnectivity;
|
||||
@Mock NetworkMisc mMisc;
|
||||
@Mock INetd mNetd;
|
||||
@Mock INetworkManagementService mNms;
|
||||
@Mock InterfaceConfiguration mConfig;
|
||||
@Mock NetworkAgentInfo mNai;
|
||||
@@ -65,7 +65,7 @@ public class Nat464XlatTest {
|
||||
Handler mHandler;
|
||||
|
||||
Nat464Xlat makeNat464Xlat() {
|
||||
return new Nat464Xlat(mNms, mNai);
|
||||
return new Nat464Xlat(mNai, mNetd, mNms);
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -129,7 +129,7 @@ public class Nat464XlatTest {
|
||||
nat.start();
|
||||
|
||||
verify(mNms).registerObserver(eq(nat));
|
||||
verify(mNms).startClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStart(eq(BASE_IFACE));
|
||||
|
||||
// Stacked interface up notification arrives.
|
||||
nat.interfaceLinkStateChanged(STACKED_IFACE, true);
|
||||
@@ -144,7 +144,7 @@ public class Nat464XlatTest {
|
||||
// ConnectivityService stops clat (Network disconnects, IPv4 addr appears, ...).
|
||||
nat.stop();
|
||||
|
||||
verify(mNms).stopClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStop(eq(BASE_IFACE));
|
||||
|
||||
// Stacked interface removed notification arrives.
|
||||
nat.interfaceRemoved(STACKED_IFACE);
|
||||
@@ -156,7 +156,7 @@ public class Nat464XlatTest {
|
||||
assertFalse(c.getValue().getAllInterfaceNames().contains(STACKED_IFACE));
|
||||
assertIdle(nat);
|
||||
|
||||
verifyNoMoreInteractions(mNms, mConnectivity);
|
||||
verifyNoMoreInteractions(mNetd, mNms, mConnectivity);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,7 +168,7 @@ public class Nat464XlatTest {
|
||||
nat.start();
|
||||
|
||||
verify(mNms).registerObserver(eq(nat));
|
||||
verify(mNms).startClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStart(eq(BASE_IFACE));
|
||||
|
||||
// Stacked interface up notification arrives.
|
||||
nat.interfaceLinkStateChanged(STACKED_IFACE, true);
|
||||
@@ -185,7 +185,7 @@ public class Nat464XlatTest {
|
||||
mLooper.dispatchNext();
|
||||
|
||||
verify(mNms).unregisterObserver(eq(nat));
|
||||
verify(mNms).stopClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStop(eq(BASE_IFACE));
|
||||
verify(mConnectivity, times(2)).handleUpdateLinkProperties(eq(mNai), c.capture());
|
||||
assertTrue(c.getValue().getStackedLinks().isEmpty());
|
||||
assertFalse(c.getValue().getAllInterfaceNames().contains(STACKED_IFACE));
|
||||
@@ -194,7 +194,7 @@ public class Nat464XlatTest {
|
||||
// ConnectivityService stops clat: no-op.
|
||||
nat.stop();
|
||||
|
||||
verifyNoMoreInteractions(mNms, mConnectivity);
|
||||
verifyNoMoreInteractions(mNetd, mNms, mConnectivity);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,13 +205,13 @@ public class Nat464XlatTest {
|
||||
nat.start();
|
||||
|
||||
verify(mNms).registerObserver(eq(nat));
|
||||
verify(mNms).startClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStart(eq(BASE_IFACE));
|
||||
|
||||
// ConnectivityService immediately stops clat (Network disconnects, IPv4 addr appears, ...)
|
||||
nat.stop();
|
||||
|
||||
verify(mNms).unregisterObserver(eq(nat));
|
||||
verify(mNms).stopClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStop(eq(BASE_IFACE));
|
||||
assertIdle(nat);
|
||||
|
||||
// In-flight interface up notification arrives: no-op
|
||||
@@ -225,7 +225,7 @@ public class Nat464XlatTest {
|
||||
|
||||
assertIdle(nat);
|
||||
|
||||
verifyNoMoreInteractions(mNms, mConnectivity);
|
||||
verifyNoMoreInteractions(mNetd, mNms, mConnectivity);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -236,16 +236,16 @@ public class Nat464XlatTest {
|
||||
nat.start();
|
||||
|
||||
verify(mNms).registerObserver(eq(nat));
|
||||
verify(mNms).startClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStart(eq(BASE_IFACE));
|
||||
|
||||
// ConnectivityService immediately stops clat (Network disconnects, IPv4 addr appears, ...)
|
||||
nat.stop();
|
||||
|
||||
verify(mNms).unregisterObserver(eq(nat));
|
||||
verify(mNms).stopClatd(eq(BASE_IFACE));
|
||||
verify(mNetd).clatdStop(eq(BASE_IFACE));
|
||||
assertIdle(nat);
|
||||
|
||||
verifyNoMoreInteractions(mNms, mConnectivity);
|
||||
verifyNoMoreInteractions(mNetd, mNms, mConnectivity);
|
||||
}
|
||||
|
||||
static void assertIdle(Nat464Xlat nat) {
|
||||
|
||||
Reference in New Issue
Block a user