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

Commit 263db45e authored by Gabriel Biren's avatar Gabriel Biren
Browse files

Update usages of WifiRadioCombinationMatrix in

the Vendor HAL service.

Bug: 267819850
Test: Run the gTest suite under default/tests
Change-Id: I18feb87f16abbc9ece9186b2e92e19984a5a90f0
parent 432807e4
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -2996,14 +2996,13 @@ bool convertLegacyWifiRadioConfigurationToAidl(

bool convertLegacyRadioCombinationsMatrixToAidl(
        legacy_hal::wifi_radio_combination_matrix* legacy_matrix,
        WifiRadioCombinationMatrix* aidl_matrix) {
    if (!aidl_matrix || !legacy_matrix) {
        std::vector<WifiRadioCombination>* aidl_combinations) {
    if (!aidl_combinations || !legacy_matrix) {
        return false;
    }
    *aidl_matrix = {};
    *aidl_combinations = {};

    int num_combinations = legacy_matrix->num_radio_combinations;
    std::vector<WifiRadioCombination> radio_combinations_vec;
    if (!num_combinations) {
        LOG(ERROR) << "zero radio combinations";
        return false;
@@ -3029,13 +3028,12 @@ bool convertLegacyRadioCombinationsMatrixToAidl(
            radio_configurations_vec.push_back(radioConfiguration);
        }
        radioCombination.radioConfigurations = radio_configurations_vec;
        radio_combinations_vec.push_back(radioCombination);
        aidl_combinations->push_back(radioCombination);
        l_radio_combinations_ptr =
                (wifi_radio_combination*)((u8*)l_radio_combinations_ptr +
                                          sizeof(wifi_radio_combination) +
                                          (sizeof(wifi_radio_configuration) * num_configurations));
    }
    aidl_matrix->radioCombinations = radio_combinations_vec;
    return true;
}

+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ bool convertAidlVectorOfCoexUnsafeChannelToLegacy(
        std::vector<legacy_hal::wifi_coex_unsafe_channel>* legacy_unsafe_channels);
bool convertLegacyRadioCombinationsMatrixToAidl(
        legacy_hal::wifi_radio_combination_matrix* legacy_matrix,
        WifiRadioCombinationMatrix* aidl_matrix);
        std::vector<WifiRadioCombination>* aidl_combinations);
WifiBand convertLegacyMacBandToAidlWifiBand(uint32_t band);
WifiAntennaMode convertLegacyAntennaConfigurationToAidl(uint32_t antenna_cfg);

+7 −6
Original line number Diff line number Diff line
@@ -753,21 +753,22 @@ TEST_F(AidlStructUtilTest, canConvertLegacyRadioCombinationsMatrixToAidl) {
            sizeof(radio_configurations_array3) / sizeof(radio_configurations_array3[0]),
            radio_configurations_array3);

    WifiRadioCombinationMatrix converted_matrix{};
    aidl_struct_util::convertLegacyRadioCombinationsMatrixToAidl(legacy_matrix, &converted_matrix);
    std::vector<WifiRadioCombination> converted_combinations;
    aidl_struct_util::convertLegacyRadioCombinationsMatrixToAidl(legacy_matrix,
                                                                 &converted_combinations);

    // Verify the conversion
    EXPECT_EQ(legacy_matrix->num_radio_combinations, converted_matrix.radioCombinations.size());
    EXPECT_EQ(legacy_matrix->num_radio_combinations, converted_combinations.size());
    verifyRadioCombination(
            &converted_matrix.radioCombinations[0],
            &converted_combinations[0],
            sizeof(radio_configurations_array1) / sizeof(radio_configurations_array1[0]),
            radio_configurations_array1);
    verifyRadioCombination(
            &converted_matrix.radioCombinations[1],
            &converted_combinations[1],
            sizeof(radio_configurations_array2) / sizeof(radio_configurations_array2[0]),
            radio_configurations_array2);
    verifyRadioCombination(
            &converted_matrix.radioCombinations[2],
            &converted_combinations[2],
            sizeof(radio_configurations_array3) / sizeof(radio_configurations_array3[0]),
            radio_configurations_array3);
}
+10 −10
Original line number Diff line number Diff line
@@ -682,10 +682,10 @@ ndk::ScopedAStatus WifiChip::triggerSubsystemRestart() {
                           &WifiChip::triggerSubsystemRestartInternal);
}

