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

Commit 84017f01 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6416579 from cfb84932 to sc-release

Change-Id: If725d5dbd4cc30808b4eb00c98fa660b54418a7a
parents fd50dc77 cfb84932
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -132,12 +132,14 @@ import com.android.networkstack.arp.ArpPacket;
import com.android.server.NetworkObserverRegistry;
import com.android.server.NetworkStackService.NetworkStackServiceManager;
import com.android.server.connectivity.ipmemorystore.IpMemoryStoreService;
import com.android.testutils.DevSdkIgnoreRule;
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
import com.android.testutils.HandlerUtilsKt;
import com.android.testutils.TapPacketReader;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -174,6 +176,9 @@ public class IpClientIntegrationTest {
    private static final String TEST_GROUPHINT = "some grouphint";
    private static final int TEST_LEASE_DURATION_S = 3_600; // 1 hour

    @Rule
    public final DevSdkIgnoreRule mIgnoreRule = new DevSdkIgnoreRule();

    @Mock private Context mContext;
    @Mock private ConnectivityManager mCm;
    @Mock private Resources mResources;
@@ -1650,11 +1655,17 @@ public class IpClientIntegrationTest {

        final Uri expectedUrl = featureEnabled && serverSendsOption
                ? Uri.parse(TEST_CAPTIVE_PORTAL_URL) : null;
        // Wait for LinkProperties containing DHCP-obtained info, such as MTU, and ensure that the
        // URL is set as expected
        verify(mCb, timeout(TEST_TIMEOUT_MS)).onLinkPropertiesChange(argThat(lp ->
                lp.getMtu() == testMtu
                        && Objects.equals(expectedUrl, lp.getCaptivePortalApiUrl())));
        // Wait for LinkProperties containing DHCP-obtained info, such as MTU
        final ArgumentCaptor<LinkProperties> captor = ArgumentCaptor.forClass(LinkProperties.class);
        verify(mCb, timeout(TEST_TIMEOUT_MS)).onLinkPropertiesChange(
                argThat(lp -> lp.getMtu() == testMtu));

        // Ensure that the URL was set as expected in the callbacks.
        // Can't verify the URL up to Q as there is no such attribute in LinkProperties.
        if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) return;
        verify(mCb).onLinkPropertiesChange(captor.capture());
        assertTrue(captor.getAllValues().stream().anyMatch(
                lp -> Objects.equals(expectedUrl, lp.getCaptivePortalApiUrl())));
    }

    @Test
+5 −4
Original line number Diff line number Diff line
@@ -27,9 +27,10 @@ import kotlin.concurrent.withLock
 */
interface TrackRecord<E> : List<E> {
    /**
     * Adds an element to this queue, waking up threads waiting for one. Returns the element.
     * Adds an element to this queue, waking up threads waiting for one. Returns true, as
     * per the contract for List.
     */
    fun add(e: E): TrackRecord<E>
    fun add(e: E): Boolean

    /**
     * Returns the first element after {@param pos}, possibly blocking until one is available, or
@@ -91,12 +92,12 @@ class ArrayTrackRecord<E> : TrackRecord<E> {
    }

    // TrackRecord<E> implementation
    override fun add(e: E): ArrayTrackRecord<E> {
    override fun add(e: E): Boolean {
        lock.withLock {
            elements.add(e)
            condition.signalAll()
        }
        return this
        return true
    }
    override fun poll(timeoutMs: Long, pos: Int, predicate: (E) -> Boolean) = lock.withLock {
        elements.getOrNull(pollForIndexReadLocked(timeoutMs, pos, predicate))
+7 −7
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public class StructNdOptPref64Test {
    }

    private void assertToByteBufferMatches(StructNdOptPref64 opt, String expected) {
        String actual = HexEncoding.encodeToString(opt.toByteBuffer().array(), false /*upperCase*/);
        String actual = HexEncoding.encodeToString(opt.toByteBuffer().array());
        assertEquals(expected, actual);
    }

