[AWARE] Update HIDL interface and link to legacy HAL
HAL: Refine first cut implementation of HIDL interfaces and bring
up-to-date with changes to HAL.
Server: connect to legacy HAL, convert all structures.
Bug: 32207606
Test: builds
Change-Id: Ice1ba44014aa98cc948c0d0202b4fd18bf875502
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index a94d812..9cc57bb 100644
--- a/wifi/1.0/default/hidl_struct_util.cpp
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -743,123 +743,10 @@
CHECK(false);
}
-legacy_hal::NanPublishType convertHidlNanPublishTypeToLegacy(
- NanPublishType type) {
- switch (type) {
- case NanPublishType::UNSOLICITED:
- return legacy_hal::NAN_PUBLISH_TYPE_UNSOLICITED;
- case NanPublishType::SOLICITED:
- return legacy_hal::NAN_PUBLISH_TYPE_SOLICITED;
- case NanPublishType::UNSOLICITED_SOLICITED:
- return legacy_hal::NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED;
- };
- CHECK(false);
-}
-
-legacy_hal::NanTxType convertHidlNanTxTypeToLegacy(NanTxType type) {
- switch (type) {
- case NanTxType::BROADCAST:
- return legacy_hal::NAN_TX_TYPE_BROADCAST;
- case NanTxType::UNICAST:
- return legacy_hal::NAN_TX_TYPE_UNICAST;
- };
- CHECK(false);
-}
-
-legacy_hal::NanMatchAlg convertHidlNanMatchAlgToLegacy(NanMatchAlg type) {
- switch (type) {
- case NanMatchAlg::MATCH_ONCE:
- return legacy_hal::NAN_MATCH_ALG_MATCH_ONCE;
- case NanMatchAlg::MATCH_CONTINUOUS:
- return legacy_hal::NAN_MATCH_ALG_MATCH_CONTINUOUS;
- case NanMatchAlg::MATCH_NEVER:
- return legacy_hal::NAN_MATCH_ALG_MATCH_NEVER;
- };
- CHECK(false);
-}
-
-legacy_hal::NanSubscribeType convertHidlNanSubscribeTypeToLegacy(
- NanSubscribeType type) {
- switch (type) {
- case NanSubscribeType::ACTIVE:
- return legacy_hal::NAN_SUBSCRIBE_TYPE_ACTIVE;
- case NanSubscribeType::PASSIVE:
- return legacy_hal::NAN_SUBSCRIBE_TYPE_PASSIVE;
- };
- CHECK(false);
-}
-
-legacy_hal::NanSRFType convertHidlNanSrfTypeToLegacy(NanSrfType type) {
- switch (type) {
- case NanSrfType::BLOOM_FILTER:
- return legacy_hal::NAN_SRF_ATTR_BLOOM_FILTER;
- case NanSrfType::PARTIAL_MAC_ADDR:
- return legacy_hal::NAN_SRF_ATTR_PARTIAL_MAC_ADDR;
- };
- CHECK(false);
-}
-
-legacy_hal::NanSRFIncludeType convertHidlNanSrfIncludeTypeToLegacy(
- NanSrfIncludeType type) {
- switch (type) {
- case NanSrfIncludeType::DO_NOT_RESPOND:
- return legacy_hal::NAN_SRF_INCLUDE_DO_NOT_RESPOND;
- case NanSrfIncludeType::RESPOND:
- return legacy_hal::NAN_SRF_INCLUDE_RESPOND;
- };
- CHECK(false);
-}
-
NanStatusType convertLegacyNanStatusTypeToHidl(
- legacy_hal::NanStatusType /* type */) {
- // TODO: The |NanStatusType| has changed in legacy HAL and no longer in sync
- // with the HIDL interface.
- return NanStatusType::SUCCESS;
-}
-
-NanResponseType convertLegacyNanResponseTypeToHidl(
- legacy_hal::NanResponseType type) {
- switch (type) {
- case legacy_hal::NAN_RESPONSE_ENABLED:
- return NanResponseType::ENABLED;
- case legacy_hal::NAN_RESPONSE_DISABLED:
- return NanResponseType::DISABLED;
- case legacy_hal::NAN_RESPONSE_PUBLISH:
- return NanResponseType::PUBLISH;
- case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL:
- return NanResponseType::PUBLISH_CANCEL;
- case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP:
- return NanResponseType::TRANSMIT_FOLLOWUP;
- case legacy_hal::NAN_RESPONSE_SUBSCRIBE:
- return NanResponseType::SUBSCRIBE;
- case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL:
- return NanResponseType::SUBSCRIBE_CANCEL;
- case legacy_hal::NAN_RESPONSE_STATS:
- // Not present in HIDL. Is going to be deprecated in legacy HAL as well.
- CHECK(0);
- case legacy_hal::NAN_RESPONSE_CONFIG:
- return NanResponseType::CONFIG;
- case legacy_hal::NAN_RESPONSE_TCA:
- // Not present in HIDL. Is going to be deprecated in legacy HAL as well.
- CHECK(0);
- case legacy_hal::NAN_RESPONSE_ERROR:
- return NanResponseType::ERROR;
- case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD:
- return NanResponseType::BEACON_SDF_PAYLOAD;
- case legacy_hal::NAN_GET_CAPABILITIES:
- return NanResponseType::GET_CAPABILITIES;
- case legacy_hal::NAN_DP_INTERFACE_CREATE:
- return NanResponseType::DP_INTERFACE_CREATE;
- case legacy_hal::NAN_DP_INTERFACE_DELETE:
- return NanResponseType::DP_INTERFACE_DELETE;
- case legacy_hal::NAN_DP_INITIATOR_RESPONSE:
- return NanResponseType::DP_INITIATOR_RESPONSE;
- case legacy_hal::NAN_DP_RESPONDER_RESPONSE:
- return NanResponseType::DP_RESPONDER_RESPONSE;
- case legacy_hal::NAN_DP_END:
- return NanResponseType::DP_END;
- };
- CHECK(false) << "Unknown legacy type: " << type;
+ legacy_hal::NanStatusType type) {
+ // values are identical - may need to do a mapping if they diverge in the future
+ return (NanStatusType) type;
}
bool convertHidlNanEnableRequestToLegacy(
@@ -868,79 +755,123 @@
if (!legacy_request) {
return false;
}
- legacy_request->master_pref = hidl_request.masterPref;
- legacy_request->cluster_low = hidl_request.clusterLow;
- legacy_request->cluster_high = hidl_request.clusterHigh;
- legacy_request->config_support_5g = hidl_request.validSupport5gVal;
- legacy_request->support_5g_val = hidl_request.support5gVal;
- legacy_request->config_sid_beacon = hidl_request.validSidBeaconVal;
- legacy_request->sid_beacon_val = hidl_request.sidBeaconVal;
- legacy_request->config_2dot4g_rssi_close =
- hidl_request.valid2dot4gRssiCloseVal;
- legacy_request->rssi_close_2dot4g_val = hidl_request.rssiClose2dot4gVal;
- legacy_request->config_2dot4g_rssi_middle =
- hidl_request.valid2dot4gRssiMiddleVal;
- legacy_request->rssi_middle_2dot4g_val = hidl_request.rssiMiddle2dot4gVal;
- legacy_request->config_2dot4g_rssi_proximity =
- hidl_request.valid2dot4gRssiProximityVal;
+ memset(legacy_request, 0, sizeof(legacy_hal::NanEnableRequest));
+
+ // TODO: b/34059183 tracks missing configurations in legacy HAL or uknown defaults
+ legacy_request->config_2dot4g_support = 1;
+ legacy_request->support_2dot4g_val = hidl_request.operateInBand[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_support_5g = 1;
+ legacy_request->support_5g_val = hidl_request.operateInBand[(size_t) NanBandIndex::NAN_BAND_5GHZ];
+ legacy_request->config_hop_count_limit = 0; // TODO: don't know default yet
+ legacy_request->hop_count_limit_val = hidl_request.hopCountMax;
+ legacy_request->master_pref = hidl_request.configParams.masterPref;
+ legacy_request->discovery_indication_cfg = 0;
+ legacy_request->discovery_indication_cfg |=
+ hidl_request.configParams.disableDiscoveryAddressChangeIndication ? 0x1 : 0x0;
+ legacy_request->discovery_indication_cfg |=
+ hidl_request.configParams.disableStartedClusterIndication ? 0x2 : 0x0;
+ legacy_request->discovery_indication_cfg |=
+ hidl_request.configParams.disableJoinedClusterIndication ? 0x4 : 0x0;
+ legacy_request->config_sid_beacon = 1;
+ if (hidl_request.configParams.numberOfServiceIdsInBeacon > 127) {
+ return false;
+ }
+ legacy_request->sid_beacon_val = (hidl_request.configParams.includeServiceIdsInBeacon ? 0x1 : 0x0)
+ | (hidl_request.configParams.numberOfServiceIdsInBeacon << 1);
+ legacy_request->config_rssi_window_size = 0; // TODO: don't know default yet
+ legacy_request->rssi_window_size_val = hidl_request.configParams.rssiWindowSize;
+ legacy_request->config_disc_mac_addr_randomization = 1;
+ legacy_request->disc_mac_addr_rand_interval_sec =
+ hidl_request.configParams.macAddressRandomizationIntervalSec;
+ legacy_request->config_responder_auto_response = 1;
+ legacy_request->ranging_auto_response_cfg = hidl_request.configParams.acceptRangingRequests ?
+ legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
+ legacy_request->config_2dot4g_rssi_close = 0; // TODO: don't know default yet
+ legacy_request->rssi_close_2dot4g_val =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiClose;
+ legacy_request->config_2dot4g_rssi_middle = 0; // TODO: don't know default yet
+ legacy_request->rssi_middle_2dot4g_val =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiMiddle;
+ legacy_request->config_2dot4g_rssi_proximity = 0; // TODO: don't know default yet
legacy_request->rssi_proximity_2dot4g_val =
- hidl_request.rssiProximity2dot4gVal;
- legacy_request->config_hop_count_limit = hidl_request.validHopCountLimitVal;
- legacy_request->hop_count_limit_val = hidl_request.hopCountLimitVal;
- legacy_request->config_2dot4g_support = hidl_request.valid2dot4gSupportVal;
- legacy_request->support_2dot4g_val = hidl_request.support2dot4gVal;
- legacy_request->config_2dot4g_beacons = hidl_request.valid2dot4gBeaconsVal;
- legacy_request->beacon_2dot4g_val = hidl_request.beacon2dot4gVal;
- legacy_request->config_2dot4g_sdf = hidl_request.valid2dot4gSdfVal;
- legacy_request->sdf_2dot4g_val = hidl_request.sdf2dot4gVal;
- legacy_request->config_5g_beacons = hidl_request.valid5gBeaconsVal;
- legacy_request->beacon_5g_val = hidl_request.beacon5gVal;
- legacy_request->config_5g_sdf = hidl_request.valid5gSdfVal;
- legacy_request->sdf_5g_val = hidl_request.sdf5gVal;
- legacy_request->config_5g_rssi_close = hidl_request.valid5gRssiCloseVal;
- legacy_request->rssi_close_5g_val = hidl_request.rssiClose5gVal;
- legacy_request->config_5g_rssi_middle = hidl_request.valid5gRssiMiddleVal;
- legacy_request->rssi_middle_5g_val = hidl_request.rssiMiddle5gVal;
- legacy_request->config_5g_rssi_close_proximity =
- hidl_request.valid5gRssiCloseProximityVal;
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiProximity;
+ legacy_request->config_scan_params = 0; // TODO: don't know default yet
+ legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].dwellTimeMs;
+ legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].scanPeriodSec;
+ legacy_request->config_dw.config_2dot4g_dw_band = hidl_request.configParams
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_2dot4g_interval_val = hidl_request.configParams
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].discoveryWindowIntervalVal;
+ legacy_request->config_5g_rssi_close = 0; // TODO: don't know default yet
+ legacy_request->rssi_close_5g_val =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiClose;
+ legacy_request->config_5g_rssi_middle = 0; // TODO: don't know default yet
+ legacy_request->rssi_middle_5g_val =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiMiddle;
+ legacy_request->config_5g_rssi_close_proximity = 0; // TODO: don't know default yet
legacy_request->rssi_close_proximity_5g_val =
- hidl_request.rssiCloseProximity5gVal;
- legacy_request->config_rssi_window_size = hidl_request.validRssiWindowSizeVal;
- legacy_request->rssi_window_size_val = hidl_request.rssiWindowSizeVal;
- legacy_request->config_oui = hidl_request.validOuiVal;
- legacy_request->oui_val = hidl_request.ouiVal;
- legacy_request->config_intf_addr = hidl_request.validIntfAddrVal;
- CHECK(hidl_request.intfAddrVal.size() ==
- sizeof(legacy_request->intf_addr_val));
- memcpy(legacy_request->intf_addr_val,
- hidl_request.intfAddrVal.data(),
- hidl_request.intfAddrVal.size());
- legacy_request->config_cluster_attribute_val =
- hidl_request.configClusterAttributeVal;
- legacy_request->config_scan_params = hidl_request.validScanParamsVal;
- if (hidl_request.scanParamsVal.dwellTime.size() >
- sizeof(legacy_request->scan_params_val.dwell_time)) {
- return false;
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiProximity;
+ legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
+ legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
+ legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
+ legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.configParams.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
+ legacy_request->config_dw.config_5g_dw_band = hidl_request.configParams
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_5g_interval_val = hidl_request.configParams
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].discoveryWindowIntervalVal;
+ if (hidl_request.debugConfigs.validClusterIdVals) {
+ legacy_request->cluster_low = hidl_request.debugConfigs.clusterIdLowVal;
+ legacy_request->cluster_high = hidl_request.debugConfigs.clusterIdHighVal;
+ } else { // need 'else' since not configurable in legacy HAL
+ legacy_request->cluster_low = 0x0000;
+ legacy_request->cluster_high = 0xFFFF;
}
- memcpy(legacy_request->scan_params_val.dwell_time,
- hidl_request.scanParamsVal.dwellTime.data(),
- hidl_request.scanParamsVal.dwellTime.size());
- if (hidl_request.scanParamsVal.scanPeriod.size() >
- sizeof(legacy_request->scan_params_val.scan_period)) {
- return false;
- }
- memcpy(legacy_request->scan_params_val.scan_period,
- hidl_request.scanParamsVal.scanPeriod.data(),
- hidl_request.scanParamsVal.scanPeriod.size());
- legacy_request->config_random_factor_force =
- hidl_request.validRandomFactorForceVal;
- legacy_request->random_factor_force_val = hidl_request.randomFactorForceVal;
- legacy_request->config_hop_count_force = hidl_request.validHopCountLimitVal;
- legacy_request->hop_count_force_val = hidl_request.hopCountLimitVal;
- legacy_request->config_24g_channel = hidl_request.valid24gChannelVal;
- legacy_request->channel_24g_val = hidl_request.channel24gVal;
- legacy_request->config_5g_channel = hidl_request.valid5gChannelVal;
- legacy_request->channel_5g_val = hidl_request.channel5gVal;
+ legacy_request->config_intf_addr = hidl_request.debugConfigs.validIntfAddrVal;
+ memcpy(legacy_request->intf_addr_val, hidl_request.debugConfigs.intfAddrVal.data(), 6);
+ legacy_request->config_oui = hidl_request.debugConfigs.validOuiVal;
+ legacy_request->oui_val = hidl_request.debugConfigs.ouiVal;
+ legacy_request->config_random_factor_force = hidl_request.debugConfigs.validRandomFactorForceVal;
+ legacy_request->random_factor_force_val = hidl_request.debugConfigs.randomFactorForceVal;
+ legacy_request->config_hop_count_force = hidl_request.debugConfigs.validHopCountForceVal;
+ legacy_request->hop_count_force_val = hidl_request.debugConfigs.hopCountForceVal;
+ legacy_request->config_24g_channel = hidl_request.debugConfigs.validDiscoveryChannelVal;
+ legacy_request->channel_24g_val =
+ hidl_request.debugConfigs.discoveryChannelMhzVal[(size_t) NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_5g_channel = hidl_request.debugConfigs.validDiscoveryChannelVal;
+ legacy_request->channel_5g_val = hidl_request.debugConfigs
+ .discoveryChannelMhzVal[(size_t) NanBandIndex::NAN_BAND_5GHZ];
+ legacy_request->config_2dot4g_beacons = hidl_request.debugConfigs.validUseBeaconsInBandVal;
+ legacy_request->beacon_2dot4g_val = hidl_request.debugConfigs
+ .useBeaconsInBandVal[(size_t) NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_5g_beacons = hidl_request.debugConfigs.validUseBeaconsInBandVal;
+ legacy_request->beacon_5g_val = hidl_request.debugConfigs
+ .useBeaconsInBandVal[(size_t) NanBandIndex::NAN_BAND_5GHZ];
+ legacy_request->config_2dot4g_sdf = hidl_request.debugConfigs.validUseSdfInBandVal;
+ legacy_request->sdf_2dot4g_val = hidl_request.debugConfigs
+ .useSdfInBandVal[(size_t) NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_5g_sdf = hidl_request.debugConfigs.validUseSdfInBandVal;
+ legacy_request->sdf_5g_val = hidl_request.debugConfigs
+ .useSdfInBandVal[(size_t) NanBandIndex::NAN_BAND_5GHZ];
+
return true;
}
@@ -950,57 +881,69 @@
if (!legacy_request) {
return false;
}
- legacy_request->publish_id = hidl_request.publishId;
- legacy_request->ttl = hidl_request.ttl;
- legacy_request->period = hidl_request.period;
- legacy_request->publish_type =
- convertHidlNanPublishTypeToLegacy(hidl_request.publishType);
- legacy_request->tx_type = convertHidlNanTxTypeToLegacy(hidl_request.txType);
- legacy_request->publish_count = hidl_request.publishCount;
- if (hidl_request.serviceName.size() > sizeof(legacy_request->service_name)) {
- return false;
- }
- legacy_request->service_name_len = hidl_request.serviceName.size();
- memcpy(legacy_request->service_name,
- hidl_request.serviceName.c_str(),
- hidl_request.serviceName.size());
- legacy_request->publish_match_indicator =
- convertHidlNanMatchAlgToLegacy(hidl_request.publishMatchIndicator);
- if (hidl_request.serviceSpecificInfo.size() >
- sizeof(legacy_request->service_specific_info)) {
- return false;
- }
- legacy_request->service_specific_info_len =
- hidl_request.serviceSpecificInfo.size();
- memcpy(legacy_request->service_specific_info,
- hidl_request.serviceSpecificInfo.data(),
- hidl_request.serviceSpecificInfo.size());
- if (hidl_request.rxMatchFilter.size() >
- sizeof(legacy_request->rx_match_filter)) {
- return false;
- }
- legacy_request->rx_match_filter_len = hidl_request.rxMatchFilter.size();
- memcpy(legacy_request->rx_match_filter,
- hidl_request.rxMatchFilter.data(),
- hidl_request.rxMatchFilter.size());
- if (hidl_request.txMatchFilter.size() >
- sizeof(legacy_request->tx_match_filter)) {
- return false;
- }
- legacy_request->tx_match_filter_len = hidl_request.txMatchFilter.size();
- memcpy(legacy_request->tx_match_filter,
- hidl_request.txMatchFilter.data(),
- hidl_request.txMatchFilter.size());
- legacy_request->rssi_threshold_flag = hidl_request.useRssiThreshold;
- legacy_request->connmap = hidl_request.connmap;
- legacy_request->recv_indication_cfg = hidl_request.recvIndicationCfg;
- return true;
-}
+ memset(&legacy_request, 0, sizeof(legacy_hal::NanPublishRequest));
-bool convertHidlNanPublishCancelRequestToLegacy(
- const NanPublishCancelRequest& hidl_request,
- legacy_hal::NanPublishCancelRequest* legacy_request) {
- legacy_request->publish_id = hidl_request.publishId;
+ legacy_request->publish_id = hidl_request.baseConfigs.sessionId;
+ legacy_request->ttl = hidl_request.baseConfigs.ttlSec;
+ legacy_request->period = hidl_request.baseConfigs.discoveryWindowPeriod;
+ legacy_request->publish_count = hidl_request.baseConfigs.discoveryCount;
+ legacy_request->service_name_len = hidl_request.baseConfigs.serviceName.size();
+ if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->service_name, hidl_request.baseConfigs.serviceName.c_str(),
+ legacy_request->service_name_len);
+ legacy_request->publish_match_indicator =
+ (legacy_hal::NanMatchAlg) hidl_request.baseConfigs.discoveryMatchIndicator;
+ legacy_request->service_specific_info_len = hidl_request.baseConfigs.serviceSpecificInfo.size();
+ if (legacy_request->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->service_specific_info,
+ hidl_request.baseConfigs.serviceSpecificInfo.data(),
+ legacy_request->service_specific_info_len);
+ legacy_request->rx_match_filter_len = hidl_request.baseConfigs.rxMatchFilter.size();
+ if (legacy_request->rx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->rx_match_filter,
+ hidl_request.baseConfigs.rxMatchFilter.data(),
+ legacy_request->rx_match_filter_len);
+ legacy_request->tx_match_filter_len = hidl_request.baseConfigs.txMatchFilter.size();
+ if (legacy_request->tx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->tx_match_filter,
+ hidl_request.baseConfigs.txMatchFilter.data(),
+ legacy_request->tx_match_filter_len);
+ legacy_request->rssi_threshold_flag = hidl_request.baseConfigs.useRssiThreshold;
+ legacy_request->recv_indication_cfg = 0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableDiscoveryTerminationIndication ? 0x1 : 0x0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableMatchExpirationIndication ? 0x2 : 0x0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableFollowupReceivedIndication ? 0x4 : 0x0;
+ legacy_request->cipher_type = hidl_request.baseConfigs.supportedCipherTypes;
+ legacy_request->pmk_len = hidl_request.baseConfigs.pmk.size();
+ if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->pmk,
+ hidl_request.baseConfigs.pmk.data(),
+ legacy_request->pmk_len);
+ legacy_request->sdea_params.security_cfg = hidl_request.baseConfigs.securityEnabledInNdp ?
+ legacy_hal::NAN_DP_CONFIG_SECURITY : legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
+ legacy_request->sdea_params.ranging_state = hidl_request.baseConfigs.rangingRequired ?
+ legacy_hal::NAN_RANGING_ENABLE : legacy_hal::NAN_RANGING_DISABLE;
+ legacy_request->ranging_cfg.ranging_interval_msec = hidl_request.baseConfigs.rangingIntervalMsec;
+ legacy_request->ranging_cfg.config_ranging_indications =
+ hidl_request.baseConfigs.configRangingIndications;
+ legacy_request->ranging_cfg.distance_ingress_cm = hidl_request.baseConfigs.distanceIngressCm;
+ legacy_request->ranging_cfg.distance_egress_cm = hidl_request.baseConfigs.distanceEgressCm;
+ legacy_request->publish_type = (legacy_hal::NanPublishType) hidl_request.publishType;
+ legacy_request->tx_type = (legacy_hal::NanTxType) hidl_request.txType;
+
return true;
}
@@ -1010,225 +953,417 @@
if (!legacy_request) {
return false;
}
- legacy_request->subscribe_id = hidl_request.subscribeId;
- legacy_request->ttl = hidl_request.ttl;
- legacy_request->period = hidl_request.period;
- legacy_request->subscribe_type =
- convertHidlNanSubscribeTypeToLegacy(hidl_request.subscribeType);
- legacy_request->serviceResponseFilter =
- convertHidlNanSrfTypeToLegacy(hidl_request.serviceResponseFilter);
- legacy_request->serviceResponseInclude =
- convertHidlNanSrfIncludeTypeToLegacy(hidl_request.serviceResponseInclude);
- legacy_request->useServiceResponseFilter =
- hidl_request.shouldUseServiceResponseFilter
- ? legacy_hal::NAN_USE_SRF
- : legacy_hal::NAN_DO_NOT_USE_SRF;
- legacy_request->ssiRequiredForMatchIndication =
- hidl_request.isSsiRequiredForMatchIndication
- ? legacy_hal::NAN_SSI_REQUIRED_IN_MATCH_IND
- : legacy_hal::NAN_SSI_NOT_REQUIRED_IN_MATCH_IND;
+ memset(&legacy_request, 0, sizeof(legacy_hal::NanSubscribeRequest));
+
+ legacy_request->subscribe_id = hidl_request.baseConfigs.sessionId;
+ legacy_request->ttl = hidl_request.baseConfigs.ttlSec;
+ legacy_request->period = hidl_request.baseConfigs.discoveryWindowPeriod;
+ legacy_request->subscribe_count = hidl_request.baseConfigs.discoveryCount;
+ legacy_request->service_name_len = hidl_request.baseConfigs.serviceName.size();
+ if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->service_name, hidl_request.baseConfigs.serviceName.c_str(),
+ legacy_request->service_name_len);
legacy_request->subscribe_match_indicator =
- convertHidlNanMatchAlgToLegacy(hidl_request.subscribeMatchIndicator);
- legacy_request->subscribe_count = hidl_request.subscribeCount;
- if (hidl_request.serviceName.size() > sizeof(legacy_request->service_name)) {
+ (legacy_hal::NanMatchAlg) hidl_request.baseConfigs.discoveryMatchIndicator;
+ legacy_request->service_specific_info_len = hidl_request.baseConfigs.serviceSpecificInfo.size();
+ if (legacy_request->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
return false;
}
- legacy_request->service_name_len = hidl_request.serviceName.size();
- memcpy(legacy_request->service_name,
- hidl_request.serviceName.c_str(),
- hidl_request.serviceName.size());
- if (hidl_request.serviceSpecificInfo.size() >
- sizeof(legacy_request->service_specific_info)) {
- return false;
- }
- legacy_request->service_specific_info_len =
- hidl_request.serviceSpecificInfo.size();
memcpy(legacy_request->service_specific_info,
- hidl_request.serviceSpecificInfo.data(),
- hidl_request.serviceSpecificInfo.size());
- if (hidl_request.rxMatchFilter.size() >
- sizeof(legacy_request->rx_match_filter)) {
+ hidl_request.baseConfigs.serviceSpecificInfo.data(),
+ legacy_request->service_specific_info_len);
+ legacy_request->rx_match_filter_len = hidl_request.baseConfigs.rxMatchFilter.size();
+ if (legacy_request->rx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
return false;
}
- legacy_request->rx_match_filter_len = hidl_request.rxMatchFilter.size();
memcpy(legacy_request->rx_match_filter,
- hidl_request.rxMatchFilter.data(),
- hidl_request.rxMatchFilter.size());
- if (hidl_request.txMatchFilter.size() >
- sizeof(legacy_request->tx_match_filter)) {
+ hidl_request.baseConfigs.rxMatchFilter.data(),
+ legacy_request->rx_match_filter_len);
+ legacy_request->tx_match_filter_len = hidl_request.baseConfigs.txMatchFilter.size();
+ if (legacy_request->tx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
return false;
}
- legacy_request->tx_match_filter_len = hidl_request.txMatchFilter.size();
memcpy(legacy_request->tx_match_filter,
- hidl_request.txMatchFilter.data(),
- hidl_request.txMatchFilter.size());
- legacy_request->rssi_threshold_flag = hidl_request.useRssiThreshold;
- legacy_request->connmap = hidl_request.connmap;
- if (hidl_request.intfAddr.size() > NAN_MAX_SUBSCRIBE_MAX_ADDRESS) {
+ hidl_request.baseConfigs.txMatchFilter.data(),
+ legacy_request->tx_match_filter_len);
+ legacy_request->rssi_threshold_flag = hidl_request.baseConfigs.useRssiThreshold;
+ legacy_request->recv_indication_cfg = 0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableDiscoveryTerminationIndication ? 0x1 : 0x0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableMatchExpirationIndication ? 0x2 : 0x0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableFollowupReceivedIndication ? 0x4 : 0x0;
+ legacy_request->cipher_type = hidl_request.baseConfigs.supportedCipherTypes;
+ legacy_request->pmk_len = hidl_request.baseConfigs.pmk.size();
+ if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
return false;
}
+ memcpy(legacy_request->pmk,
+ hidl_request.baseConfigs.pmk.data(),
+ legacy_request->pmk_len);
+ legacy_request->sdea_params.security_cfg = hidl_request.baseConfigs.securityEnabledInNdp ?
+ legacy_hal::NAN_DP_CONFIG_SECURITY : legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
+ legacy_request->sdea_params.ranging_state = hidl_request.baseConfigs.rangingRequired ?
+ legacy_hal::NAN_RANGING_ENABLE : legacy_hal::NAN_RANGING_DISABLE;
+ legacy_request->ranging_cfg.ranging_interval_msec = hidl_request.baseConfigs.rangingIntervalMsec;
+ legacy_request->ranging_cfg.config_ranging_indications =
+ hidl_request.baseConfigs.configRangingIndications;
+ legacy_request->ranging_cfg.distance_ingress_cm = hidl_request.baseConfigs.distanceIngressCm;
+ legacy_request->ranging_cfg.distance_egress_cm = hidl_request.baseConfigs.distanceEgressCm;
+ legacy_request->subscribe_type = (legacy_hal::NanSubscribeType) hidl_request.subscribeType;
+ legacy_request->serviceResponseFilter = (legacy_hal::NanSRFType) hidl_request.srfType;
+ legacy_request->serviceResponseInclude = hidl_request.srfRespondIfInAddressSet ?
+ legacy_hal::NAN_SRF_INCLUDE_RESPOND : legacy_hal::NAN_SRF_INCLUDE_DO_NOT_RESPOND;
+ legacy_request->useServiceResponseFilter = hidl_request.shouldUseSrf ?
+ legacy_hal::NAN_USE_SRF : legacy_hal::NAN_DO_NOT_USE_SRF;
+ legacy_request->ssiRequiredForMatchIndication = hidl_request.isSsiRequiredForMatch ?
+ legacy_hal::NAN_SSI_REQUIRED_IN_MATCH_IND : legacy_hal::NAN_SSI_NOT_REQUIRED_IN_MATCH_IND;
legacy_request->num_intf_addr_present = hidl_request.intfAddr.size();
- for (uint32_t i = 0; i < hidl_request.intfAddr.size(); i++) {
- CHECK(hidl_request.intfAddr[i].size() ==
- sizeof(legacy_request->intf_addr[i]));
- memcpy(legacy_request->intf_addr[i],
- hidl_request.intfAddr[i].data(),
- hidl_request.intfAddr[i].size());
+ if (legacy_request->num_intf_addr_present > NAN_MAX_SUBSCRIBE_MAX_ADDRESS) {
+ return false;
}
- legacy_request->recv_indication_cfg = hidl_request.recvIndicationCfg;
+ for (int i = 0; i < legacy_request->num_intf_addr_present; i++) {
+ memcpy(legacy_request->intf_addr[i], hidl_request.intfAddr[i].data(), 6);
+ }
+
return true;
}
-bool convertHidlNanSubscribeCancelRequestToLegacy(
- const NanSubscribeCancelRequest& /* hidl_request */,
- legacy_hal::NanSubscribeCancelRequest* /* legacy_request */) {
- return false;
-}
-
bool convertHidlNanTransmitFollowupRequestToLegacy(
- const NanTransmitFollowupRequest& /* hidl_request */,
- legacy_hal::NanTransmitFollowupRequest* /* legacy_request */) {
- return false;
+ const NanTransmitFollowupRequest& hidl_request,
+ legacy_hal::NanTransmitFollowupRequest* legacy_request) {
+ if (!legacy_request) {
+ return false;
+ }
+ memset(&legacy_request, 0, sizeof(legacy_hal::NanTransmitFollowupRequest));
+
+ legacy_request->publish_subscribe_id = hidl_request.discoverySessionId;
+ legacy_request->requestor_instance_id = hidl_request.peerId;
+ memcpy(legacy_request->addr, hidl_request.addr.data(), 6);
+ legacy_request->priority = hidl_request.isHighPriority ?
+ legacy_hal::NAN_TX_PRIORITY_HIGH : legacy_hal::NAN_TX_PRIORITY_NORMAL;
+ legacy_request->dw_or_faw = hidl_request.shouldUseDiscoveryWindow ?
+ legacy_hal::NAN_TRANSMIT_IN_DW : legacy_hal::NAN_TRANSMIT_IN_FAW;
+ legacy_request->service_specific_info_len = hidl_request.message.size();
+ if (legacy_request->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->service_specific_info,
+ hidl_request.message.data(),
+ legacy_request->service_specific_info_len);
+ legacy_request->recv_indication_cfg = hidl_request.disableFollowupResultIndication ? 0x1 : 0x0;
+
+ return true;
}
bool convertHidlNanConfigRequestToLegacy(
- const NanConfigRequest& /* hidl_request */,
- legacy_hal::NanConfigRequest* /* legacy_request */) {
- return false;
+ const NanConfigRequest& hidl_request,
+ legacy_hal::NanConfigRequest* legacy_request) {
+ if (!legacy_request) {
+ return false;
+ }
+ memset(&legacy_request, 0, sizeof(legacy_hal::NanConfigRequest));
+
+ // TODO: b/34059183 tracks missing configurations in legacy HAL or uknown defaults
+ legacy_request->master_pref = hidl_request.masterPref;
+ legacy_request->discovery_indication_cfg = 0;
+ legacy_request->discovery_indication_cfg |=
+ hidl_request.disableDiscoveryAddressChangeIndication ? 0x1 : 0x0;
+ legacy_request->discovery_indication_cfg |=
+ hidl_request.disableStartedClusterIndication ? 0x2 : 0x0;
+ legacy_request->discovery_indication_cfg |=
+ hidl_request.disableJoinedClusterIndication ? 0x4 : 0x0;
+ legacy_request->config_sid_beacon = 1;
+ if (hidl_request.numberOfServiceIdsInBeacon > 127) {
+ return false;
+ }
+ legacy_request->sid_beacon = (hidl_request.includeServiceIdsInBeacon ? 0x1 : 0x0)
+ | (hidl_request.numberOfServiceIdsInBeacon << 1);
+ legacy_request->config_rssi_window_size = 0; // TODO: don't know default yet
+ legacy_request->rssi_window_size_val = hidl_request.rssiWindowSize;
+ legacy_request->config_disc_mac_addr_randomization = 1;
+ legacy_request->disc_mac_addr_rand_interval_sec =
+ hidl_request.macAddressRandomizationIntervalSec;
+ legacy_request->config_responder_auto_response = 1;
+ legacy_request->ranging_auto_response_cfg = hidl_request.acceptRangingRequests ?
+ legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
+ /* TODO : missing
+ legacy_request->config_2dot4g_rssi_close = 0; // TODO: don't know default yet
+ legacy_request->rssi_close_2dot4g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiClose;
+ legacy_request->config_2dot4g_rssi_middle = 0; // TODO: don't know default yet
+ legacy_request->rssi_middle_2dot4g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiMiddle;
+ legacy_request->config_2dot4g_rssi_proximity = 0; // TODO: don't know default yet
+ legacy_request->rssi_proximity_2dot4g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiProximity;
+ */
+ legacy_request->config_scan_params = 0; // TODO: don't know default yet
+ legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].dwellTimeMs;
+ legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].scanPeriodSec;
+ legacy_request->config_dw.config_2dot4g_dw_band = hidl_request
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_2dot4g_interval_val = hidl_request
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].discoveryWindowIntervalVal;
+ /* TODO: missing
+ legacy_request->config_5g_rssi_close = 0; // TODO: don't know default yet
+ legacy_request->rssi_close_5g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiClose;
+ legacy_request->config_5g_rssi_middle = 0; // TODO: don't know default yet
+ legacy_request->rssi_middle_5g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiMiddle;
+ */
+ legacy_request->config_5g_rssi_close_proximity = 0; // TODO: don't know default yet
+ legacy_request->rssi_close_proximity_5g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiProximity;
+ legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
+ legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
+ legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
+ legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
+ legacy_request->config_dw.config_5g_dw_band = hidl_request
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_5g_interval_val = hidl_request
+ .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].discoveryWindowIntervalVal;
+
+ return true;
}
bool convertHidlNanBeaconSdfPayloadRequestToLegacy(
- const NanBeaconSdfPayloadRequest& /* hidl_request */,
- legacy_hal::NanBeaconSdfPayloadRequest* /* legacy_request */) {
- return false;
+ const NanBeaconSdfPayloadRequest& hidl_request,
+ legacy_hal::NanBeaconSdfPayloadRequest* legacy_request) {
+ if (!legacy_request) {
+ return false;
+ }
+ memset(&legacy_request, 0, sizeof(legacy_hal::NanBeaconSdfPayloadRequest));
+
+ legacy_request->vsa.payload_transmit_flag = hidl_request.transmitInNext16dws ? 1 : 0;
+ legacy_request->vsa.tx_in_discovery_beacon = hidl_request.transmitInDiscoveryBeacon;
+ legacy_request->vsa.tx_in_sync_beacon = hidl_request.transmitInSyncBeacon;
+ legacy_request->vsa.tx_in_service_discovery = hidl_request.transmitInServiceDiscoveryFrame;
+ legacy_request->vsa.vendor_oui = hidl_request.vendorOui;
+ legacy_request->vsa.vsa_len = hidl_request.vsa.size();
+ if (legacy_request->vsa.vsa_len > NAN_MAX_VSA_DATA_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->vsa.vsa, hidl_request.vsa.data(), legacy_request->vsa.vsa_len);
+
+ return true;
}
bool convertHidlNanDataPathInitiatorRequestToLegacy(
- const NanDataPathInitiatorRequest& /* hidl_request */,
- legacy_hal::NanDataPathInitiatorRequest* /* legacy_request */) {
- return false;
+ const NanInitiateDataPathRequest& hidl_request,
+ legacy_hal::NanDataPathInitiatorRequest* legacy_request) {
+ if (!legacy_request) {
+ return false;
+ }
+ memset(&legacy_request, 0, sizeof(legacy_hal::NanDataPathInitiatorRequest));
+
+ legacy_request->requestor_instance_id = hidl_request.peerId;
+ memcpy(legacy_request->peer_disc_mac_addr, hidl_request.peerDiscMacAddr.data(), 6);
+ legacy_request->channel_request_type =
+ (legacy_hal::NanDataPathChannelCfg) hidl_request.channelRequestType;
+ legacy_request->channel = hidl_request.channel;
+ strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
+ legacy_request->ndp_cfg.security_cfg = hidl_request.securityRequired ?
+ legacy_hal::NAN_DP_CONFIG_SECURITY : legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
+ legacy_request->app_info.ndp_app_info_len = hidl_request.appInfo.size();
+ if (legacy_request->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
+ legacy_request->app_info.ndp_app_info_len);
+ legacy_request->cipher_type = hidl_request.supportedCipherTypes;
+ legacy_request->pmk_len = hidl_request.pmk.size();
+ if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->pmk, hidl_request.pmk.data(), legacy_request->pmk_len);
+
+ return true;
}
bool convertHidlNanDataPathIndicationResponseToLegacy(
- const NanDataPathIndicationResponse& /* hidl_response */,
- legacy_hal::NanDataPathIndicationResponse* /* legacy_response */) {
- return false;
-}
+ const NanRespondToDataPathIndicationRequest& hidl_request,
+ legacy_hal::NanDataPathIndicationResponse* legacy_request) {
+ if (!legacy_request) {
+ return false;
+ }
+ memset(&legacy_request, 0, sizeof(legacy_hal::NanDataPathIndicationResponse));
-bool convertHidlNanDataPathEndRequestToLegacy(
- const NanDataPathEndRequest& /* hidl_request */,
- legacy_hal::NanDataPathEndRequest* /* legacy_request */) {
- return false;
+ legacy_request->rsp_code = hidl_request.acceptRequest ?
+ legacy_hal::NAN_DP_REQUEST_ACCEPT : legacy_hal::NAN_DP_REQUEST_REJECT;
+ legacy_request->ndp_instance_id = hidl_request.ndpInstanceId;
+ strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
+ legacy_request->ndp_cfg.security_cfg = hidl_request.securityRequired ?
+ legacy_hal::NAN_DP_CONFIG_SECURITY : legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
+ legacy_request->app_info.ndp_app_info_len = hidl_request.appInfo.size();
+ if (legacy_request->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
+ legacy_request->app_info.ndp_app_info_len);
+ legacy_request->cipher_type = hidl_request.supportedCipherTypes;
+ legacy_request->pmk_len = hidl_request.pmk.size();
+ if (legacy_request->pmk_len > NAN_PMK_INFO_LEN) {
+ return false;
+ }
+ memcpy(legacy_request->pmk, hidl_request.pmk.data(), legacy_request->pmk_len);
+
+ return true;
}
bool convertLegacyNanResponseHeaderToHidl(
const legacy_hal::NanResponseMsg& legacy_response,
- NanResponseMsgHeader* hidl_response) {
- if (!hidl_response) {
+ WifiNanStatus* wifiNanStatus) {
+ if (!wifiNanStatus) {
return false;
}
- hidl_response->status =
- convertLegacyNanStatusTypeToHidl(legacy_response.status);
- hidl_response->value = legacy_response.value;
- hidl_response->responseType =
- convertLegacyNanResponseTypeToHidl(legacy_response.response_type);
+ wifiNanStatus->status = convertLegacyNanStatusTypeToHidl(legacy_response.status);
+ wifiNanStatus->description = legacy_response.nan_error;
+
return true;
}
-bool convertLegacyNanPublishResponseToHidl(
- const legacy_hal::NanPublishResponse& /* legacy_response */,
- NanPublishResponse* /* hidl_response */) {
- return false;
-}
-
-bool convertLegacyNanSubscribeResponseToHidl(
- const legacy_hal::NanSubscribeResponse& /* legacy_response */,
- NanSubscribeResponse* /* hidl_response */) {
- return false;
-}
-
-bool convertLegacyNanDataPathResponseToHidl(
- const legacy_hal::NanDataPathRequestResponse& /* legacy_response */,
- NanDataPathResponse* /* hidl_response */) {
- return false;
-}
-
bool convertLegacyNanCapabilitiesResponseToHidl(
- const legacy_hal::NanCapabilities& /* legacy_response */,
- NanCapabilitiesResponse* /* hidl_response */) {
- return false;
-}
+ const legacy_hal::NanCapabilities& legacy_response,
+ NanCapabilities* hidl_response) {
+ if (!hidl_response) {
+ return false;
+ }
+ hidl_response->maxConcurrentClusters = legacy_response.max_concurrent_nan_clusters;
+ hidl_response->maxPublishes = legacy_response.max_publishes;
+ hidl_response->maxSubscribes = legacy_response.max_subscribes;
+ hidl_response->maxServiceNameLen = legacy_response.max_service_name_len;
+ hidl_response->maxMatchFilterLen = legacy_response.max_match_filter_len;
+ hidl_response->maxTotalMatchFilterLen = legacy_response.max_total_match_filter_len;
+ hidl_response->maxServiceSpecificInfoLen = legacy_response.max_service_specific_info_len;
+ hidl_response->maxVsaDataLen = legacy_response.max_vsa_data_len;
+ hidl_response->maxNdiInterfaces = legacy_response.max_ndi_interfaces;
+ hidl_response->maxNdpSessions = legacy_response.max_ndp_sessions;
+ hidl_response->maxAppInfoLen = legacy_response.max_app_info_len;
+ hidl_response->maxQueuedTransmitFollowupMsgs = legacy_response.max_queued_transmit_followup_msgs;
+ // TODO: b/34059183 to add to underlying HAL
+ hidl_response->maxSubscribeInterfaceAddresses = NAN_MAX_SUBSCRIBE_MAX_ADDRESS;
+ hidl_response->supportedCipherSuites = legacy_response.cipher_suites_supported;
-bool convertLegacyNanPublishTerminatedIndToHidl(
- const legacy_hal::NanPublishTerminatedInd& /* legacy_ind */,
- NanPublishTerminatedInd* /* hidl_ind */) {
- return false;
+ return true;
}
bool convertLegacyNanMatchIndToHidl(
- const legacy_hal::NanMatchInd& /* legacy_ind */,
- NanMatchInd* /* hidl_ind */) {
- return false;
-}
+ const legacy_hal::NanMatchInd& legacy_ind,
+ NanMatchInd* hidl_ind) {
+ if (!hidl_ind) {
+ return false;
+ }
+ hidl_ind->discoverySessionId = legacy_ind.publish_subscribe_id;
+ hidl_ind->peerId = legacy_ind.requestor_instance_id;
+ hidl_ind->addr = hidl_array<uint8_t, 6>(legacy_ind.addr);
+ hidl_ind->serviceSpecificInfo = std::vector<uint8_t>(legacy_ind.service_specific_info,
+ legacy_ind.service_specific_info + legacy_ind.service_specific_info_len);
+ hidl_ind->matchFilter = std::vector<uint8_t>(legacy_ind.sdf_match_filter,
+ legacy_ind.sdf_match_filter + legacy_ind.sdf_match_filter_len);
+ hidl_ind->matchOccuredInBeaconFlag = legacy_ind.match_occured_flag == 1;
+ hidl_ind->outOfResourceFlag = legacy_ind.out_of_resource_flag == 1;
+ hidl_ind->rssiValue = legacy_ind.rssi_value;
+ hidl_ind->peerSupportedCipherTypes = legacy_ind.peer_cipher_type;
+ hidl_ind->peerRequiresSecurityEnabledInNdp =
+ legacy_ind.peer_sdea_params.security_cfg == legacy_hal::NAN_DP_CONFIG_SECURITY;
+ hidl_ind->peerRequiresRanging =
+ legacy_ind.peer_sdea_params.ranging_state == legacy_hal::NAN_RANGING_ENABLE;
+ hidl_ind->rangingMeasurementInCm = legacy_ind.range_result.range_measurement_cm;
+ hidl_ind->rangingIndicationType = legacy_ind.range_result.ranging_event_type;
-bool convertLegacyNanMatchExpiredIndToHidl(
- const legacy_hal::NanMatchExpiredInd& /* legacy_ind */,
- NanMatchExpiredInd* /* hidl_ind */) {
- return false;
-}
-
-bool convertLegacyNanSubscribeTerminatedIndToHidl(
- const legacy_hal::NanSubscribeTerminatedInd& /* legacy_ind */,
- NanSubscribeTerminatedInd* /* hidl_ind */) {
- return false;
+ return true;
}
bool convertLegacyNanFollowupIndToHidl(
- const legacy_hal::NanFollowupInd& /* legacy_ind */,
- NanFollowupInd* /* hidl_ind */) {
- return false;
-}
+ const legacy_hal::NanFollowupInd& legacy_ind,
+ NanFollowupReceivedInd* hidl_ind) {
+ if (!hidl_ind) {
+ return false;
+ }
+ hidl_ind->discoverySessionId = legacy_ind.publish_subscribe_id;
+ hidl_ind->peerId = legacy_ind.requestor_instance_id;
+ hidl_ind->addr = hidl_array<uint8_t, 6>(legacy_ind.addr);
+ hidl_ind->receivedInFaw = legacy_ind.dw_or_faw == 1;
+ hidl_ind->message = std::vector<uint8_t>(legacy_ind.service_specific_info,
+ legacy_ind.service_specific_info + legacy_ind.service_specific_info_len);
-bool convertLegacyNanDiscEngEventIndToHidl(
- const legacy_hal::NanDiscEngEventInd& /* legacy_ind */,
- NanDiscEngEventInd* /* hidl_ind */) {
- return false;
-}
-
-bool convertLegacyNanDisabledIndToHidl(
- const legacy_hal::NanDisabledInd& /* legacy_ind */,
- NanDisabledInd* /* hidl_ind */) {
- return false;
+ return true;
}
bool convertLegacyNanBeaconSdfPayloadIndToHidl(
- const legacy_hal::NanBeaconSdfPayloadInd& /* legacy_ind */,
- NanBeaconSdfPayloadInd* /* hidl_ind */) {
- return false;
+ const legacy_hal::NanBeaconSdfPayloadInd& legacy_ind,
+ NanBeaconSdfPayloadInd* hidl_ind) {
+ if (!hidl_ind) {
+ return false;
+ }
+ hidl_ind->addr = hidl_array<uint8_t, 6>(legacy_ind.addr);
+ hidl_ind->isVsaReceived = legacy_ind.is_vsa_received == 1;
+ hidl_ind->vsaReceivedOnFrames = legacy_ind.vsa.vsa_received_on;
+ hidl_ind->vsaVendorOui = legacy_ind.vsa.vendor_oui;
+ hidl_ind->vsa = std::vector<uint8_t>(legacy_ind.vsa.vsa,
+ legacy_ind.vsa.vsa + legacy_ind.vsa.attr_len);
+ hidl_ind->isBeaconSdfPayloadReceived = legacy_ind.is_beacon_sdf_payload_received == 1;
+ hidl_ind->beaconSdfPayloadData = std::vector<uint8_t>(legacy_ind.data.frame_data,
+ legacy_ind.data.frame_data + legacy_ind.data.frame_len);
+
+ return true;
}
bool convertLegacyNanDataPathRequestIndToHidl(
- const legacy_hal::NanDataPathRequestInd& /* legacy_ind */,
- NanDataPathRequestInd* /* hidl_ind */) {
- return false;
+ const legacy_hal::NanDataPathRequestInd& legacy_ind,
+ NanDataPathRequestInd* hidl_ind) {
+ if (!hidl_ind) {
+ return false;
+ }
+ hidl_ind->discoverySessionId = legacy_ind.service_instance_id;
+ hidl_ind->peerDiscMacAddr = hidl_array<uint8_t, 6>(legacy_ind.peer_disc_mac_addr);
+ hidl_ind->ndpInstanceId = legacy_ind.ndp_instance_id;
+ hidl_ind->securityRequired =
+ legacy_ind.ndp_cfg.security_cfg == legacy_hal::NAN_DP_CONFIG_SECURITY;
+ hidl_ind->appInfo = std::vector<uint8_t>(legacy_ind.app_info.ndp_app_info,
+ legacy_ind.app_info.ndp_app_info + legacy_ind.app_info.ndp_app_info_len);
+
+ return true;
}
bool convertLegacyNanDataPathConfirmIndToHidl(
- const legacy_hal::NanDataPathConfirmInd& /* legacy_ind */,
- NanDataPathConfirmInd* /* hidl_ind */) {
- return false;
-}
+ const legacy_hal::NanDataPathConfirmInd& legacy_ind,
+ NanDataPathConfirmInd* hidl_ind) {
+ if (!hidl_ind) {
+ return false;
+ }
+ hidl_ind->ndpInstanceId = legacy_ind.ndp_instance_id;
+ hidl_ind->dataPathSetupSuccess = legacy_ind.rsp_code == legacy_hal::NAN_DP_REQUEST_ACCEPT;
+ hidl_ind->peerNdiMacAddr = hidl_array<uint8_t, 6>(legacy_ind.peer_ndi_mac_addr);
+ hidl_ind->appInfo = std::vector<uint8_t>(legacy_ind.app_info.ndp_app_info,
+ legacy_ind.app_info.ndp_app_info + legacy_ind.app_info.ndp_app_info_len);
+ hidl_ind->status.status = convertLegacyNanStatusTypeToHidl(legacy_ind.reason_code);
+ hidl_ind->status.description = ""; // TODO: b/34059183
-bool convertLegacyNanDataPathEndIndToHidl(
- const legacy_hal::NanDataPathEndInd& /* legacy_ind */,
- NanDataPathEndInd* /* hidl_ind */) {
- return false;
-}
-
-bool convertLegacyNanTransmitFollowupIndToHidl(
- const legacy_hal::NanTransmitFollowupInd& /* legacy_ind */,
- NanTransmitFollowupInd* /* hidl_ind */) {
- return false;
+ return true;
}
legacy_hal::wifi_rtt_type convertHidlRttTypeToLegacy(RttType type) {
diff --git a/wifi/1.0/default/hidl_struct_util.h b/wifi/1.0/default/hidl_struct_util.h
index 9086666..14bc77d 100644
--- a/wifi/1.0/default/hidl_struct_util.h
+++ b/wifi/1.0/default/hidl_struct_util.h
@@ -94,87 +94,50 @@
std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
// NAN iface conversion methods.
+NanStatusType convertLegacyNanStatusTypeToHidl(legacy_hal::NanStatusType type);
bool convertHidlNanEnableRequestToLegacy(
const NanEnableRequest& hidl_request,
legacy_hal::NanEnableRequest* legacy_request);
-bool convertHidlNanPublishRequestToLegacy(
- const NanPublishRequest& hidl_request,
- legacy_hal::NanPublishRequest* legacy_request);
-bool convertHidlNanPublishCancelRequestToLegacy(
- const NanPublishCancelRequest& hidl_request,
- legacy_hal::NanPublishCancelRequest* legacy_request);
-bool convertHidlNanSubscribeRequestToLegacy(
- const NanSubscribeRequest& hidl_request,
- legacy_hal::NanSubscribeRequest* legacy_request);
-bool convertHidlNanSubscribeCancelRequestToLegacy(
- const NanSubscribeCancelRequest& hidl_request,
- legacy_hal::NanSubscribeCancelRequest* legacy_request);
-bool convertHidlNanTransmitFollowupRequestToLegacy(
- const NanTransmitFollowupRequest& hidl_request,
- legacy_hal::NanTransmitFollowupRequest* legacy_request);
bool convertHidlNanConfigRequestToLegacy(
const NanConfigRequest& hidl_request,
legacy_hal::NanConfigRequest* legacy_request);
+bool convertHidlNanPublishRequestToLegacy(
+ const NanPublishRequest& hidl_request,
+ legacy_hal::NanPublishRequest* legacy_request);
+bool convertHidlNanSubscribeRequestToLegacy(
+ const NanSubscribeRequest& hidl_request,
+ legacy_hal::NanSubscribeRequest* legacy_request);
+bool convertHidlNanTransmitFollowupRequestToLegacy(
+ const NanTransmitFollowupRequest& hidl_request,
+ legacy_hal::NanTransmitFollowupRequest* legacy_request);
bool convertHidlNanBeaconSdfPayloadRequestToLegacy(
const NanBeaconSdfPayloadRequest& hidl_request,
legacy_hal::NanBeaconSdfPayloadRequest* legacy_request);
bool convertHidlNanDataPathInitiatorRequestToLegacy(
- const NanDataPathInitiatorRequest& hidl_request,
+ const NanInitiateDataPathRequest& hidl_request,
legacy_hal::NanDataPathInitiatorRequest* legacy_request);
bool convertHidlNanDataPathIndicationResponseToLegacy(
- const NanDataPathIndicationResponse& hidl_response,
+ const NanRespondToDataPathIndicationRequest& hidl_response,
legacy_hal::NanDataPathIndicationResponse* legacy_response);
-bool convertHidlNanDataPathEndRequestToLegacy(
- const NanDataPathEndRequest& hidl_request,
- legacy_hal::NanDataPathEndRequest* legacy_request);
bool convertLegacyNanResponseHeaderToHidl(
const legacy_hal::NanResponseMsg& legacy_response,
- NanResponseMsgHeader* hidl_response);
-bool convertLegacyNanPublishResponseToHidl(
- const legacy_hal::NanPublishResponse& legacy_response,
- NanPublishResponse* hidl_response);
-bool convertLegacyNanSubscribeResponseToHidl(
- const legacy_hal::NanSubscribeResponse& legacy_response,
- NanSubscribeResponse* hidl_response);
-bool convertLegacyNanDataPathResponseToHidl(
- const legacy_hal::NanDataPathRequestResponse& legacy_response,
- NanDataPathResponse* hidl_response);
+ WifiNanStatus* wifiNanStatus);
bool convertLegacyNanCapabilitiesResponseToHidl(
const legacy_hal::NanCapabilities& legacy_response,
- NanCapabilitiesResponse* hidl_response);
-bool convertLegacyNanPublishTerminatedIndToHidl(
- const legacy_hal::NanPublishTerminatedInd& legacy_ind,
- NanPublishTerminatedInd* hidl_ind);
+ NanCapabilities* hidl_response);
bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
NanMatchInd* hidl_ind);
-bool convertLegacyNanMatchExpiredIndToHidl(
- const legacy_hal::NanMatchExpiredInd& legacy_ind,
- NanMatchExpiredInd* hidl_ind);
-bool convertLegacyNanSubscribeTerminatedIndToHidl(
- const legacy_hal::NanSubscribeTerminatedInd& legacy_ind,
- NanSubscribeTerminatedInd* hidl_ind);
bool convertLegacyNanFollowupIndToHidl(
- const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupInd* hidl_ind);
-bool convertLegacyNanDiscEngEventIndToHidl(
- const legacy_hal::NanDiscEngEventInd& legacy_ind,
- NanDiscEngEventInd* hidl_ind);
-bool convertLegacyNanDisabledIndToHidl(
- const legacy_hal::NanDisabledInd& legacy_ind, NanDisabledInd* hidl_ind);
-bool convertLegacyNanBeaconSdfPayloadIndToHidl(
- const legacy_hal::NanBeaconSdfPayloadInd& legacy_ind,
- NanBeaconSdfPayloadInd* hidl_ind);
+ const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupReceivedInd* hidl_ind);
bool convertLegacyNanDataPathRequestIndToHidl(
const legacy_hal::NanDataPathRequestInd& legacy_ind,
NanDataPathRequestInd* hidl_ind);
bool convertLegacyNanDataPathConfirmIndToHidl(
const legacy_hal::NanDataPathConfirmInd& legacy_ind,
NanDataPathConfirmInd* hidl_ind);
-bool convertLegacyNanDataPathEndIndToHidl(
- const legacy_hal::NanDataPathEndInd& legacy_ind,
- NanDataPathEndInd* hidl_ind);
-bool convertLegacyNanTransmitFollowupIndToHidl(
- const legacy_hal::NanTransmitFollowupInd& legacy_ind,
- NanTransmitFollowupInd* hidl_ind);
+bool convertLegacyNanBeaconSdfPayloadIndToHidl(
+ const legacy_hal::NanBeaconSdfPayloadInd& legacy_ind,
+ NanBeaconSdfPayloadInd* hidl_ind);
// RTT controller conversion methods.
bool convertHidlVectorOfRttConfigToLegacy(
diff --git a/wifi/1.0/default/wifi_nan_iface.cpp b/wifi/1.0/default/wifi_nan_iface.cpp
index 8d5cbc9..5ac6fa8 100644
--- a/wifi/1.0/default/wifi_nan_iface.cpp
+++ b/wifi/1.0/default/wifi_nan_iface.cpp
@@ -36,35 +36,378 @@
// of the object. Whenever the mode changes legacy HAL will remove
// all of these callbacks.
legacy_hal::NanCallbackHandlers callback_handlers;
+ android::wp<WifiNanIface> weak_ptr_this(this);
// Callback for response.
- callback_handlers.on_notify_response = [&](
+ callback_handlers.on_notify_response = [weak_ptr_this](
legacy_hal::transaction_id id, const legacy_hal::NanResponseMsg& msg) {
- NanResponseMsgHeader hidl_header;
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus wifiNanStatus;
if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl(msg,
- &hidl_header)) {
+ &wifiNanStatus)) {
LOG(ERROR) << "Failed to convert nan response header";
return;
}
- // TODO: This is a union in the legacy HAL. Need to convert to appropriate
- // callback based on type.
- // Assuming |NanPublishResponseMsg| type here.
- NanPublishResponse hidl_body;
- if (!hidl_struct_util::convertLegacyNanPublishResponseToHidl(
- msg.body.publish_response, &hidl_body)) {
- LOG(ERROR) << "Failed to convert nan publish response";
- return;
+
+ switch (msg.response_type) {
+ case legacy_hal::NAN_RESPONSE_ENABLED: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyEnableResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
}
- NanPublishResponseMsg hidl_msg;
- hidl_msg.header = hidl_header;
- hidl_msg.body = hidl_body;
- for (const auto& callback : event_callbacks_) {
- if (!callback->notifyPublishResponse(id, hidl_msg).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
+ case legacy_hal::NAN_RESPONSE_DISABLED: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyDisableResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_PUBLISH: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyStartPublishResponse(id, wifiNanStatus,
+ msg.body.publish_response.publish_id).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyStopPublishResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyTransmitFollowupResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_SUBSCRIBE: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyStartSubscribeResponse(id, wifiNanStatus,
+ msg.body.subscribe_response.subscribe_id).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyStopSubscribeResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_CONFIG: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyConfigResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyBeaconSdfPayloadResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_GET_CAPABILITIES: {
+ NanCapabilities hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanCapabilitiesResponseToHidl(
+ msg.body.nan_capabilities, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyCapabilitiesResponse(id, wifiNanStatus,
+ hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_DP_INTERFACE_CREATE: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyCreateDataInterfaceResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_DP_INTERFACE_DELETE: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyDeleteDataInterfaceResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_DP_INITIATOR_RESPONSE: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyInitiateDataPathResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_DP_RESPONDER_RESPONSE: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyRespondToDataPathIndicationResponse(id, wifiNanStatus,
+ msg.body.data_request_response.ndp_instance_id).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_DP_END: {
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->notifyTerminateDataPathResponse(id, wifiNanStatus).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ case legacy_hal::NAN_RESPONSE_TCA:
+ /* fall through */
+ case legacy_hal::NAN_RESPONSE_STATS:
+ /* fall through */
+ case legacy_hal::NAN_RESPONSE_ERROR:
+ /* fall through */
+ default:
+ LOG(ERROR) << "Unknown or unhandled response type: " << msg.response_type;
+ return;
}
};
- // TODO: Register the remaining callbacks.
+
+ callback_handlers.on_event_disc_eng_event = [weak_ptr_this](
+ const legacy_hal::NanDiscEngEventInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanClusterEventInd hidl_struct;
+ // event types defined identically - hence can be cast
+ hidl_struct.eventType = (NanClusterEventType) msg.event_type;
+ hidl_struct.addr = msg.data.mac_addr.addr;
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventClusterEvent(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_disabled = [weak_ptr_this](
+ const legacy_hal::NanDisabledInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
+ status.description = msg.nan_reason;
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventDisabled(status).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_publish_terminated = [weak_ptr_this](
+ const legacy_hal::NanPublishTerminatedInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
+ status.description = msg.nan_reason;
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventPublishTerminated(msg.publish_id, status).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_subscribe_terminated = [weak_ptr_this](
+ const legacy_hal::NanSubscribeTerminatedInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
+ status.description = msg.nan_reason;
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventSubscribeTerminated(msg.subscribe_id, status).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_match = [weak_ptr_this](
+ const legacy_hal::NanMatchInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanMatchInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanMatchIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventMatch(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_match_expired = [weak_ptr_this](
+ const legacy_hal::NanMatchExpiredInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventMatchExpired(msg.publish_subscribe_id,
+ msg.requestor_instance_id).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_followup = [weak_ptr_this](
+ const legacy_hal::NanFollowupInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanFollowupReceivedInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventFollowupReceived(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_transmit_follow_up = [weak_ptr_this](
+ const legacy_hal::NanTransmitFollowupInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason);
+ status.description = msg.nan_reason;
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventTransmitFollowup(msg.id, status).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_data_path_request = [weak_ptr_this](
+ const legacy_hal::NanDataPathRequestInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanDataPathRequestInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventDataPathRequest(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_data_path_confirm = [weak_ptr_this](
+ const legacy_hal::NanDataPathConfirmInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanDataPathConfirmInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventDataPathConfirm(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_data_path_end = [weak_ptr_this](
+ const legacy_hal::NanDataPathEndInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ for (int i = 0; i < msg.num_ndp_instances; ++i) {
+ if (!callback->eventDataPathTerminated(msg.ndp_instance_id[i]).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ };
+
+ callback_handlers.on_event_beacon_sdf_payload = [weak_ptr_this](
+ const legacy_hal::NanBeaconSdfPayloadInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanBeaconSdfPayloadInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanBeaconSdfPayloadIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->event_callbacks_) {
+ if (!callback->eventBeaconSdfPayload(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->nanRegisterCallbackHandlers(callback_handlers);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
@@ -90,6 +433,13 @@
hidl_status_cb);
}
+Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::getTypeInternal,
+ hidl_status_cb);
+}
+
Return<void> WifiNanIface::registerEventCallback(
const sp<IWifiNanIfaceEventCallback>& callback,
registerEventCallback_cb hidl_status_cb) {
@@ -100,7 +450,16 @@
callback);
}
-Return<void> WifiNanIface::enableRequest(uint32_t cmd_id,
+Return<void> WifiNanIface::getCapabilitiesRequest(uint16_t cmd_id,
+ getCapabilitiesRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::getCapabilitiesRequestInternal,
+ hidl_status_cb,
+ cmd_id);
+}
+
+Return<void> WifiNanIface::enableRequest(uint16_t cmd_id,
const NanEnableRequest& msg,
enableRequest_cb hidl_status_cb) {
return validateAndCall(this,
@@ -111,75 +470,7 @@
msg);
}
-Return<void> WifiNanIface::disableRequest(uint32_t cmd_id,
- disableRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::disableRequestInternal,
- hidl_status_cb,
- cmd_id);
-}
-
-Return<void> WifiNanIface::publishRequest(uint32_t cmd_id,
- const NanPublishRequest& msg,
- publishRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::publishRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::publishCancelRequest(
- uint32_t cmd_id,
- const NanPublishCancelRequest& msg,
- publishCancelRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::publishCancelRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::subscribeRequest(
- uint32_t cmd_id,
- const NanSubscribeRequest& msg,
- subscribeRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::subscribeRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::subscribeCancelRequest(
- uint32_t cmd_id,
- const NanSubscribeCancelRequest& msg,
- subscribeCancelRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::subscribeCancelRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::transmitFollowupRequest(
- uint32_t cmd_id,
- const NanTransmitFollowupRequest& msg,
- transmitFollowupRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::transmitFollowupRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::configRequest(uint32_t cmd_id,
+Return<void> WifiNanIface::configRequest(uint16_t cmd_id,
const NanConfigRequest& msg,
configRequest_cb hidl_status_cb) {
return validateAndCall(this,
@@ -190,8 +481,134 @@
msg);
}
+Return<void> WifiNanIface::disableRequest(uint16_t cmd_id,
+ disableRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::disableRequestInternal,
+ hidl_status_cb,
+ cmd_id);
+}
+
+Return<void> WifiNanIface::startPublishRequest(uint16_t cmd_id,
+ const NanPublishRequest& msg,
+ startPublishRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::startPublishRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ msg);
+}
+
+Return<void> WifiNanIface::stopPublishRequest(
+ uint16_t cmd_id,
+ uint16_t sessionId,
+ stopPublishRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::stopPublishRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ sessionId);
+}
+
+Return<void> WifiNanIface::startSubscribeRequest(
+ uint16_t cmd_id,
+ const NanSubscribeRequest& msg,
+ startSubscribeRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::startSubscribeRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ msg);
+}
+
+Return<void> WifiNanIface::stopSubscribeRequest(
+ uint16_t cmd_id,
+ uint16_t sessionId,
+ stopSubscribeRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::stopSubscribeRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ sessionId);
+}
+
+Return<void> WifiNanIface::transmitFollowupRequest(
+ uint16_t cmd_id,
+ const NanTransmitFollowupRequest& msg,
+ transmitFollowupRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::transmitFollowupRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ msg);
+}
+
+Return<void> WifiNanIface::createDataInterfaceRequest(
+ uint16_t cmd_id,
+ const hidl_string& iface_name,
+ createDataInterfaceRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::createDataInterfaceRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ iface_name);
+}
+
+Return<void> WifiNanIface::deleteDataInterfaceRequest(
+ uint16_t cmd_id,
+ const hidl_string& iface_name,
+ deleteDataInterfaceRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::deleteDataInterfaceRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ iface_name);
+}
+
+Return<void> WifiNanIface::initiateDataPathRequest(
+ uint16_t cmd_id,
+ const NanInitiateDataPathRequest& msg,
+ initiateDataPathRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::initiateDataPathRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ msg);
+}
+
+Return<void> WifiNanIface::respondToDataPathIndicationRequest(
+ uint16_t cmd_id,
+ const NanRespondToDataPathIndicationRequest& msg,
+ respondToDataPathIndicationRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::respondToDataPathIndicationRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ msg);
+}
+
+Return<void> WifiNanIface::terminateDataPathRequest(uint16_t cmd_id, uint32_t ndpInstanceId,
+ terminateDataPathRequest_cb hidl_status_cb) {
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::terminateDataPathRequestInternal,
+ hidl_status_cb,
+ cmd_id,
+ ndpInstanceId);
+}
+
Return<void> WifiNanIface::beaconSdfPayloadRequest(
- uint32_t cmd_id,
+ uint16_t cmd_id,
const NanBeaconSdfPayloadRequest& msg,
beaconSdfPayloadRequest_cb hidl_status_cb) {
return validateAndCall(this,
@@ -202,88 +619,6 @@
msg);
}
-Return<void> WifiNanIface::getVersion(getVersion_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::getVersionInternal,
- hidl_status_cb);
-}
-
-Return<void> WifiNanIface::getCapabilities(uint32_t cmd_id,
- getCapabilities_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::getCapabilitiesInternal,
- hidl_status_cb,
- cmd_id);
-}
-
-Return<void> WifiNanIface::dataInterfaceCreate(
- uint32_t cmd_id,
- const hidl_string& iface_name,
- dataInterfaceCreate_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::dataInterfaceCreateInternal,
- hidl_status_cb,
- cmd_id,
- iface_name);
-}
-
-Return<void> WifiNanIface::dataInterfaceDelete(
- uint32_t cmd_id,
- const hidl_string& iface_name,
- dataInterfaceDelete_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::dataInterfaceDeleteInternal,
- hidl_status_cb,
- cmd_id,
- iface_name);
-}
-
-Return<void> WifiNanIface::dataRequestInitiator(
- uint32_t cmd_id,
- const NanDataPathInitiatorRequest& msg,
- dataRequestInitiator_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::dataRequestInitiatorInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::dataIndicationResponse(
- uint32_t cmd_id,
- const NanDataPathIndicationResponse& msg,
- dataIndicationResponse_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::dataIndicationResponseInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::dataEnd(uint32_t cmd_id,
- const NanDataPathEndRequest& msg,
- dataEnd_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::dataEndInternal,
- hidl_status_cb,
- cmd_id,
- msg);
-}
-
-Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::getTypeInternal,
- hidl_status_cb);
-}
-
std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() {
return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
@@ -294,16 +629,24 @@
WifiStatus WifiNanIface::registerEventCallbackInternal(
const sp<IWifiNanIfaceEventCallback>& callback) {
- // TODO(b/31632518): remove the callback when the client is destroyed
+ // TODO(b/31632518): remove the callback when the client is destroyed and/or
+ // make sure that the same callback is only registered once (i.e. detect duplicates)
+ // OR: consider having a single listener - not clear why multiple listeners (managers) are
+ // necessary, nor how they would coordinate (at least command IDs).
event_callbacks_.emplace_back(callback);
return createWifiStatus(WifiStatusCode::SUCCESS);
}
-WifiStatus WifiNanIface::enableRequestInternal(uint32_t cmd_id,
+WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t cmd_id) {
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanGetCapabilities(cmd_id);
+ return createWifiStatusFromLegacyError(legacy_status);
+}
+
+WifiStatus WifiNanIface::enableRequestInternal(uint16_t cmd_id,
const NanEnableRequest& msg) {
legacy_hal::NanEnableRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanEnableRequestToLegacy(msg,
- &legacy_msg)) {
+ if (!hidl_struct_util::convertHidlNanEnableRequestToLegacy(msg, &legacy_msg)) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
legacy_hal::wifi_error legacy_status =
@@ -311,14 +654,26 @@
return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::disableRequestInternal(uint32_t cmd_id) {
+WifiStatus WifiNanIface::configRequestInternal(
+ uint16_t cmd_id, const NanConfigRequest& msg) {
+ legacy_hal::NanConfigRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanConfigRequestToLegacy(msg,
+ &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanConfigRequest(cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
+}
+
+WifiStatus WifiNanIface::disableRequestInternal(uint16_t cmd_id) {
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->nanDisableRequest(cmd_id);
return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::publishRequestInternal(uint32_t cmd_id,
- const NanPublishRequest& msg) {
+WifiStatus WifiNanIface::startPublishRequestInternal(uint16_t cmd_id,
+ const NanPublishRequest& msg) {
legacy_hal::NanPublishRequest legacy_msg;
if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg,
&legacy_msg)) {
@@ -329,20 +684,17 @@
return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::publishCancelRequestInternal(
- uint32_t cmd_id, const NanPublishCancelRequest& msg) {
+WifiStatus WifiNanIface::stopPublishRequestInternal(
+ uint16_t cmd_id, uint16_t sessionId) {
legacy_hal::NanPublishCancelRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanPublishCancelRequestToLegacy(
- msg, &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
+ legacy_msg.publish_id = sessionId;
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->nanPublishCancelRequest(cmd_id, legacy_msg);
return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::subscribeRequestInternal(
- uint32_t cmd_id, const NanSubscribeRequest& msg) {
+WifiStatus WifiNanIface::startSubscribeRequestInternal(
+ uint16_t cmd_id, const NanSubscribeRequest& msg) {
legacy_hal::NanSubscribeRequest legacy_msg;
if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy(msg,
&legacy_msg)) {
@@ -353,59 +705,81 @@
return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::subscribeCancelRequestInternal(
- uint32_t /* cmd_id */, const NanSubscribeCancelRequest& /* msg */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
+WifiStatus WifiNanIface::stopSubscribeRequestInternal(
+ uint16_t cmd_id, uint16_t sessionId) {
+ legacy_hal::NanSubscribeCancelRequest legacy_msg;
+ legacy_msg.subscribe_id = sessionId;
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanSubscribeCancelRequest(cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
+
WifiStatus WifiNanIface::transmitFollowupRequestInternal(
- uint32_t /* cmd_id */, const NanTransmitFollowupRequest& /* msg */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ uint16_t cmd_id, const NanTransmitFollowupRequest& msg) {
+ legacy_hal::NanTransmitFollowupRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy(msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanTransmitFollowupRequest(cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::configRequestInternal(
- uint32_t /* cmd_id */, const NanConfigRequest& /* msg */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
+
+WifiStatus WifiNanIface::createDataInterfaceRequestInternal(
+ uint16_t cmd_id, const std::string& iface_name) {
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataInterfaceCreate(cmd_id, iface_name);
+ return createWifiStatusFromLegacyError(legacy_status);
+}
+WifiStatus WifiNanIface::deleteDataInterfaceRequestInternal(
+ uint16_t cmd_id, const std::string& iface_name) {
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataInterfaceDelete(cmd_id, iface_name);
+ return createWifiStatusFromLegacyError(legacy_status);
+}
+WifiStatus WifiNanIface::initiateDataPathRequestInternal(
+ uint16_t cmd_id, const NanInitiateDataPathRequest& msg) {
+ legacy_hal::NanDataPathInitiatorRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy(msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataRequestInitiator(cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
+}
+WifiStatus WifiNanIface::respondToDataPathIndicationRequestInternal(
+ uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg) {
+ legacy_hal::NanDataPathIndicationResponse legacy_msg;
+ if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy(msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataIndicationResponse(cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
+}
+WifiStatus WifiNanIface::terminateDataPathRequestInternal(
+ uint16_t cmd_id, uint32_t ndpInstanceId) {
+ legacy_hal::NanDataPathEndRequest* legacy_msg = (legacy_hal::NanDataPathEndRequest*)malloc(
+ sizeof(legacy_hal::NanDataPathEndRequest) + sizeof(uint32_t));
+ legacy_msg->num_ndp_instances = 1;
+ legacy_msg->ndp_instance_id[0] = ndpInstanceId;
+
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataEnd(cmd_id, *legacy_msg);
+ free(legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::beaconSdfPayloadRequestInternal(
- uint32_t /* cmd_id */, const NanBeaconSdfPayloadRequest& /* msg */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ uint16_t cmd_id, const NanBeaconSdfPayloadRequest& msg) {
+ legacy_hal::NanBeaconSdfPayloadRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanBeaconSdfPayloadRequestToLegacy(msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanBeaconSdfPayloadRequest(cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
-std::pair<WifiStatus, NanVersion> WifiNanIface::getVersionInternal() {
- // TODO implement
- return {createWifiStatus(WifiStatusCode::SUCCESS), 0};
-}
-WifiStatus WifiNanIface::getCapabilitiesInternal(uint32_t /* cmd_id */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
-}
-WifiStatus WifiNanIface::dataInterfaceCreateInternal(
- uint32_t /* cmd_id */, const std::string& /* iface_name */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
-}
-WifiStatus WifiNanIface::dataInterfaceDeleteInternal(
- uint32_t /* cmd_id */, const std::string& /* iface_name */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
-}
-WifiStatus WifiNanIface::dataRequestInitiatorInternal(
- uint32_t /* cmd_id */, const NanDataPathInitiatorRequest& /* msg */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
-}
-WifiStatus WifiNanIface::dataIndicationResponseInternal(
- uint32_t /* cmd_id */, const NanDataPathIndicationResponse& /* msg */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
-}
-WifiStatus WifiNanIface::dataEndInternal(
- uint32_t /* cmd_id */, const NanDataPathEndRequest& /* msg */) {
- // TODO implement
- return createWifiStatus(WifiStatusCode::SUCCESS);
-}
+
} // namespace implementation
} // namespace V1_0
} // namespace wifi
diff --git a/wifi/1.0/default/wifi_nan_iface.h b/wifi/1.0/default/wifi_nan_iface.h
index 4f89b31..4fae3df 100644
--- a/wifi/1.0/default/wifi_nan_iface.h
+++ b/wifi/1.0/default/wifi_nan_iface.h
@@ -46,58 +46,50 @@
Return<void> registerEventCallback(
const sp<IWifiNanIfaceEventCallback>& callback,
registerEventCallback_cb hidl_status_cb) override;
- Return<void> enableRequest(uint32_t cmd_id,
+ Return<void> getCapabilitiesRequest(uint16_t cmd_id,
+ getCapabilitiesRequest_cb hidl_status_cb) override;
+ Return<void> enableRequest(uint16_t cmd_id,
const NanEnableRequest& msg,
enableRequest_cb hidl_status_cb) override;
- Return<void> disableRequest(uint32_t cmd_id,
- disableRequest_cb hidl_status_cb) override;
- Return<void> publishRequest(uint32_t cmd_id,
- const NanPublishRequest& msg,
- publishRequest_cb hidl_status_cb) override;
- Return<void> publishCancelRequest(
- uint32_t cmd_id,
- const NanPublishCancelRequest& msg,
- publishCancelRequest_cb hidl_status_cb) override;
- Return<void> subscribeRequest(uint32_t cmd_id,
- const NanSubscribeRequest& msg,
- subscribeRequest_cb hidl_status_cb) override;
- Return<void> subscribeCancelRequest(
- uint32_t cmd_id,
- const NanSubscribeCancelRequest& msg,
- subscribeCancelRequest_cb hidl_status_cb) override;
- Return<void> transmitFollowupRequest(
- uint32_t cmd_id,
- const NanTransmitFollowupRequest& msg,
- transmitFollowupRequest_cb hidl_status_cb) override;
- Return<void> configRequest(uint32_t cmd_id,
+ Return<void> configRequest(uint16_t cmd_id,
const NanConfigRequest& msg,
configRequest_cb hidl_status_cb) override;
- Return<void> beaconSdfPayloadRequest(
- uint32_t cmd_id,
- const NanBeaconSdfPayloadRequest& msg,
- beaconSdfPayloadRequest_cb hidl_status_cb) override;
- Return<void> getVersion(getVersion_cb hidl_status_cb) override;
- Return<void> getCapabilities(uint32_t cmd_id,
- getCapabilities_cb hidl_status_cb) override;
- Return<void> dataInterfaceCreate(
- uint32_t cmd_id,
- const hidl_string& iface_name,
- dataInterfaceCreate_cb hidl_status_cb) override;
- Return<void> dataInterfaceDelete(
- uint32_t cmd_id,
- const hidl_string& iface_name,
- dataInterfaceDelete_cb hidl_status_cb) override;
- Return<void> dataRequestInitiator(
- uint32_t cmd_id,
- const NanDataPathInitiatorRequest& msg,
- dataRequestInitiator_cb hidl_status_cb) override;
- Return<void> dataIndicationResponse(
- uint32_t cmd_id,
- const NanDataPathIndicationResponse& msg,
- dataIndicationResponse_cb hidl_status_cb) override;
- Return<void> dataEnd(uint32_t cmd_id,
- const NanDataPathEndRequest& msg,
- dataEnd_cb hidl_status_cb) override;
+ Return<void> disableRequest(uint16_t cmd_id,
+ disableRequest_cb hidl_status_cb) override;
+ Return<void> startPublishRequest(uint16_t cmd_id,
+ const NanPublishRequest& msg,
+ startPublishRequest_cb hidl_status_cb) override;
+ Return<void> stopPublishRequest(uint16_t cmd_id,
+ uint16_t sessionId,
+ stopPublishRequest_cb hidl_status_cb) override;
+ Return<void> startSubscribeRequest(uint16_t cmd_id,
+ const NanSubscribeRequest& msg,
+ startSubscribeRequest_cb hidl_status_cb) override;
+ Return<void> stopSubscribeRequest(uint16_t cmd_id,
+ uint16_t sessionId,
+ stopSubscribeRequest_cb hidl_status_cb) override;
+ Return<void> transmitFollowupRequest(uint16_t cmd_id,
+ const NanTransmitFollowupRequest& msg,
+ transmitFollowupRequest_cb hidl_status_cb) override;
+ Return<void> createDataInterfaceRequest(uint16_t cmd_id,
+ const hidl_string& iface_name,
+ createDataInterfaceRequest_cb hidl_status_cb) override;
+ Return<void> deleteDataInterfaceRequest(uint16_t cmd_id,
+ const hidl_string& iface_name,
+ deleteDataInterfaceRequest_cb hidl_status_cb) override;
+ Return<void> initiateDataPathRequest(uint16_t cmd_id,
+ const NanInitiateDataPathRequest& msg,
+ initiateDataPathRequest_cb hidl_status_cb) override;
+ Return<void> respondToDataPathIndicationRequest(
+ uint16_t cmd_id,
+ const NanRespondToDataPathIndicationRequest& msg,
+ respondToDataPathIndicationRequest_cb hidl_status_cb) override;
+ Return<void> terminateDataPathRequest(uint16_t cmd_id,
+ uint32_t ndpInstanceId,
+ terminateDataPathRequest_cb hidl_status_cb) override;
+ Return<void> beaconSdfPayloadRequest(uint16_t cmd_id,
+ const NanBeaconSdfPayloadRequest& msg,
+ beaconSdfPayloadRequest_cb hidl_status_cb) override;
private:
// Corresponding worker functions for the HIDL methods.
@@ -105,34 +97,32 @@
std::pair<WifiStatus, IfaceType> getTypeInternal();
WifiStatus registerEventCallbackInternal(
const sp<IWifiNanIfaceEventCallback>& callback);
- WifiStatus enableRequestInternal(uint32_t cmd_id,
+ WifiStatus getCapabilitiesRequestInternal(uint16_t cmd_id);
+ WifiStatus enableRequestInternal(uint16_t cmd_id,
const NanEnableRequest& msg);
- WifiStatus disableRequestInternal(uint32_t cmd_id);
- WifiStatus publishRequestInternal(uint32_t cmd_id,
- const NanPublishRequest& msg);
- WifiStatus publishCancelRequestInternal(uint32_t cmd_id,
- const NanPublishCancelRequest& msg);
- WifiStatus subscribeRequestInternal(uint32_t cmd_id,
- const NanSubscribeRequest& msg);
- WifiStatus subscribeCancelRequestInternal(
- uint32_t cmd_id, const NanSubscribeCancelRequest& msg);
- WifiStatus transmitFollowupRequestInternal(
- uint32_t cmd_id, const NanTransmitFollowupRequest& msg);
- WifiStatus configRequestInternal(uint32_t cmd_id,
+ WifiStatus configRequestInternal(uint16_t cmd_id,
const NanConfigRequest& msg);
+ WifiStatus disableRequestInternal(uint16_t cmd_id);
+ WifiStatus startPublishRequestInternal(uint16_t cmd_id,
+ const NanPublishRequest& msg);
+ WifiStatus stopPublishRequestInternal(uint16_t cmd_id, uint16_t sessionId);
+ WifiStatus startSubscribeRequestInternal(uint16_t cmd_id,
+ const NanSubscribeRequest& msg);
+ WifiStatus stopSubscribeRequestInternal(uint16_t cmd_id, uint16_t sessionId);
+ WifiStatus transmitFollowupRequestInternal(
+ uint16_t cmd_id, const NanTransmitFollowupRequest& msg);
+ WifiStatus createDataInterfaceRequestInternal(uint16_t cmd_id,
+ const std::string& iface_name);
+ WifiStatus deleteDataInterfaceRequestInternal(uint16_t cmd_id,
+ const std::string& iface_name);
+ WifiStatus initiateDataPathRequestInternal(
+ uint16_t cmd_id, const NanInitiateDataPathRequest& msg);
+ WifiStatus respondToDataPathIndicationRequestInternal(
+ uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg);
+ WifiStatus terminateDataPathRequestInternal(
+ uint16_t cmd_id, uint32_t ndpInstanceId);
WifiStatus beaconSdfPayloadRequestInternal(
- uint32_t cmd_id, const NanBeaconSdfPayloadRequest& msg);
- std::pair<WifiStatus, NanVersion> getVersionInternal();
- WifiStatus getCapabilitiesInternal(uint32_t cmd_id);
- WifiStatus dataInterfaceCreateInternal(uint32_t cmd_id,
- const std::string& iface_name);
- WifiStatus dataInterfaceDeleteInternal(uint32_t cmd_id,
- const std::string& iface_name);
- WifiStatus dataRequestInitiatorInternal(
- uint32_t cmd_id, const NanDataPathInitiatorRequest& msg);
- WifiStatus dataIndicationResponseInternal(
- uint32_t cmd_id, const NanDataPathIndicationResponse& msg);
- WifiStatus dataEndInternal(uint32_t cmd_id, const NanDataPathEndRequest& msg);
+ uint16_t cmd_id, const NanBeaconSdfPayloadRequest& msg);
std::string ifname_;
std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;