ndk::ScopedAStatus WifiChip::getSupportedRadioCombinationsMatrix(
        WifiRadioCombinationMatrix* _aidl_return) {
ndk::ScopedAStatus WifiChip::getSupportedRadioCombinations(
        std::vector<WifiRadioCombination>* _aidl_return) {
    return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
                           &WifiChip::getSupportedRadioCombinationsMatrixInternal, _aidl_return);
                           &WifiChip::getSupportedRadioCombinationsInternal, _aidl_return);
}

ndk::ScopedAStatus WifiChip::getWifiChipCapabilities(WifiChipCapabilities* _aidl_return) {
@@ -1411,26 +1411,26 @@ ndk::ScopedAStatus WifiChip::setAfcChannelAllowanceInternal(
    return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}

std::pair<WifiRadioCombinationMatrix, ndk::ScopedAStatus>
WifiChip::getSupportedRadioCombinationsMatrixInternal() {
std::pair<std::vector<WifiRadioCombination>, ndk::ScopedAStatus>
WifiChip::getSupportedRadioCombinationsInternal() {
    legacy_hal::wifi_error legacy_status;
    legacy_hal::wifi_radio_combination_matrix* legacy_matrix;
    std::vector<WifiRadioCombination> aidl_combinations;

    std::tie(legacy_status, legacy_matrix) =
            legacy_hal_.lock()->getSupportedRadioCombinationsMatrix();
    if (legacy_status != legacy_hal::WIFI_SUCCESS) {
        LOG(ERROR) << "Failed to get SupportedRadioCombinations matrix from legacy HAL: "
                   << legacyErrorToString(legacy_status);
        return {WifiRadioCombinationMatrix{}, createWifiStatusFromLegacyError(legacy_status)};
        return {aidl_combinations, createWifiStatusFromLegacyError(legacy_status)};
    }

    WifiRadioCombinationMatrix aidl_matrix;
    if (!aidl_struct_util::convertLegacyRadioCombinationsMatrixToAidl(legacy_matrix,
                                                                      &aidl_matrix)) {
                                                                      &aidl_combinations)) {
        LOG(ERROR) << "Failed convertLegacyRadioCombinationsMatrixToAidl() ";
        return {WifiRadioCombinationMatrix(), createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS)};
        return {aidl_combinations, createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS)};
    }
    return {aidl_matrix, ndk::ScopedAStatus::ok()};
    return {aidl_combinations, ndk::ScopedAStatus::ok()};
}

std::pair<WifiChipCapabilities, ndk::ScopedAStatus> WifiChip::getWifiChipCapabilitiesInternal() {
+4 −4
Original line number Diff line number Diff line
@@ -144,8 +144,8 @@ class WifiChip : public BnWifiChip {
    ndk::ScopedAStatus setAfcChannelAllowance(
            const std::vector<AvailableAfcFrequencyInfo>& availableAfcFrequencyInfo) override;
    ndk::ScopedAStatus triggerSubsystemRestart() override;
    ndk::ScopedAStatus getSupportedRadioCombinationsMatrix(
            WifiRadioCombinationMatrix* _aidl_return) override;
    ndk::ScopedAStatus getSupportedRadioCombinations(
            std::vector<WifiRadioCombination>* _aidl_return) override;
    ndk::ScopedAStatus getWifiChipCapabilities(WifiChipCapabilities* _aidl_return) override;
    ndk::ScopedAStatus enableStaChannelForPeerNetwork(
            ChannelCategoryMask in_channelCategoryEnableFlag) override;
@@ -258,8 +258,8 @@ class WifiChip : public BnWifiChip {
    void invalidateAndClearBridgedAp(const std::string& br_name);
    bool findUsingNameFromBridgedApInstances(const std::string& name);
    ndk::ScopedAStatus triggerSubsystemRestartInternal();
    std::pair<WifiRadioCombinationMatrix, ndk::ScopedAStatus>
    getSupportedRadioCombinationsMatrixInternal();
    std::pair<std::vector<WifiRadioCombination>, ndk::ScopedAStatus>
    getSupportedRadioCombinationsInternal();
    std::pair<WifiChipCapabilities, ndk::ScopedAStatus> getWifiChipCapabilitiesInternal();
    ndk::ScopedAStatus setMloModeInternal(const ChipMloMode in_mode);
    void setWeakPtr(std::weak_ptr<WifiChip> ptr);