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

Commit 0d29cf99 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "radio_mode_cbs_hidl"

* changes:
  wifi(implementation): Invoke radio mode change callbacks
  wifi(implementation): Conversion functions for radio mode change
  wifi(implementation): WifiLegacyHal interface for radio mode change
  wifi(interface): Add callbacks for indicating radio mode changes
parents f30add84 85c6441f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ hidl_interface {
        "types.hal",
        "IWifi.hal",
        "IWifiChip.hal",
        "IWifiChipEventCallback.hal",
        "IWifiNanIface.hal",
        "IWifiNanIfaceEventCallback.hal",
    ],
+16 −0
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package android.hardware.wifi@1.2;

import @1.0::WifiStatus;
import @1.1::IWifiChip;
import IWifiChipEventCallback;

/**
 * Interface that represents a chip that must be configured as a single unit.
@@ -24,4 +26,18 @@ import @1.1::IWifiChip;
 * to perform operations like NAN, RTT, etc.
 */
interface IWifiChip extends @1.1::IWifiChip {
    /**
     * Requests notifications of significant events on this chip. Multiple calls
     * to this must register multiple callbacks each of which must receive all
     * events.
     *
     * @param callback An instance of the |IWifiChipEventCallback| HIDL interface
     *        object.
     * @return status WifiStatus of the operation.
     *         Possible status codes:
     *         |WifiStatusCode.SUCCESS|,
     *         |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|
     */
    registerEventCallback_1_2(IWifiChipEventCallback callback)
        generates (WifiStatus status);
};
+71 −0
Original line number Diff line number Diff line
/*
 * Copyright 2017 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.2;

import @1.0::IWifiChipEventCallback;
import @1.0::WifiBand;

/**
 * Wifi chip event callbacks.
 */
interface IWifiChipEventCallback extends @1.0::IWifiChipEventCallback {
    /**
     * Struct describing the state of each iface operating on the radio chain
     * (hardware MAC) on the device.
     */
    struct IfaceInfo {
        /** Name of the interface (For ex: "wlan0"). */
        string name;
        /** Wifi channel on which this interface is operating. */
        uint32_t channel;
    };

    /**
     * Struct describing the state of each hardware radio chain (hardware MAC)
     * on the device.
     */
    struct RadioModeInfo {
        /**
         * Identifier for this radio chain. This is vendor dependent & used
         * only for debugging purposes.
         */
        uint32_t radioId;
        /**
         * List of bands on which this radio chain is operating.
         * Can be one of:
         * a) WifiBand.BAND_24GHZ => 2.4Ghz.
         * b) WifiBand.BAND_5GHZ => 5Ghz.
         * c) WifiBand.BAND_24GHZ_5GHZ = 2.4Ghz + 5Ghz (Radio is time sharing
         * across the 2 bands).
         */
        WifiBand bandInfo;
        /** List of interfaces on this radio chain (hardware MAC). */
        vec<IfaceInfo> ifaceInfos;
    };

    /**
     * Asynchronous callback indicating a radio mode change.
     * Radio mode change could be a result of:
     * a) Bringing up concurrent interfaces (For ex: STA + AP).
     * b) Change in operating band of one of the concurrent interfaces (For ex:
     * STA connection moved from 2.4G to 5G)
     *
     * @param radioModeInfos List of RadioModeInfo structures for each
     * radio chain (hardware MAC) on the device.
     */
    oneway onRadioModeChange(vec<RadioModeInfo> radioModeInfos);
};
+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.wifi@1.0-service-tests
LOCAL_PROPRIETARY_MODULE := true
LOCAL_SRC_FILES := \
    tests/hidl_struct_util_unit_tests.cpp \
    tests/main.cpp \
    tests/mock_wifi_feature_flags.cpp \
    tests/mock_wifi_legacy_hal.cpp \
+51 −0
Original line number Diff line number Diff line
@@ -266,6 +266,57 @@ legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
    CHECK(false);
}

bool convertLegacyWifiMacInfoToHidl(
    const legacy_hal::WifiMacInfo& legacy_mac_info,
    IWifiChipEventCallback::RadioModeInfo* hidl_radio_mode_info) {
    if (!hidl_radio_mode_info) {
        return false;
    }
    *hidl_radio_mode_info = {};

    hidl_radio_mode_info->radioId = legacy_mac_info.wlan_mac_id;
    // Convert from bitmask of bands in the legacy HAL to enum value in
    // the HIDL interface.
    if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND &&
        legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND) {
        hidl_radio_mode_info->bandInfo = WifiBand::BAND_24GHZ_5GHZ;
    } else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND) {
        hidl_radio_mode_info->bandInfo = WifiBand::BAND_24GHZ;
    } else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND) {
        hidl_radio_mode_info->bandInfo = WifiBand::BAND_5GHZ;
    } else {
        hidl_radio_mode_info->bandInfo = WifiBand::BAND_UNSPECIFIED;
    }
    std::vector<IWifiChipEventCallback::IfaceInfo> iface_info_vec;
    for (const auto& legacy_iface_info : legacy_mac_info.iface_infos) {
        IWifiChipEventCallback::IfaceInfo iface_info;
        iface_info.name = legacy_iface_info.name;
        iface_info.channel = legacy_iface_info.channel;
        iface_info_vec.push_back(iface_info);
    }
    hidl_radio_mode_info->ifaceInfos = iface_info_vec;
    return true;
}

bool convertLegacyWifiMacInfosToHidl(
    const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
    std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos) {
    if (!hidl_radio_mode_infos) {
        return false;
    }
    *hidl_radio_mode_infos = {};

    for (const auto& legacy_mac_info : legacy_mac_infos) {
        IWifiChipEventCallback::RadioModeInfo hidl_radio_mode_info;
        if (!convertLegacyWifiMacInfoToHidl(legacy_mac_info,
                                            &hidl_radio_mode_info)) {
            return false;
        }
        hidl_radio_mode_infos->push_back(hidl_radio_mode_info);
    }
    return true;
}

bool convertLegacyFeaturesToHidlStaCapabilities(
    uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
    uint32_t* hidl_caps) {
Loading