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

Commit 9e7a4057 authored by Etan Cohen's avatar Etan Cohen
Browse files

[AWARE] Add power confriguration parameters to HAL 1.2

Add configuration parameters (power optimization) to NAN HAL 1.2.

Bug: 67745737
Test: integration tests
Change-Id: I65524c05c6861d7b54e441572b3be918bc6bb5ab
parent ad22189d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -7,14 +7,19 @@ hidl_interface {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IWifi.hal",
        "IWifiChip.hal",
        "IWifiNanIface.hal",
    ],
    interfaces: [
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.1",
        "android.hidl.base@1.0",
    ],
    types: [
        "NanConfigRequestSupplemental",
    ],
    gen_java: true,
}
+77 −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::CommandIdShort;
import @1.0::IWifiNanIface;
import @1.0::NanConfigRequest;
import @1.0::NanEnableRequest;
import @1.0::WifiStatus;

/**
 * Interface used to represent a single NAN (Neighbour Aware Network) iface.
 *
 * References to "NAN Spec" are to the Wi-Fi Alliance "Wi-Fi Neighbor Awareness
 * Networking (NAN) Technical Specification".
 */
interface IWifiNanIface extends @1.0::IWifiNanIface {
    /**
     * Enable NAN: configures and activates NAN clustering (does not start
     * a discovery session or set up data-interfaces or data-paths). Use the
     * |IWifiNanIface.configureRequest| method to change the configuration of an already enabled
     * NAN interface.
     * Asynchronous response is with |IWifiNanIfaceEventCallback.notifyEnableResponse|.
     *
     * Note: supersedes the @1.0::IWifiNanIface.enableRequest() method which is deprecated as of
     * HAL version 1.2.
     *
     * @param cmdId command Id to use for this invocation.
     * @param msg1 Instance of |NanEnableRequest|.
     * @param msg2 Instance of |NanConfigRequestSupplemental|.
     * @return status WifiStatus of the operation.
     *         Possible status codes:
     *         |WifiStatusCode.SUCCESS|,
     *         |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
     *         |WifiStatusCode.ERROR_INVALID_ARGS|,
     *         |WifiStatusCode.ERROR_UNKNOWN|
     */
    enableRequest_1_2(CommandIdShort cmdId, NanEnableRequest msg1,
                      NanConfigRequestSupplemental msg2)
        generates (WifiStatus status);

    /**
     * Configure NAN: configures an existing NAN functionality (i.e. assumes
     * |IWifiNanIface.enableRequest| already submitted and succeeded).
     * Asynchronous response is with |IWifiNanIfaceEventCallback.notifyConfigResponse|.
     *
     * Note: supersedes the @1.0::IWifiNanIface.configRequest() method which is deprecated as of
     * HAL version 1.2.
     *
     * @param cmdId command Id to use for this invocation.
     * @param msg1 Instance of |NanConfigRequest|.
     * @param msg1 Instance of |NanConfigRequestSupplemental|.
     * @return status WifiStatus of the operation.
     *         Possible status codes:
     *         |WifiStatusCode.SUCCESS|,
     *         |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
     *         |WifiStatusCode.ERROR_INVALID_ARGS|,
     *         |WifiStatusCode.ERROR_UNKNOWN|
     */
    configRequest_1_2(CommandIdShort cmdId, NanConfigRequest msg1,
                      NanConfigRequestSupplemental msg2)
        generates (WifiStatus status);
};
+54 −0
Original line number Diff line number Diff line
@@ -1118,6 +1118,33 @@ bool convertHidlNanEnableRequestToLegacy(
    return true;
}

