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

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

Snap for 6626121 from ad90e1bf to rvc-release

Change-Id: Ic23a19bf3ccd554b79dfa77b7330b0656ac23048
parents 4c6ff45d ad90e1bf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ java_defaults {
        "netlink-client",
        "networkstack-client",
        "net-utils-framework-common",
        // See note on statsprotos when adding/updating proto build rules
        "datastallprotosnano",
        "statsprotos",
        "captiveportal-lib",
@@ -293,6 +294,8 @@ android_app {
    required: ["NetworkPermissionConfig"],
}

// When adding or modifying protos, the jarjar rules and possibly proguard rules need
// to be updated: proto libraries may pull additional static libraries.
java_library_static {
    name: "statsprotos",
    proto: {
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
rule com.android.net.module.util.** com.android.networkstack.util.@1

rule com.android.internal.util.** android.net.networkstack.util.@1
rule com.google.protobuf.** com.android.networkstack.protobuf.@1

# Classes from net-utils-framework-common
rule com.android.net.module.util.** com.android.networkstack.util.@1
+7 −0
Original line number Diff line number Diff line
@@ -7,3 +7,10 @@
    static final int CMD_*;
    static final int EVENT_*;
}

# The lite proto runtime uses reflection to access fields based on the names in
# the schema, keep all the fields.
# This replicates the base proguard rule used by the build by default
# (proguard_basic_keeps.flags), but needs to be specified here because the
# com.google.protobuf package is jarjared to the below package.
-keepclassmembers class * extends com.android.networkstack.protobuf.MessageLite { <fields>; }
+10 −1
Original line number Diff line number Diff line
@@ -120,12 +120,21 @@ public class IpProvisioningMetrics {
                transSuccess ? HostnameTransResult.HTR_SUCCESS : HostnameTransResult.HTR_FAILURE);
    }

    private static DhcpErrorCode dhcpErrorFromNumberSafe(int number) {
        // See DhcpErrorCode.errorCodeWithOption
        // TODO: add a DhcpErrorCode method to extract the code;
        //       or replace legacy error codes with the new metrics.
        final DhcpErrorCode error = DhcpErrorCode.forNumber(number & 0xFFFF0000);
        if (error == null) return DhcpErrorCode.ET_UNKNOWN;
        return error;
    }

    /**
     * write the DHCP error code into DhcpSession.
     */
    public void addDhcpErrorCode(final int errorCode) {
        if (mDhcpSessionBuilder.getErrorCodeCount() >= MAX_DHCP_ERROR_COUNT) return;
        mDhcpSessionBuilder.addErrorCode(DhcpErrorCode.forNumber(errorCode));
        mDhcpSessionBuilder.addErrorCode(dhcpErrorFromNumberSafe(errorCode));
    }

    /**
+14 −14
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.networkstack.metrics;

import android.net.dhcp.DhcpPacket;
import android.net.metrics.DhcpErrorEvent;
import android.stats.connectivity.DhcpErrorCode;
import android.stats.connectivity.DhcpFeature;
@@ -64,25 +65,24 @@ public class NetworkIpProvisioningMetricsTest {
        final NetworkIpProvisioningReported mStats;
        final IpProvisioningMetrics mMetrics = new IpProvisioningMetrics();
        mMetrics.reset();
        mMetrics.addDhcpErrorCode(DhcpErrorEvent.DHCP_ERROR);
        mMetrics.addDhcpErrorCode(DhcpErrorEvent.L2_WRONG_ETH_TYPE);
        mMetrics.addDhcpErrorCode(DhcpErrorEvent.L3_INVALID_IP);
        mMetrics.addDhcpErrorCode(DhcpErrorEvent.L4_WRONG_PORT);
        mMetrics.addDhcpErrorCode(DhcpErrorEvent.BOOTP_TOO_SHORT);
        mMetrics.addDhcpErrorCode(DhcpErrorEvent.DHCP_NO_COOKIE);
        mMetrics.addDhcpErrorCode(DhcpErrorEvent.errorCodeWithOption(
                DhcpErrorEvent.BUFFER_UNDERFLOW, DhcpPacket.DHCP_HOST_NAME));
        // Write the incorrect input number 50000 as DHCP error number
        int incorrectErrorCodeNumber = 50000;
        mMetrics.addDhcpErrorCode(incorrectErrorCodeNumber);
        for (int i = 0; i < mMetrics.MAX_DHCP_ERROR_COUNT; i++) {
            mMetrics.addDhcpErrorCode(DhcpErrorEvent.PARSING_ERROR);
        }
        mStats = mMetrics.statsWrite();
        assertEquals(DhcpErrorCode.ET_DHCP_ERROR, mStats.getDhcpSession().getErrorCode(0));
        assertEquals(DhcpErrorCode.ET_L2_WRONG_ETH_TYPE, mStats.getDhcpSession().getErrorCode(1));
        assertEquals(DhcpErrorCode.ET_L3_INVALID_IP, mStats.getDhcpSession().getErrorCode(2));
        assertEquals(DhcpErrorCode.ET_L4_WRONG_PORT, mStats.getDhcpSession().getErrorCode(3));
        assertEquals(DhcpErrorCode.ET_BOOTP_TOO_SHORT, mStats.getDhcpSession().getErrorCode(4));
        assertEquals(DhcpErrorCode.ET_DHCP_NO_COOKIE, mStats.getDhcpSession().getErrorCode(5));
        // Check can record the same error code
        assertEquals(DhcpErrorCode.ET_PARSING_ERROR, mStats.getDhcpSession().getErrorCode(6));
        assertEquals(DhcpErrorCode.ET_PARSING_ERROR, mStats.getDhcpSession().getErrorCode(6));
        assertEquals(DhcpErrorCode.ET_BOOTP_TOO_SHORT, mStats.getDhcpSession().getErrorCode(0));
        assertEquals(DhcpErrorCode.ET_BUFFER_UNDERFLOW, mStats.getDhcpSession().getErrorCode(1));
        // When the input is an invalid integer value (such as incorrectErrorCodeNumber),
        // the DhcpErrorCode will be ET_UNKNOWN
        assertEquals(DhcpErrorCode.ET_UNKNOWN, mStats.getDhcpSession().getErrorCode(2));
        // If the same error code appears, it must be recorded
        assertEquals(DhcpErrorCode.ET_PARSING_ERROR, mStats.getDhcpSession().getErrorCode(3));
        assertEquals(DhcpErrorCode.ET_PARSING_ERROR, mStats.getDhcpSession().getErrorCode(4));
        // The maximum number of DHCP error code counts is MAX_DHCP_ERROR_COUNT
        assertEquals(mMetrics.MAX_DHCP_ERROR_COUNT, mStats.getDhcpSession().getErrorCodeCount());
    }