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

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

Snap for 6188643 from 8b7011f0 to rvc-release

Change-Id: Ia04326d06960b8b52a0dc4d713fbc625af078123
parents b5115ac2 8b7011f0
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -133,6 +133,15 @@ android_library {
    manifest: "AndroidManifestBase.xml",
}

filegroup {
    name: "NetworkStackJarJarRules",
    srcs: ["jarjar-rules-shared.txt"],
    visibility: [
        "//packages/modules/NetworkStack/tests/unit",
        "//packages/modules/NetworkStack/tests/integration",
    ]
}

// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
java_defaults {
    name: "NetworkStackAppDefaults",
@@ -143,7 +152,7 @@ java_defaults {
    ],
    // Resources already included in NetworkStackBase
    resource_dirs: [],
    jarjar_rules: "jarjar-rules-shared.txt",
    jarjar_rules: ":NetworkStackJarJarRules",
    use_embedded_native_libs: true,
    optimize: {
        proguard_flags_files: ["proguard.flags"],
@@ -201,6 +210,7 @@ android_library {
    defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
    static_libs: ["NetworkStackApiStableLib"],
    manifest: "AndroidManifestBase.xml",
    visibility: ["//frameworks/base/tests/net/integration"],
}

cc_library_shared {
+43 −13
Original line number Diff line number Diff line
@@ -14,31 +14,61 @@
// limitations under the License.
//

android_test {
    name: "NetworkStackIntegrationTests",
    certificate: "networkstack",
java_defaults {
    name: "NetworkStackIntegrationTestsJniDefaults",
    defaults: ["libnetworkstackutilsjni_deps"],
    jni_libs: [
        // For mockito extended
        "libdexmakerjvmtiagent",
        "libstaticjvmtiagent",
        // For NetworkStackUtils included in NetworkStackBase
        "libnetworkstackutilsjni",
    ],
    visibility: ["//visibility:private"],
}

android_library {
    name: "NetworkStackIntegrationTestsLib",
    min_sdk_version: "29",
    srcs: ["src/**/*.java"],
    test_suites: ["device-tests"],
    static_libs: [
        "androidx.annotation_annotation",
        "androidx.test.rules",
        "mockito-target-extended-minus-junit4",
        "net-tests-utils",
        "testables",
        "TestNetworkStackLib",
        "NetworkStackApiStableLib",
    ],
    libs: [
        "android.test.runner",
        "android.test.base",
        "android.test.mock",
    ],
    defaults: ["libnetworkstackutilsjni_deps"],
    jni_libs: [
        // For mockito extended
        "libdexmakerjvmtiagent",
        "libstaticjvmtiagent",
        // For NetworkStackUtils included in NetworkStackBase
        "libnetworkstackutilsjni",
    ],
    jarjar_rules: ":NetworkStackJarJarRules",
    visibility: ["//visibility:private"],
}

// Network stack integration tests.
android_test {
    name: "NetworkStackIntegrationTests",
    defaults: ["NetworkStackIntegrationTestsJniDefaults"],
    static_libs: ["NetworkStackIntegrationTestsLib"],
    certificate: "networkstack",
    platform_apis: true,
    test_suites: ["device-tests"],
    min_sdk_version: "29",
}

// Special version of the network stack tests that includes all tests necessary for code coverage
// purposes. This is currently the union of NetworkStackTests and NetworkStackIntegrationTests.
android_test {
    name: "NetworkStackCoverageTests",
    certificate: "networkstack",
    platform_apis: true,
    min_sdk_version: "29",
    test_suites: ["device-tests", "mts"],
    defaults: ["NetworkStackIntegrationTestsJniDefaults"],
    static_libs: ["NetworkStackTestsLib", "NetworkStackIntegrationTestsLib"],
    compile_multilib: "both",
    manifest: "AndroidManifest_coverage.xml",
}
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2019 The Android Open Source Project
<!-- Copyright (C) 2020 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
@@ -13,17 +13,24 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<configuration description="Runs Integration Tests for NetworkStack">
    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
        <option name="test-file-name" value="NetworkStackIntegrationTests.apk" />
    </target_preparer>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.server.networkstack.coverage"
          android:sharedUserId="android.uid.networkstack">
    <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />

    <option name="test-suite-tag" value="apct" />
    <option name="test-suite-tag" value="framework-base-presubmit" />
    <option name="test-tag" value="NetworkStackIntegrationTests" />
    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
        <option name="package" value="com.android.server.networkstack.integrationtests" />
        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
        <option name="hidden-api-checks" value="false"/>
    </test>
</configuration>
    <!-- Note: do not add any privileged or signature permissions that are granted
         to the network stack app. Otherwise, the test APK will install, but when the device is
         rebooted, it will bootloop with something like:

         05-14 00:41:02.723 18330 18330 E AndroidRuntime: java.lang.IllegalStateException: Signature|privileged permissions not in privapp-permissions whitelist: {com.android.server.networkstack.integrationtests: android.permission.CONNECTIVITY_INTERNAL}
    -->
    <uses-permission android:name="android.permission.MAINLINE_NETWORK_STACK" />

    <application android:debuggable="true">
        <uses-library android:name="android.test.runner" />
    </application>
    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
        android:targetPackage="com.android.server.networkstack.coverage"
        android:label="Networking stack coverage tests">
    </instrumentation>
</manifest>
+21 −5
Original line number Diff line number Diff line
@@ -25,13 +25,12 @@ import static android.net.dhcp.DhcpPacket.ENCAP_L2;
import static android.net.dhcp.DhcpPacket.INADDR_BROADCAST;
import static android.net.dhcp.DhcpPacket.INFINITE_LEASE;
import static android.net.ipmemorystore.Status.SUCCESS;
import static android.net.networkstack.shared.Inet4AddressUtils.getBroadcastAddress;
import static android.net.networkstack.shared.Inet4AddressUtils.getPrefixMaskAsInet4Address;
import static android.net.shared.Inet4AddressUtils.getBroadcastAddress;
import static android.net.shared.Inet4AddressUtils.getPrefixMaskAsInet4Address;
import static android.system.OsConstants.ETH_P_IPV6;
import static android.system.OsConstants.IPPROTO_ICMPV6;
import static android.system.OsConstants.IPPROTO_TCP;

import static com.android.internal.util.BitUtils.uint16;
import static com.android.server.util.NetworkStackConstants.ARP_REPLY;
import static com.android.server.util.NetworkStackConstants.ARP_REQUEST;
import static com.android.server.util.NetworkStackConstants.ETHER_ADDR_LEN;
@@ -96,18 +95,19 @@ import android.net.dhcp.DhcpRequestPacket;
import android.net.ipmemorystore.NetworkAttributes;
import android.net.ipmemorystore.OnNetworkAttributesRetrievedListener;
import android.net.ipmemorystore.Status;
import android.net.networkstack.util.StateMachine;
import android.net.shared.ProvisioningConfiguration;
import android.net.util.InterfaceParams;
import android.net.util.IpUtils;
import android.net.util.NetworkStackUtils;
import android.net.util.PacketReader;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.system.ErrnoException;
import android.system.Os;

@@ -116,6 +116,8 @@ import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.util.StateMachine;
import com.android.networkstack.apishim.ShimUtils;
import com.android.networkstack.arp.ArpPacket;
import com.android.server.NetworkObserverRegistry;
import com.android.server.NetworkStackService.NetworkStackServiceManager;
@@ -600,13 +602,23 @@ public class IpClientIntegrationTest {
            final List<DhcpPacket> packetList) throws Exception {
        for (DhcpPacket packet : packetList) {
            if (!isHostnameConfigurationEnabled || hostname == null) {
                assertNull(packet.getHostname());
                assertNoHostname(packet.getHostname());
            } else {
                assertEquals(packet.getHostname(), hostnameAfterTransliteration);
            }
        }
    }

    private void assertNoHostname(String hostname) {
        if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) {
            assertNull(hostname);
        } else {
            // Until Q, if no hostname is set, the device falls back to the hostname set via
            // system property, to avoid breaking Q devices already launched with that setup.
            assertEquals(SystemProperties.get("net.hostname"), hostname);
        }
    }

    // Helper method to complete DHCP 2-way or 4-way handshake
    private List<DhcpPacket> performDhcpHandshake(final boolean isSuccessLease,
            final Integer leaseTimeSec, final boolean isDhcpLeaseCacheEnabled,
@@ -1137,6 +1149,10 @@ public class IpClientIntegrationTest {
        return (short) ~tempSum;
    }

    public static int uint16(short s) {
        return s & 0xffff;
    }

    private static short icmpv6Checksum(ByteBuffer buf, int ipOffset, int transportOffset,
            int transportLen) {
        // The ICMPv6 checksum is the same as the TCP checksum, except the pseudo-header uses
+13 −0
Original line number Diff line number Diff line
@@ -38,8 +38,10 @@ java_defaults {
        "libstaticjvmtiagent",
        "libnetworkstackutilsjni",
    ],
    jarjar_rules: ":NetworkStackJarJarRules",
}

// Tests for NetworkStackNext.
android_test {
    name: "NetworkStackNextTests",
    srcs: [], // TODO: tests that only apply to the current, non-stable API can be added here
@@ -48,6 +50,17 @@ android_test {
    static_libs: ["NetworkStackApiCurrentLib"],
}

// Library containing the unit tests. This is used by the coverage test target to pull in the
// unit test code. It is not currently used by the tests themselves because all the build
// configuration needed by the tests is in the NetworkStackTestsDefaults rule.
android_library {
    name: "NetworkStackTestsLib",
    min_sdk_version: "29",
    defaults: ["NetworkStackTestsDefaults"],
    static_libs: ["NetworkStackApiStableLib"],
    visibility: ["//packages/modules/NetworkStack/tests/integration"]
}

android_test {
    name: "NetworkStackTests",
    min_sdk_version: "29",
Loading