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

Commit 6f27d8d7 authored by Oscar Shu's avatar Oscar Shu Committed by Android (Google) Code Review
Browse files

Merge "Add StaLinkLayerStats V1_3"

parents d3516e43 e9873256
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -7,7 +7,9 @@ hidl_interface {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IWifi.hal",
        "IWifiStaIface.hal",
    ],
    interfaces: [
        "android.hardware.wifi@1.0",
@@ -15,6 +17,10 @@ hidl_interface {
        "android.hardware.wifi@1.2",
        "android.hidl.base@1.0",
    ],
    types: [
      "StaLinkLayerRadioStats",
      "StaLinkLayerStats",
    ],
    gen_java: true,
}
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 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.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.wifi@1.3;

import @1.0::WifiStatus;
import @1.2::IWifiStaIface;

/**
 * Interface used to represent a single STA iface.
 *
 * IWifiChip.createStaIface() may return a @1.3::IWifiStaIface when supported.
 */
interface IWifiStaIface extends @1.2::IWifiStaIface {
    /**
     * Retrieve the latest link layer stats.
     * Must fail if |StaIfaceCapabilityMask.LINK_LAYER_STATS| is not set or if
     * link layer stats collection hasn't been explicitly enabled.
     *
     * @return status WifiStatus of the operation.
     *     Possible status codes:
     *     |WifiStatusCode.SUCCESS|,
     *     |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
     *     |WifiStatusCode.ERROR_NOT_SUPPORTED|,
     *     |WifiStatusCode.ERROR_NOT_STARTED|,
     *     |WifiStatusCode.ERROR_NOT_AVAILABLE|,
     *     |WifiStatusCode.ERROR_UNKNOWN|
     * @return stats Instance of |LinkLayerStats|.
     */
    getLinkLayerStats_1_3() generates (WifiStatus status, StaLinkLayerStats stats);
};
+18 −8
Original line number Diff line number Diff line
@@ -785,7 +785,7 @@ bool convertLegacyVectorOfDebugRxPacketFateToHidl(

bool convertLegacyLinkLayerStatsToHidl(
    const legacy_hal::LinkLayerStats& legacy_stats,
    StaLinkLayerStats* hidl_stats) {
    V1_3::StaLinkLayerStats* hidl_stats) {
    if (!hidl_stats) {
        return false;
    }
@@ -826,16 +826,26 @@ bool convertLegacyLinkLayerStatsToHidl(
    hidl_stats->iface.wmeVoPktStats.retries =
        legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries;
    // radio legacy_stats conversion.
    std::vector<StaLinkLayerRadioStats> hidl_radios_stats;
    std::vector<V1_3::StaLinkLayerRadioStats> hidl_radios_stats;
    for (const auto& legacy_radio_stats : legacy_stats.radios) {
        StaLinkLayerRadioStats hidl_radio_stats;
        hidl_radio_stats.onTimeInMs = legacy_radio_stats.stats.on_time;
        hidl_radio_stats.txTimeInMs = legacy_radio_stats.stats.tx_time;
        hidl_radio_stats.rxTimeInMs = legacy_radio_stats.stats.rx_time;
        hidl_radio_stats.onTimeInMsForScan =
        V1_3::StaLinkLayerRadioStats hidl_radio_stats;
        hidl_radio_stats.V1_0.onTimeInMs = legacy_radio_stats.stats.on_time;
        hidl_radio_stats.V1_0.txTimeInMs = legacy_radio_stats.stats.tx_time;
        hidl_radio_stats.V1_0.rxTimeInMs = legacy_radio_stats.stats.rx_time;
        hidl_radio_stats.V1_0.onTimeInMsForScan =
            legacy_radio_stats.stats.on_time_scan;
        hidl_radio_stats.txTimeInMsPerLevel =
        hidl_radio_stats.V1_0.txTimeInMsPerLevel =
            legacy_radio_stats.tx_time_per_levels;
        hidl_radio_stats.onTimeInMsForNanScan =
            legacy_radio_stats.stats.on_time_nbd;
        hidl_radio_stats.onTimeInMsForBgScan =
            legacy_radio_stats.stats.on_time_gscan;
        hidl_radio_stats.onTimeInMsForRoamScan =
            legacy_radio_stats.stats.on_time_roam_scan;
        hidl_radio_stats.onTimeInMsForPnoScan =
            legacy_radio_stats.stats.on_time_pno_scan;
        hidl_radio_stats.onTimeInMsForHs20Scan =
            legacy_radio_stats.stats.on_time_hs20;
        hidl_radios_stats.push_back(hidl_radio_stats);
    }
    hidl_stats->radios = hidl_radios_stats;
+2 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <android/hardware/wifi/1.2/IWifiChip.h>
#include <android/hardware/wifi/1.2/IWifiChipEventCallback.h>
#include <android/hardware/wifi/1.2/types.h>
#include <android/hardware/wifi/1.3/types.h>

#include "wifi_legacy_hal.h"

@@ -89,7 +90,7 @@ bool convertLegacyVectorOfCachedGscanResultsToHidl(
    std::vector<StaScanData>* hidl_scan_datas);
bool convertLegacyLinkLayerStatsToHidl(
    const legacy_hal::LinkLayerStats& legacy_stats,
    StaLinkLayerStats* hidl_stats);
    V1_3::StaLinkLayerStats* hidl_stats);
bool convertLegacyRoamingCapabilitiesToHidl(
    const legacy_hal::wifi_roaming_capabilities& legacy_caps,
    StaRoamingCapabilities* hidl_caps);
+112 −0
Original line number Diff line number Diff line
@@ -126,6 +126,118 @@ TEST_F(HidlStructUtilTest, CanConvertLegacyWifiMacInfosToHidlWithTwoMac) {
    EXPECT_EQ(static_cast<uint32_t>(legacy_iface_info2.channel),
              hidl_iface_info2.channel);
}

TEST_F(HidlStructUtilTest, canConvertLegacyLinkLayerStatsToHidl) {
    legacy_hal::LinkLayerStats legacy_stats{};
    legacy_stats.radios.push_back(legacy_hal::LinkLayerRadioStats{});
    legacy_stats.radios.push_back(legacy_hal::LinkLayerRadioStats{});
    legacy_stats.iface.beacon_rx = rand();
    legacy_stats.iface.rssi_mgmt = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].rx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].tx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].mpdu_lost = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].retries = rand();

    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].rx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].tx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].mpdu_lost = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].retries = rand();

    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].rx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].tx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].mpdu_lost = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].retries = rand();

    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].rx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].tx_mpdu = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].mpdu_lost = rand();
    legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries = rand();

    for (auto& radio : legacy_stats.radios) {
        radio.stats.on_time = rand();
        radio.stats.tx_time = rand();
        radio.stats.rx_time = rand();
        radio.stats.on_time_scan = rand();
        radio.stats.on_time_nbd = rand();
        radio.stats.on_time_gscan = rand();
        radio.stats.on_time_roam_scan = rand();
        radio.stats.on_time_pno_scan = rand();
        radio.stats.on_time_hs20 = rand();
        for (int i = 0; i < 4; i++) {
            radio.tx_time_per_levels.push_back(rand());
        }
    }

    V1_3::StaLinkLayerStats converted{};
    hidl_struct_util::convertLegacyLinkLayerStatsToHidl(legacy_stats,
                                                        &converted);
    EXPECT_EQ(legacy_stats.iface.beacon_rx, converted.iface.beaconRx);
    EXPECT_EQ(legacy_stats.iface.rssi_mgmt, converted.iface.avgRssiMgmt);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].rx_mpdu,
              converted.iface.wmeBePktStats.rxMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].tx_mpdu,
              converted.iface.wmeBePktStats.txMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].mpdu_lost,
              converted.iface.wmeBePktStats.lostMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].retries,
              converted.iface.wmeBePktStats.retries);

    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].rx_mpdu,
              converted.iface.wmeBkPktStats.rxMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].tx_mpdu,
              converted.iface.wmeBkPktStats.txMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].mpdu_lost,
              converted.iface.wmeBkPktStats.lostMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].retries,
              converted.iface.wmeBkPktStats.retries);

    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].rx_mpdu,
              converted.iface.wmeViPktStats.rxMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].tx_mpdu,
              converted.iface.wmeViPktStats.txMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].mpdu_lost,
              converted.iface.wmeViPktStats.lostMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].retries,
              converted.iface.wmeViPktStats.retries);

    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].rx_mpdu,
              converted.iface.wmeVoPktStats.rxMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].tx_mpdu,
              converted.iface.wmeVoPktStats.txMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].mpdu_lost,
              converted.iface.wmeVoPktStats.lostMpdu);
    EXPECT_EQ(legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries,
              converted.iface.wmeVoPktStats.retries);

    EXPECT_EQ(legacy_stats.radios.size(), converted.radios.size());
    for (int i = 0; i < legacy_stats.radios.size(); i++) {
        EXPECT_EQ(legacy_stats.radios[i].stats.on_time,
                  converted.radios[i].V1_0.onTimeInMs);
        EXPECT_EQ(legacy_stats.radios[i].stats.tx_time,
                  converted.radios[i].V1_0.txTimeInMs);
        EXPECT_EQ(legacy_stats.radios[i].stats.rx_time,
                  converted.radios[i].V1_0.rxTimeInMs);
        EXPECT_EQ(legacy_stats.radios[i].stats.on_time_scan,
                  converted.radios[i].V1_0.onTimeInMsForScan);
        EXPECT_EQ(legacy_stats.radios[i].tx_time_per_levels.size(),
                  converted.radios[i].V1_0.txTimeInMsPerLevel.size());
        for (int j = 0; j < legacy_stats.radios[i].tx_time_per_levels.size();
             j++) {
            EXPECT_EQ(legacy_stats.radios[i].tx_time_per_levels[j],
                      converted.radios[i].V1_0.txTimeInMsPerLevel[j]);
        }
        EXPECT_EQ(legacy_stats.radios[i].stats.on_time_nbd,
                  converted.radios[i].onTimeInMsForNanScan);
        EXPECT_EQ(legacy_stats.radios[i].stats.on_time_gscan,
                  converted.radios[i].onTimeInMsForBgScan);
        EXPECT_EQ(legacy_stats.radios[i].stats.on_time_roam_scan,
                  converted.radios[i].onTimeInMsForRoamScan);
        EXPECT_EQ(legacy_stats.radios[i].stats.on_time_pno_scan,
                  converted.radios[i].onTimeInMsForPnoScan);
        EXPECT_EQ(legacy_stats.radios[i].stats.on_time_hs20,
                  converted.radios[i].onTimeInMsForHs20Scan);
    }
}
}  // namespace implementation
}  // namespace V1_3
}  // namespace wifi
Loading