bool convertHidlNanEnableRequest_1_2ToLegacy(
    const NanEnableRequest& hidl_request1,
    const NanConfigRequestSupplemental& hidl_request2,
    legacy_hal::NanEnableRequest* legacy_request) {
    if (!legacy_request) {
        LOG(ERROR)
            << "convertHidlNanEnableRequest_1_2ToLegacy: null legacy_request";
        return false;
    }

    *legacy_request = {};
    if (!convertHidlNanEnableRequestToLegacy(hidl_request1, legacy_request)) {
        return false;
    }

    legacy_request->config_discovery_beacon_int = 1;
    legacy_request->discovery_beacon_interval =
        hidl_request2.discoveryBeaconIntervalMs;
    legacy_request->config_nss = 1;
    legacy_request->nss = hidl_request2.numberOfSpatialStreamsInDiscovery;
    legacy_request->config_dw_early_termination = 1;
    legacy_request->enable_dw_termination =
        hidl_request2.enableDiscoveryWindowEarlyTermination;

    return true;
}

bool convertHidlNanPublishRequestToLegacy(
    const NanPublishRequest& hidl_request,
    legacy_hal::NanPublishRequest* legacy_request) {
@@ -1600,6 +1627,33 @@ bool convertHidlNanConfigRequestToLegacy(
    return true;
}

bool convertHidlNanConfigRequest_1_2ToLegacy(
    const NanConfigRequest& hidl_request1,
    const NanConfigRequestSupplemental& hidl_request2,
    legacy_hal::NanConfigRequest* legacy_request) {
    if (!legacy_request) {
        LOG(ERROR) << "convertHidlNanConfigRequest_1_2ToLegacy: legacy_request "
                      "is null";
        return false;
    }

    *legacy_request = {};
    if (!convertHidlNanConfigRequestToLegacy(hidl_request1, legacy_request)) {
        return false;
    }

    legacy_request->config_discovery_beacon_int = 1;
    legacy_request->discovery_beacon_interval =
        hidl_request2.discoveryBeaconIntervalMs;
    legacy_request->config_nss = 1;
    legacy_request->nss = hidl_request2.numberOfSpatialStreamsInDiscovery;
    legacy_request->config_dw_early_termination = 1;
    legacy_request->enable_dw_termination =
        hidl_request2.enableDiscoveryWindowEarlyTermination;

    return true;
}

bool convertHidlNanDataPathInitiatorRequestToLegacy(
    const NanInitiateDataPathRequest& hidl_request,
    legacy_hal::NanDataPathInitiatorRequest* legacy_request) {
+9 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <android/hardware/wifi/1.0/IWifiChip.h>
#include <android/hardware/wifi/1.0/types.h>
#include <android/hardware/wifi/1.1/IWifiChip.h>
#include <android/hardware/wifi/1.2/types.h>

#include "wifi_legacy_hal.h"

@@ -106,6 +107,14 @@ bool convertHidlNanEnableRequestToLegacy(
bool convertHidlNanConfigRequestToLegacy(
    const NanConfigRequest& hidl_request,
    legacy_hal::NanConfigRequest* legacy_request);
bool convertHidlNanEnableRequest_1_2ToLegacy(
    const NanEnableRequest& hidl_request1,
    const NanConfigRequestSupplemental& hidl_request2,
    legacy_hal::NanEnableRequest* legacy_request);
bool convertHidlNanConfigRequest_1_2ToLegacy(
    const NanConfigRequest& hidl_request1,
    const NanConfigRequestSupplemental& hidl_request2,
    legacy_hal::NanConfigRequest* legacy_request);
bool convertHidlNanPublishRequestToLegacy(
    const NanPublishRequest& hidl_request,
    legacy_hal::NanPublishRequest* legacy_request);
+4 −2
Original line number Diff line number Diff line
@@ -117,8 +117,10 @@ class WifiChipTest : public Test {
            });
        } else if (type == IfaceType::NAN) {
            chip_->createNanIface(
                [&iface_name](const WifiStatus& status,
                              const sp<IWifiNanIface>& iface) {
                [&iface_name](
                    const WifiStatus& status,
                    const sp<android::hardware::wifi::V1_0::IWifiNanIface>&
                        iface) {
                    if (WifiStatusCode::SUCCESS == status.code) {
                        ASSERT_NE(iface.get(), nullptr);
                        iface->getName([&iface_name](const WifiStatus& status,
Loading