Wifi: Add 6GHz band to NAN structures and methods

This commit adds 6GHz band to NAN related structures and methods.

Bug: 139354972
Test: Manual
Test: VTS test
Test: Unit test:
Test: ./hardware/interfaces/wifi/1.4/default/tests/runtests.sh
Change-Id: I33f63fde67d5a839678076fdb7c76d5eb8645131
This commit is contained in:
Ahmed ElArabawy 2019-11-15 19:20:41 -08:00
parent b5affd2612
commit 83baffdac2
11 changed files with 886 additions and 33 deletions

View file

@ -12,6 +12,7 @@ hidl_interface {
"IWifiApIface.hal",
"IWifiChip.hal",
"IWifiChipEventCallback.hal",
"IWifiNanIface.hal",
"IWifiRttController.hal",
"IWifiRttControllerEventCallback.hal",
"IWifiStaIface.hal",

View file

@ -0,0 +1,80 @@
/*
* Copyright 2019 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.4;
import @1.0::CommandIdShort;
import @1.0::WifiStatus;
import @1.2::IWifiNanIface;
import @1.2::NanConfigRequestSupplemental;
import NanConfigRequest;
import NanEnableRequest;
/**
* 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.2::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.2::IWifiNanIface.enableRequest() method which is deprecated as of
* HAL version 1.4.
*
* @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_NOT_SUPPORTED|,
* |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
* |WifiStatusCode.ERROR_INVALID_ARGS|,
* |WifiStatusCode.ERROR_UNKNOWN|
*/
enableRequest_1_4(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.2::IWifiNanIface.configRequest() method which is deprecated as of
* HAL version 1.4.
*
* @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_NOT_SUPPORTED|,
* |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
* |WifiStatusCode.ERROR_INVALID_ARGS|,
* |WifiStatusCode.ERROR_UNKNOWN|
*/
configRequest_1_4(CommandIdShort cmdId, NanConfigRequest msg1,
NanConfigRequestSupplemental msg2)
generates (WifiStatus status);
};

View file

@ -1270,16 +1270,20 @@ bool convertHidlNanEnableRequestToLegacy(
hidl_request.debugConfigs
.useSdfInBandVal[(size_t)NanBandIndex::NAN_BAND_5GHZ];
/* TODO: b/145609058
* Missing updates needed to legacy_hal::NanEnableRequest and conversion to
* it for 6GHz band */
return true;
}
bool convertHidlNanEnableRequest_1_2ToLegacy(
bool convertHidlNanEnableRequest_1_4ToLegacy(
const NanEnableRequest& hidl_request1,
const V1_2::NanConfigRequestSupplemental& hidl_request2,
legacy_hal::NanEnableRequest* legacy_request) {
if (!legacy_request) {
LOG(ERROR)
<< "convertHidlNanEnableRequest_1_2ToLegacy: null legacy_request";
<< "convertHidlNanEnableRequest_1_4ToLegacy: null legacy_request";
return false;
}
@ -1780,16 +1784,19 @@ bool convertHidlNanConfigRequestToLegacy(
legacy_request->config_dw.dw_5g_interval_val =
hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
.discoveryWindowIntervalVal;
/* TODO: b/145609058
* Missing updates needed to legacy_hal::NanConfigRequest and conversion to
* it for 6GHz band */
return true;
}
bool convertHidlNanConfigRequest_1_2ToLegacy(
bool convertHidlNanConfigRequest_1_4ToLegacy(
const NanConfigRequest& hidl_request1,
const V1_2::NanConfigRequestSupplemental& hidl_request2,
legacy_hal::NanConfigRequest* legacy_request) {
if (!legacy_request) {
LOG(ERROR) << "convertHidlNanConfigRequest_1_2ToLegacy: legacy_request "
LOG(ERROR) << "convertHidlNanConfigRequest_1_4ToLegacy: legacy_request "
"is null";
return false;
}

View file

@ -118,11 +118,11 @@ bool convertHidlNanEnableRequestToLegacy(
bool convertHidlNanConfigRequestToLegacy(
const NanConfigRequest& hidl_request,
legacy_hal::NanConfigRequest* legacy_request);
bool convertHidlNanEnableRequest_1_2ToLegacy(
bool convertHidlNanEnableRequest_1_4ToLegacy(
const NanEnableRequest& hidl_request1,
const V1_2::NanConfigRequestSupplemental& hidl_request2,
legacy_hal::NanEnableRequest* legacy_request);
bool convertHidlNanConfigRequest_1_2ToLegacy(
bool convertHidlNanConfigRequest_1_4ToLegacy(
const NanConfigRequest& hidl_request1,
const V1_2::NanConfigRequestSupplemental& hidl_request2,
legacy_hal::NanConfigRequest* legacy_request);

View file

@ -720,13 +720,16 @@ TEST_F(WifiChipV2_AwareIfaceCombinationTest,
ASSERT_EQ(iface_names[0], "wlan0");
});
// Retrieve the exact iface object.
sp<IWifiNanIface> nan_iface;
chip_->getNanIface("wlan0", [&nan_iface](const WifiStatus& status,
const sp<IWifiNanIface>& iface) {
ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
ASSERT_NE(iface.get(), nullptr);
nan_iface = iface;
});
sp<android::hardware::wifi::V1_0::IWifiNanIface> nan_iface;
chip_->getNanIface(
"wlan0",
[&nan_iface](
const WifiStatus& status,
const sp<android::hardware::wifi::V1_0::IWifiNanIface>& iface) {
ASSERT_EQ(WifiStatusCode::SUCCESS, status.code);
ASSERT_NE(iface.get(), nullptr);
nan_iface = iface;
});
// Remove the STA iface.
removeIface(IfaceType::STA, "wlan0");

View file

@ -41,6 +41,9 @@ namespace wifi {
namespace V1_4 {
namespace implementation {
using android::hardware::wifi::V1_2::IWifiNanIfaceEventCallback;
using android::hardware::wifi::V1_2::NanDataPathConfirmInd;
bool CaptureIfaceEventHandlers(
const std::string& /* iface_name*/,
iface_util::IfaceEventHandlers in_iface_event_handlers,
@ -96,9 +99,15 @@ class MockNanIfaceEventCallback : public IWifiNanIfaceEventCallback {
Return<void>(uint16_t, const WifiNanStatus&));
MOCK_METHOD1(eventDataPathRequest,
Return<void>(const NanDataPathRequestInd&));
MOCK_METHOD1(eventDataPathConfirm,
Return<void>(const NanDataPathConfirmInd&));
MOCK_METHOD1(
eventDataPathConfirm,
Return<void>(
const android::hardware::wifi::V1_0::NanDataPathConfirmInd&));
MOCK_METHOD1(eventDataPathTerminated, Return<void>(uint32_t));
MOCK_METHOD1(eventDataPathConfirm_1_2,
Return<void>(const NanDataPathConfirmInd&));
MOCK_METHOD1(eventDataPathScheduleUpdate,
Return<void>(const NanDataPathScheduleUpdateInd&));
};
class WifiNanIfaceTest : public Test {

View file

@ -576,7 +576,7 @@ Return<void> WifiNanIface::getCapabilitiesRequest(
}
Return<void> WifiNanIface::enableRequest(uint16_t cmd_id,
const NanEnableRequest& msg,
const V1_0::NanEnableRequest& msg,
enableRequest_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiNanIface::enableRequestInternal, hidl_status_cb,
@ -584,7 +584,7 @@ Return<void> WifiNanIface::enableRequest(uint16_t cmd_id,
}
Return<void> WifiNanIface::configRequest(uint16_t cmd_id,
const NanConfigRequest& msg,
const V1_0::NanConfigRequest& msg,
configRequest_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiNanIface::configRequestInternal, hidl_status_cb,
@ -687,7 +687,7 @@ Return<void> WifiNanIface::registerEventCallback_1_2(
}
Return<void> WifiNanIface::enableRequest_1_2(
uint16_t cmd_id, const NanEnableRequest& msg1,
uint16_t cmd_id, const V1_0::NanEnableRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
enableRequest_1_2_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
@ -696,7 +696,7 @@ Return<void> WifiNanIface::enableRequest_1_2(
}
Return<void> WifiNanIface::configRequest_1_2(
uint16_t cmd_id, const NanConfigRequest& msg1,
uint16_t cmd_id, const V1_0::NanConfigRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
configRequest_1_2_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
@ -704,6 +704,24 @@ Return<void> WifiNanIface::configRequest_1_2(
hidl_status_cb, cmd_id, msg1, msg2);
}
Return<void> WifiNanIface::enableRequest_1_4(
uint16_t cmd_id, const NanEnableRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
enableRequest_1_4_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiNanIface::enableRequest_1_4Internal,
hidl_status_cb, cmd_id, msg1, msg2);
}
Return<void> WifiNanIface::configRequest_1_4(
uint16_t cmd_id, const NanConfigRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
configRequest_1_4_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiNanIface::configRequest_1_4Internal,
hidl_status_cb, cmd_id, msg1, msg2);
}
std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() {
return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
@ -727,12 +745,12 @@ WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t cmd_id) {
}
WifiStatus WifiNanIface::enableRequestInternal(
uint16_t /* cmd_id */, const NanEnableRequest& /* msg */) {
uint16_t /* cmd_id */, const V1_0::NanEnableRequest& /* msg */) {
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
WifiStatus WifiNanIface::configRequestInternal(
uint16_t /* cmd_id */, const NanConfigRequest& /* msg */) {
uint16_t /* cmd_id */, const V1_0::NanConfigRequest& /* msg */) {
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
@ -855,10 +873,22 @@ WifiStatus WifiNanIface::registerEventCallback_1_2Internal(
}
WifiStatus WifiNanIface::enableRequest_1_2Internal(
uint16_t /* cmd_id */, const V1_0::NanEnableRequest& /* msg1 */,
const V1_2::NanConfigRequestSupplemental& /*msg2 */) {
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
WifiStatus WifiNanIface::configRequest_1_2Internal(
uint16_t /* cmd_id */, const V1_0::NanConfigRequest& /* msg1 */,
const V1_2::NanConfigRequestSupplemental& /* msg2 */) {
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
WifiStatus WifiNanIface::enableRequest_1_4Internal(
uint16_t cmd_id, const NanEnableRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2) {
legacy_hal::NanEnableRequest legacy_msg;
if (!hidl_struct_util::convertHidlNanEnableRequest_1_2ToLegacy(
if (!hidl_struct_util::convertHidlNanEnableRequest_1_4ToLegacy(
msg1, msg2, &legacy_msg)) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
@ -867,11 +897,11 @@ WifiStatus WifiNanIface::enableRequest_1_2Internal(
return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::configRequest_1_2Internal(
WifiStatus WifiNanIface::configRequest_1_4Internal(
uint16_t cmd_id, const NanConfigRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2) {
legacy_hal::NanConfigRequest legacy_msg;
if (!hidl_struct_util::convertHidlNanConfigRequest_1_2ToLegacy(
if (!hidl_struct_util::convertHidlNanConfigRequest_1_4ToLegacy(
msg1, msg2, &legacy_msg)) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}

View file

@ -19,7 +19,7 @@
#include <android-base/macros.h>
#include <android/hardware/wifi/1.0/IWifiNanIfaceEventCallback.h>
#include <android/hardware/wifi/1.2/IWifiNanIface.h>
#include <android/hardware/wifi/1.4/IWifiNanIface.h>
#include "hidl_callback_util.h"
#include "wifi_iface_util.h"
@ -31,11 +31,12 @@ namespace wifi {
namespace V1_4 {
namespace implementation {
using namespace android::hardware::wifi::V1_0;
using namespace android::hardware::wifi::V1_2;
/**
* HIDL interface object used to control a NAN Iface instance.
*/
class WifiNanIface : public V1_2::IWifiNanIface {
class WifiNanIface : public V1_4::IWifiNanIface {
public:
WifiNanIface(const std::string& ifname,
const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
@ -53,9 +54,11 @@ class WifiNanIface : public V1_2::IWifiNanIface {
registerEventCallback_cb hidl_status_cb) override;
Return<void> getCapabilitiesRequest(
uint16_t cmd_id, getCapabilitiesRequest_cb hidl_status_cb) override;
Return<void> enableRequest(uint16_t cmd_id, const NanEnableRequest& msg,
Return<void> enableRequest(uint16_t cmd_id,
const V1_0::NanEnableRequest& msg,
enableRequest_cb hidl_status_cb) override;
Return<void> configRequest(uint16_t cmd_id, const NanConfigRequest& msg,
Return<void> configRequest(uint16_t cmd_id,
const V1_0::NanConfigRequest& msg,
configRequest_cb hidl_status_cb) override;
Return<void> disableRequest(uint16_t cmd_id,
disableRequest_cb hidl_status_cb) override;
@ -94,10 +97,18 @@ class WifiNanIface : public V1_2::IWifiNanIface {
const sp<V1_2::IWifiNanIfaceEventCallback>& callback,
registerEventCallback_1_2_cb hidl_status_cb) override;
Return<void> enableRequest_1_2(
uint16_t cmd_id, const NanEnableRequest& msg1,
uint16_t cmd_id, const V1_0::NanEnableRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
enableRequest_1_2_cb hidl_status_cb) override;
Return<void> configRequest_1_2(
uint16_t cmd_id, const V1_0::NanConfigRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
configRequest_1_2_cb hidl_status_cb) override;
Return<void> enableRequest_1_4(
uint16_t cmd_id, const NanEnableRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
enableRequest_1_2_cb hidl_status_cb) override;
Return<void> configRequest_1_4(
uint16_t cmd_id, const NanConfigRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2,
configRequest_1_2_cb hidl_status_cb) override;
@ -110,9 +121,9 @@ class WifiNanIface : public V1_2::IWifiNanIface {
const sp<V1_0::IWifiNanIfaceEventCallback>& callback);
WifiStatus getCapabilitiesRequestInternal(uint16_t cmd_id);
WifiStatus enableRequestInternal(uint16_t cmd_id,
const NanEnableRequest& msg);
const V1_0::NanEnableRequest& msg);
WifiStatus configRequestInternal(uint16_t cmd_id,
const NanConfigRequest& msg);
const V1_0::NanConfigRequest& msg);
WifiStatus disableRequestInternal(uint16_t cmd_id);
WifiStatus startPublishRequestInternal(uint16_t cmd_id,
const NanPublishRequest& msg);
@ -136,9 +147,15 @@ class WifiNanIface : public V1_2::IWifiNanIface {
WifiStatus registerEventCallback_1_2Internal(
const sp<V1_2::IWifiNanIfaceEventCallback>& callback);
WifiStatus enableRequest_1_2Internal(
uint16_t cmd_id, const NanEnableRequest& msg1,
uint16_t cmd_id, const V1_0::NanEnableRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2);
WifiStatus configRequest_1_2Internal(
uint16_t cmd_id, const V1_0::NanConfigRequest& msg,
const V1_2::NanConfigRequestSupplemental& msg2);
WifiStatus enableRequest_1_4Internal(
uint16_t cmd_id, const NanEnableRequest& msg1,
const V1_2::NanConfigRequestSupplemental& msg2);
WifiStatus configRequest_1_4Internal(
uint16_t cmd_id, const NanConfigRequest& msg,
const V1_2::NanConfigRequestSupplemental& msg2);

View file

@ -17,6 +17,8 @@
package android.hardware.wifi@1.4;
import @1.0::MacAddress;
import @1.0::NanBandIndex;
import @1.0::NanBandSpecificConfig;
import @1.0::Rssi;
import @1.0::RttBw;
import @1.0::RttConfig;
@ -28,6 +30,7 @@ import @1.0::TimeSpanInPs;
import @1.0::TimeStampInUs;
import @1.0::WifiBand;
import @1.0::WifiChannelInfo;
import @1.0::WifiChannelInMhz;
import @1.0::WifiChannelWidthInMhz;
import @1.0::WifiInformationElement;
import @1.0::WifiRateNss;
@ -55,6 +58,16 @@ enum WifiBand : @1.0::WifiBand {
BAND_24GHZ_5GHZ_WITH_DFS_6GHZ = 15
};
/**
* The discovery bands supported by NAN.
*/
enum NanBandIndex : @1.0::NanBandIndex {
/**
* Index for 6 GHz band.
*/
NAN_BAND_6GHZ = 2,
};
/**
* Wifi Rate Preamble
*/
@ -75,6 +88,154 @@ enum RttPreamble : @1.0::RttPreamble {
HE = 0x8,
};
/**
* Debug configuration parameters. Many of these allow non-standard-compliant operation and are
* not intended for normal operational mode.
*/
struct NanDebugConfig {
/**
* Specification of the lower 2 bytes of the cluster ID. The cluster ID is 50-60-9a-01-00-00 to
* 50-60-9a-01-FF-FF. Configuration of the bottom and top values of the range (which defaults to
* 0x0000 and 0xFFFF respectively).
* Configuration is only used if |validClusterIdVals| is set to true.
*/
bool validClusterIdVals;
uint16_t clusterIdBottomRangeVal;
uint16_t clusterIdTopRangeVal;
/**
* NAN management interface address, if specified (|validIntfAddrVal| is true) then overrides any
* other configuration (specifically the default randomization configured by
* |NanConfigRequest.macAddressRandomizationIntervalSec|).
*/
bool validIntfAddrVal;
MacAddress intfAddrVal;
/**
* Combination of the 24 bit Organizationally Unique ID (OUI) and the 8 bit OUI Type.
* Used if |validOuiVal| is set to true.
*/
bool validOuiVal;
uint32_t ouiVal;
/**
* Force the Random Factor to the specified value for all transmitted Sync/Discovery beacons.
* Used if |validRandomFactorForceVal| is set to true.
* NAN Spec: Master Indication Attribute / Random Factor
*/
bool validRandomFactorForceVal;
uint8_t randomFactorForceVal;
/**
* Forces the hop-count for all transmitted Sync and Discovery Beacons NO matter the real
* hop-count being received over the air. Used if the |validHopCountForceVal}| flag is set to
* true.
* NAN Spec: Cluster Attribute / Anchor Master Information / Hop Count to Anchor Master
*/
bool validHopCountForceVal;
uint8_t hopCountForceVal;
/**
* Frequency in MHz to of the discovery channel in the specified band. Indexed by |NanBandIndex|.
* Used if the |validDiscoveryChannelVal| is set to true.
*/
bool validDiscoveryChannelVal;
WifiChannelInMhz[3] discoveryChannelMhzVal;
/**
* Specifies whether sync/discovery beacons are transmitted in the specified band. Indexed by
* |NanBandIndex|. Used if the |validUseBeaconsInBandVal| is set to true.
*/
bool validUseBeaconsInBandVal;
bool[3] useBeaconsInBandVal;
/**
* Specifies whether SDF (service discovery frames) are transmitted in the specified band. Indexed
* by |NanBandIndex|. Used if the |validUseSdfInBandVal| is set to true.
*/
bool validUseSdfInBandVal;
bool[3] useSdfInBandVal;
};
/**
* Configuration parameters of NAN: used when enabling and re-configuring a NAN cluster.
*/
struct NanConfigRequest {
/**
* Master preference of this device.
* NAN Spec: Master Indication Attribute / Master Preference
*/
uint8_t masterPref;
/**
* Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
* for |NanClusterEventType.DISCOVERY_MAC_ADDRESS_CHANGED|.
*/
bool disableDiscoveryAddressChangeIndication;
/**
* Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
* for |NanClusterEventType.STARTED_CLUSTER|.
*/
bool disableStartedClusterIndication;
/**
* Controls whether or not the |IWifiNanIfaceEventCallback.eventClusterEvent| will be delivered
* for |NanClusterEventType.JOINED_CLUSTER|.
*/
bool disableJoinedClusterIndication;
/**
* Control whether publish service IDs are included in Sync/Discovery beacons.
* NAN Spec: Service ID List Attribute
*/
bool includePublishServiceIdsInBeacon;
/**
* If |includePublishServiceIdsInBeacon| is true then specifies the number of publish service IDs
* to include in the Sync/Discovery beacons:
* Value = 0: include as many service IDs as will fit into the maximum allowed beacon frame size.
* Value must fit within 7 bits - i.e. <= 127.
*/
uint8_t numberOfPublishServiceIdsInBeacon;
/**
* Control whether subscribe service IDs are included in Sync/Discovery beacons.
* Spec: Subscribe Service ID List Attribute
*/
bool includeSubscribeServiceIdsInBeacon;
/**
* If |includeSubscribeServiceIdsInBeacon| is true then specifies the number of subscribe service
* IDs to include in the Sync/Discovery beacons:
* Value = 0: include as many service IDs as will fit into the maximum allowed beacon frame size.
* Value must fit within 7 bits - i.e. <= 127.
*/
uint8_t numberOfSubscribeServiceIdsInBeacon;
/**
* Number of samples used to calculate RSSI.
*/
uint16_t rssiWindowSize;
/**
* Specifies the interval in seconds that the NAN management interface MAC address is randomized.
* A value of 0 is used to disable the MAC address randomization
*/
uint32_t macAddressRandomizationIntervalSec;
/**
* Additional configuration provided per band: indexed by |NanBandIndex|.
*/
NanBandSpecificConfig[3] bandSpecificConfig;
};
/**
* Enable requests for NAN: start-up configuration |IWifiNanIface.enableRequest|.
*/
struct NanEnableRequest {
/**
* Enable operation in a specific band: indexed by |NanBandIndex|.
*/
bool[3] operateInBand;
/**
* Specify extent of cluster by specifying the max hop count.
*/
uint8_t hopCountMax;
/**
* Configurations of NAN cluster operation. Can also be modified at run-time using
* |IWifiNanIface.configRequest|.
*/
NanConfigRequest configParams;
/**
* Non-standard configurations of NAN cluster operation - useful for debugging operations.
*/
NanDebugConfig debugConfigs;
};
/**
* RTT configuration.
*/

View file

@ -21,7 +21,8 @@ cc_test {
srcs: [
"VtsHalWifiV1_4TargetTest.cpp",
"wifi_ap_iface_hidl_test.cpp",
"wifi_chip_hidl_test.cpp"
"wifi_chip_hidl_test.cpp",
"wifi_nan_iface_hidl_test.cpp"
],
static_libs: [
"VtsHalWifiV1_0TargetTestUtil",

View file

@ -0,0 +1,544 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Nanache 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.
*/
#include <android-base/logging.h>
#include <android/hardware/wifi/1.2/IWifiNanIfaceEventCallback.h>
#include <android/hardware/wifi/1.4/IWifi.h>
#include <android/hardware/wifi/1.4/IWifiNanIface.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
using namespace ::android::hardware::wifi::V1_0;
using namespace ::android::hardware::wifi::V1_2;
using namespace ::android::hardware::wifi::V1_4;
using ::android::sp;
using ::android::hardware::Return;
using ::android::hardware::Void;
#define TIMEOUT_PERIOD 10
android::sp<android::hardware::wifi::V1_4::IWifiNanIface> getWifiNanIface_1_4(
const std::string& instance_name) {
return android::hardware::wifi::V1_4::IWifiNanIface::castFrom(
getWifiNanIface(instance_name));
}
/**
* Fixture to use for all NAN Iface HIDL interface tests.
*/
class WifiNanIfaceHidlTest : public ::testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
iwifiNanIface = getWifiNanIface_1_4(GetInstanceName());
ASSERT_NE(nullptr, iwifiNanIface.get());
ASSERT_EQ(WifiStatusCode::SUCCESS,
HIDL_INVOKE(iwifiNanIface, registerEventCallback_1_2,
new WifiNanIfaceEventCallback(*this))
.code);
}
virtual void TearDown() override { stopWifi(GetInstanceName()); }
/* Used as a mechanism to inform the test about data/event callback */
inline void notify() {
std::unique_lock<std::mutex> lock(mtx_);
count_++;
cv_.notify_one();
}
enum CallbackType {
INVALID = -2,
ANY_CALLBACK = -1,
NOTIFY_CAPABILITIES_RESPONSE = 0,
NOTIFY_ENABLE_RESPONSE,
NOTIFY_CONFIG_RESPONSE,
NOTIFY_DISABLE_RESPONSE,
NOTIFY_START_PUBLISH_RESPONSE,
NOTIFY_STOP_PUBLISH_RESPONSE,
NOTIFY_START_SUBSCRIBE_RESPONSE,
NOTIFY_STOP_SUBSCRIBE_RESPONSE,
NOTIFY_TRANSMIT_FOLLOWUP_RESPONSE,
NOTIFY_CREATE_DATA_INTERFACE_RESPONSE,
NOTIFY_DELETE_DATA_INTERFACE_RESPONSE,
NOTIFY_INITIATE_DATA_PATH_RESPONSE,
NOTIFY_RESPOND_TO_DATA_PATH_INDICATION_RESPONSE,
NOTIFY_TERMINATE_DATA_PATH_RESPONSE,
EVENT_CLUSTER_EVENT,
EVENT_DISABLED,
EVENT_PUBLISH_TERMINATED,
EVENT_SUBSCRIBE_TERMINATED,
EVENT_MATCH,
EVENT_MATCH_EXPIRED,
EVENT_FOLLOWUP_RECEIVED,
EVENT_TRANSMIT_FOLLOWUP,
EVENT_DATA_PATH_REQUEST,
EVENT_DATA_PATH_CONFIRM,
EVENT_DATA_PATH_TERMINATED,
EVENT_DATA_PATH_CONFIRM_1_2,
EVENT_DATA_PATH_SCHEDULE_UPDATE
};
/* Test code calls this function to wait for data/event callback */
/* Must set callbackType = INVALID before call this function */
inline std::cv_status wait(CallbackType waitForCallbackType) {
std::unique_lock<std::mutex> lock(mtx_);
EXPECT_NE(INVALID, waitForCallbackType); // can't ASSERT in a
// non-void-returning method
std::cv_status status = std::cv_status::no_timeout;
auto now = std::chrono::system_clock::now();
while (count_ == 0) {
status = cv_.wait_until(lock,
now + std::chrono::seconds(TIMEOUT_PERIOD));
if (status == std::cv_status::timeout) return status;
if (waitForCallbackType != ANY_CALLBACK &&
callbackType != INVALID &&
callbackType != waitForCallbackType) {
count_--;
}
}
count_--;
return status;
}
class WifiNanIfaceEventCallback
: public ::android::hardware::wifi::V1_2::IWifiNanIfaceEventCallback {
WifiNanIfaceHidlTest& parent_;
public:
WifiNanIfaceEventCallback(WifiNanIfaceHidlTest& parent)
: parent_(parent){};
virtual ~WifiNanIfaceEventCallback() = default;
Return<void> notifyCapabilitiesResponse(
uint16_t id, const WifiNanStatus& status,
const NanCapabilities& capabilities) override {
parent_.callbackType = NOTIFY_CAPABILITIES_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.capabilities = capabilities;
parent_.notify();
return Void();
}
Return<void> notifyEnableResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_ENABLE_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyConfigResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_CONFIG_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyDisableResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_DISABLE_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyStartPublishResponse(uint16_t id,
const WifiNanStatus& status,
uint8_t sessionId) override {
parent_.callbackType = NOTIFY_START_PUBLISH_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.sessionId = sessionId;
parent_.notify();
return Void();
}
Return<void> notifyStopPublishResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_STOP_PUBLISH_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyStartSubscribeResponse(uint16_t id,
const WifiNanStatus& status,
uint8_t sessionId) override {
parent_.callbackType = NOTIFY_START_SUBSCRIBE_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.sessionId = sessionId;
parent_.notify();
return Void();
}
Return<void> notifyStopSubscribeResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_STOP_SUBSCRIBE_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyTransmitFollowupResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_TRANSMIT_FOLLOWUP_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyCreateDataInterfaceResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_CREATE_DATA_INTERFACE_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyDeleteDataInterfaceResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_DELETE_DATA_INTERFACE_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyInitiateDataPathResponse(
uint16_t id, const WifiNanStatus& status,
uint32_t ndpInstanceId) override {
parent_.callbackType = NOTIFY_INITIATE_DATA_PATH_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.ndpInstanceId = ndpInstanceId;
parent_.notify();
return Void();
}
Return<void> notifyRespondToDataPathIndicationResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType =
NOTIFY_RESPOND_TO_DATA_PATH_INDICATION_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> notifyTerminateDataPathResponse(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = NOTIFY_TERMINATE_DATA_PATH_RESPONSE;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> eventClusterEvent(
const NanClusterEventInd& event) override {
parent_.callbackType = EVENT_CLUSTER_EVENT;
parent_.nanClusterEventInd = event;
parent_.notify();
return Void();
}
Return<void> eventDisabled(const WifiNanStatus& status) override {
parent_.callbackType = EVENT_DISABLED;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> eventPublishTerminated(
uint8_t sessionId, const WifiNanStatus& status) override {
parent_.callbackType = EVENT_PUBLISH_TERMINATED;
parent_.sessionId = sessionId;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> eventSubscribeTerminated(
uint8_t sessionId, const WifiNanStatus& status) override {
parent_.callbackType = EVENT_SUBSCRIBE_TERMINATED;
parent_.sessionId = sessionId;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> eventMatch(const NanMatchInd& event) override {
parent_.callbackType = EVENT_MATCH;
parent_.nanMatchInd = event;
parent_.notify();
return Void();
}
Return<void> eventMatchExpired(uint8_t discoverySessionId,
uint32_t peerId) override {
parent_.callbackType = EVENT_MATCH_EXPIRED;
parent_.sessionId = discoverySessionId;
parent_.peerId = peerId;
parent_.notify();
return Void();
}
Return<void> eventFollowupReceived(
const NanFollowupReceivedInd& event) override {
parent_.callbackType = EVENT_FOLLOWUP_RECEIVED;
parent_.nanFollowupReceivedInd = event;
parent_.notify();
return Void();
}
Return<void> eventTransmitFollowup(
uint16_t id, const WifiNanStatus& status) override {
parent_.callbackType = EVENT_TRANSMIT_FOLLOWUP;
parent_.id = id;
parent_.status = status;
parent_.notify();
return Void();
}
Return<void> eventDataPathRequest(
const NanDataPathRequestInd& event) override {
parent_.callbackType = EVENT_DATA_PATH_REQUEST;
parent_.nanDataPathRequestInd = event;
parent_.notify();
return Void();
}
Return<void> eventDataPathConfirm(
const ::android::hardware::wifi::V1_0::NanDataPathConfirmInd& event)
override {
parent_.callbackType = EVENT_DATA_PATH_CONFIRM;
parent_.nanDataPathConfirmInd = event;
parent_.notify();
return Void();
}
Return<void> eventDataPathTerminated(uint32_t ndpInstanceId) override {
parent_.callbackType = EVENT_DATA_PATH_TERMINATED;
parent_.ndpInstanceId = ndpInstanceId;
parent_.notify();
return Void();
}
Return<void> eventDataPathConfirm_1_2(
const ::android::hardware::wifi::V1_2::NanDataPathConfirmInd& event)
override {
parent_.callbackType = EVENT_DATA_PATH_CONFIRM_1_2;
parent_.nanDataPathConfirmInd_1_2 = event;
parent_.notify();
return Void();
}
Return<void> eventDataPathScheduleUpdate(
const NanDataPathScheduleUpdateInd& event) override {
parent_.callbackType = EVENT_DATA_PATH_SCHEDULE_UPDATE;
parent_.nanDataPathScheduleUpdateInd = event;
parent_.notify();
return Void();
}
};
private:
// synchronization objects
std::mutex mtx_;
std::condition_variable cv_;
int count_;
protected:
android::sp<::android::hardware::wifi::V1_4::IWifiNanIface> iwifiNanIface;
// Data from IWifiNanIfaceEventCallback callbacks: this is the collection of
// all arguments to all callbacks. They are set by the callback
// (notifications or events) and can be retrieved by tests.
CallbackType callbackType;
uint16_t id;
WifiNanStatus status;
NanCapabilities capabilities;
uint8_t sessionId;
uint32_t ndpInstanceId;
NanClusterEventInd nanClusterEventInd;
NanMatchInd nanMatchInd;
uint32_t peerId;
NanFollowupReceivedInd nanFollowupReceivedInd;
NanDataPathRequestInd nanDataPathRequestInd;
::android::hardware::wifi::V1_0::NanDataPathConfirmInd
nanDataPathConfirmInd;
::android::hardware::wifi::V1_2::NanDataPathConfirmInd
nanDataPathConfirmInd_1_2;
NanDataPathScheduleUpdateInd nanDataPathScheduleUpdateInd;
std::string GetInstanceName() { return GetParam(); }
};
/*
* Create:
* Ensures that an instance of the IWifiNanIface proxy object is
* successfully created.
*/
TEST_P(WifiNanIfaceHidlTest, Create) {
// The creation of a proxy object is tested as part of SetUp method.
}
/*
* enableRequest_1_4InvalidArgs: validate that fails with invalid arguments
*/
TEST_P(WifiNanIfaceHidlTest, enableRequest_1_4InvalidArgs) {
uint16_t inputCmdId = 10;
callbackType = INVALID;
::android::hardware::wifi::V1_4::NanEnableRequest nanEnableRequest = {};
NanConfigRequestSupplemental nanConfigRequestSupp = {};
ASSERT_EQ(WifiStatusCode::SUCCESS,
HIDL_INVOKE(iwifiNanIface, enableRequest_1_4, inputCmdId,
nanEnableRequest, nanConfigRequestSupp)
.code);
// wait for a callback
ASSERT_EQ(std::cv_status::no_timeout, wait(NOTIFY_ENABLE_RESPONSE));
ASSERT_EQ(NOTIFY_ENABLE_RESPONSE, callbackType);
ASSERT_EQ(id, inputCmdId);
ASSERT_EQ(status.status, NanStatusType::INVALID_ARGS);
}
/*
* enableRequest_1_4ShimInvalidArgs: validate that fails with invalid arguments
* to the shim
*/
TEST_P(WifiNanIfaceHidlTest, enableRequest_1_4ShimInvalidArgs) {
uint16_t inputCmdId = 10;
::android::hardware::wifi::V1_4::NanEnableRequest nanEnableRequest = {};
nanEnableRequest.configParams.numberOfPublishServiceIdsInBeacon =
128; // must be <= 127
NanConfigRequestSupplemental nanConfigRequestSupp = {};
ASSERT_EQ(WifiStatusCode::ERROR_INVALID_ARGS,
HIDL_INVOKE(iwifiNanIface, enableRequest_1_4, inputCmdId,
nanEnableRequest, nanConfigRequestSupp)
.code);
}
/*
* configRequest_1_4InvalidArgs: validate that fails with invalid arguments
*/
TEST_P(WifiNanIfaceHidlTest, configRequest_1_4InvalidArgs) {
uint16_t inputCmdId = 10;
callbackType = INVALID;
::android::hardware::wifi::V1_4::NanConfigRequest nanConfigRequest = {};
NanConfigRequestSupplemental nanConfigRequestSupp = {};
ASSERT_EQ(WifiStatusCode::SUCCESS,
HIDL_INVOKE(iwifiNanIface, configRequest_1_4, inputCmdId,
nanConfigRequest, nanConfigRequestSupp)
.code);
// wait for a callback
ASSERT_EQ(std::cv_status::no_timeout, wait(NOTIFY_CONFIG_RESPONSE));
ASSERT_EQ(NOTIFY_CONFIG_RESPONSE, callbackType);
ASSERT_EQ(id, inputCmdId);
ASSERT_EQ(status.status, NanStatusType::INVALID_ARGS);
}
/*
* configRequest_1_4ShimInvalidArgs: validate that fails with invalid arguments
* to the shim
*/
TEST_P(WifiNanIfaceHidlTest, configRequest_1_4ShimInvalidArgs) {
uint16_t inputCmdId = 10;
::android::hardware::wifi::V1_4::NanConfigRequest nanConfigRequest = {};
nanConfigRequest.numberOfPublishServiceIdsInBeacon = 128; // must be <= 127
NanConfigRequestSupplemental nanConfigRequestSupp = {};
ASSERT_EQ(WifiStatusCode::ERROR_INVALID_ARGS,
HIDL_INVOKE(iwifiNanIface, configRequest_1_4, inputCmdId,
nanConfigRequest, nanConfigRequestSupp)
.code);
}