@@ -85,18 +85,18 @@ public class StructNdOptPref64Test {
    public void testParseCannedOption() throws Exception {
        String hexBytes = "2602"               // type=38, len=2 (16 bytes)
                + "0088"                       // lifetime=136, PLC=0 (/96)
                + "20010db80003000400050006";  // 2001:db8:3:4:5:6/96
                + "20010DB80003000400050006";  // 2001:db8:3:4:5:6/96
        byte[] rawBytes = HexEncoding.decode(hexBytes);
        StructNdOptPref64 opt = StructNdOptPref64.parse(ByteBuffer.wrap(rawBytes));
        assertPref64OptMatches(136, prefix("2001:db8:3:4:5:6::", 96), opt);
        assertPref64OptMatches(136, prefix("2001:DB8:3:4:5:6::", 96), opt);
        assertToByteBufferMatches(opt, hexBytes);

        hexBytes = "2602"                      // type=38, len=2 (16 bytes)
                + "2752"                       // lifetime=10064, PLC=2 (/56)
                + "0064ff9b0000000000000000";  // 64:ff9b::/56
                + "0064FF9B0000000000000000";  // 64:ff9b::/56
        rawBytes = HexEncoding.decode(hexBytes);
        opt = StructNdOptPref64.parse(ByteBuffer.wrap(rawBytes));
        assertPref64OptMatches(10064, prefix("64:ff9b::", 56), opt);
        assertPref64OptMatches(10064, prefix("64:FF9B::", 56), opt);
        assertToByteBufferMatches(opt, hexBytes);
    }

@@ -185,12 +185,12 @@ public class StructNdOptPref64Test {
        final IpPrefix prefix2 = prefix(PREFIX2, 96);

        StructNdOptPref64 opt = new StructNdOptPref64(prefix1, 600);
        assertToByteBufferMatches(opt, "2602025a0064ff9b0000000000000000");
        assertToByteBufferMatches(opt, "2602025A0064FF9B0000000000000000");
        assertEquals(new IpPrefix("64:ff9b::/56"), opt.prefix);
        assertEquals(600, opt.lifetime);

        opt = new StructNdOptPref64(prefix2, 65519);
        assertToByteBufferMatches(opt, "2602ffe820010db80001000200030064");
        assertToByteBufferMatches(opt, "2602FFE820010DB80001000200030064");
        assertEquals(new IpPrefix("2001:db8:1:2:3:64::/96"), opt.prefix);
        assertEquals(65512, opt.lifetime);

+6 −4
Original line number Diff line number Diff line
@@ -29,10 +29,10 @@ import android.os.Build
import android.os.IBinder
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.networkstack.apishim.ShimUtils
import com.android.testutils.DevSdkIgnoreRule
import org.junit.After
import org.junit.Assume.assumeTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.any
@@ -50,6 +50,10 @@ class ModuleNetworkStackClientTest {
    private val TEST_NETWORK = Network(43)
    private val TEST_TIMEOUT_MS = 500L

    // ModuleNetworkStackClient is only available after Q
    @Rule @JvmField
    val mIgnoreRule = DevSdkIgnoreRule(ignoreClassUpTo = Build.VERSION_CODES.Q)

    @Mock
    private lateinit var mContext: Context
    @Mock
@@ -67,8 +71,6 @@ class ModuleNetworkStackClientTest {

    @Before
    fun setUp() {
        // ModuleNetworkStackClient is only available after Q
        assumeTrue(ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q))
        MockitoAnnotations.initMocks(this)
        doReturn(mConnector).`when`(mConnectorBinder).queryLocalInterface(
                INetworkStackConnector::class.qualifiedName!!)
+7 −0
Original line number Diff line number Diff line
@@ -19,7 +19,10 @@ package android.net.testutils
import android.net.NetworkStats
import android.net.NetworkStats.SET_DEFAULT
import android.net.NetworkStats.TAG_NONE
import android.os.Build
import com.android.testutils.DevSdkIgnoreRule
import com.android.testutils.orderInsensitiveEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -32,6 +35,10 @@ private const val TEST_START = 1194220800000L

@RunWith(JUnit4::class)
class NetworkStatsUtilsTest {
    // This is a unit test for a test utility that uses R APIs
    @Rule @JvmField
    val ignoreRule = DevSdkIgnoreRule(ignoreClassUpTo = Build.VERSION_CODES.Q)

    @Test
    fun testOrderInsensitiveEquals() {
        val testEntry = arrayOf(
Loading