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

Commit c190f931 authored by Etan Cohen's avatar Etan Cohen
Browse files

[AWARE] Ranging as a service discovery constraint

Ranging configuration modification: change from an
overall Aware configuration (remove from Enable/Config
structures) to a discovery session-specific configuration.

Bug: 33821639
Test: integrated (sl4a) tests
Change-Id: Ie5a8bb3701a5dd6186c15d2be16bca3ec7202f04
parent 2bfad0cf
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -795,9 +795,6 @@ bool convertHidlNanEnableRequestToLegacy(
  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 = 1;
  if (hidl_request.configParams.bandSpecificConfig.size() != 2) {
    LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: bandSpecificConfig.size() != 2";
@@ -963,6 +960,9 @@ bool convertHidlNanPublishRequestToLegacy(
        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->ranging_auto_response = hidl_request.baseConfigs.rangingRequired ?
        legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
  legacy_request->range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
  legacy_request->publish_type = (legacy_hal::NanPublishType) hidl_request.publishType;
  legacy_request->tx_type = (legacy_hal::NanTxType) hidl_request.txType;

@@ -1042,6 +1042,9 @@ bool convertHidlNanSubscribeRequestToLegacy(
        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->ranging_auto_response = hidl_request.baseConfigs.rangingRequired ?
        legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
  legacy_request->range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
  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 ?
@@ -1123,9 +1126,6 @@ bool convertHidlNanConfigRequestToLegacy(
  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 = 1;
  legacy_request->rssi_close_2dot4g_val =
@@ -1314,8 +1314,8 @@ bool convertLegacyNanMatchIndToHidl(
        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;
  hidl_ind->rangingMeasurementInCm = legacy_ind.range_info.range_measurement_cm;
  hidl_ind->rangingIndicationType = legacy_ind.range_info.ranging_event_type;

  return true;
}
+27 −1
Original line number Diff line number Diff line
@@ -289,6 +289,24 @@ void onAysncNanEventTransmitFollowUp(NanTransmitFollowupInd* event) {
    on_nan_event_transmit_follow_up_user_callback(*event);
  }
}

std::function<void(const NanRangeRequestInd&)>
    on_nan_event_range_request_user_callback;
void onAysncNanEventRangeRequest(NanRangeRequestInd* event) {
  const auto lock = hidl_sync_util::acquireGlobalLock();
  if (on_nan_event_range_request_user_callback && event) {
    on_nan_event_range_request_user_callback(*event);
  }
}

std::function<void(const NanRangeReportInd&)>
    on_nan_event_range_report_user_callback;
void onAysncNanEventRangeReport(NanRangeReportInd* event) {
  const auto lock = hidl_sync_util::acquireGlobalLock();
  if (on_nan_event_range_report_user_callback && event) {
    on_nan_event_range_report_user_callback(*event);
  }
}
// End of the free-standing "C" style callbacks.

WifiLegacyHal::WifiLegacyHal()
@@ -1023,6 +1041,10 @@ wifi_error WifiLegacyHal::nanRegisterCallbackHandlers(
      user_callbacks.on_event_data_path_end;
  on_nan_event_transmit_follow_up_user_callback =
      user_callbacks.on_event_transmit_follow_up;
  on_nan_event_range_request_user_callback =
      user_callbacks.on_event_range_request;
  on_nan_event_range_report_user_callback =
      user_callbacks.on_event_range_report;

  return global_func_table_.wifi_nan_register_handler(
      wlan_interface_handle_,
@@ -1039,7 +1061,9 @@ wifi_error WifiLegacyHal::nanRegisterCallbackHandlers(
       onAysncNanEventDataPathRequest,
       onAysncNanEventDataPathConfirm,
       onAysncNanEventDataPathEnd,
       onAysncNanEventTransmitFollowUp});
       onAysncNanEventTransmitFollowUp,
       onAysncNanEventRangeRequest,
       onAysncNanEventRangeReport});
}

wifi_error WifiLegacyHal::nanEnableRequest(transaction_id id,
@@ -1261,6 +1285,8 @@ void WifiLegacyHal::invalidate() {
  on_nan_event_data_path_confirm_user_callback = nullptr;
  on_nan_event_data_path_end_user_callback = nullptr;
  on_nan_event_transmit_follow_up_user_callback = nullptr;
  on_nan_event_range_request_user_callback = nullptr;
  on_nan_event_range_report_user_callback = nullptr;
}

}  // namespace legacy_hal
+4 −0
Original line number Diff line number Diff line
@@ -89,6 +89,10 @@ struct NanCallbackHandlers {
  std::function<void(const NanDataPathEndInd&)> on_event_data_path_end;
  std::function<void(const NanTransmitFollowupInd&)>
      on_event_transmit_follow_up;
  std::function<void(const NanRangeRequestInd&)>
      on_event_range_request;
  std::function<void(const NanRangeReportInd&)>
      on_event_range_report;
};

// Full scan results contain IE info and are hence passed by reference, to
+10 −0
Original line number Diff line number Diff line
@@ -400,6 +400,16 @@ WifiNanIface::WifiNanIface(
      LOG(ERROR) << "on_event_beacon_sdf_payload - should not be called";
  };

  callback_handlers.on_event_range_request = [weak_ptr_this](
        const legacy_hal::NanRangeRequestInd& /* msg */) {
      LOG(ERROR) << "on_event_range_request - should not be called";
  };

  callback_handlers.on_event_range_report = [weak_ptr_this](
        const legacy_hal::NanRangeReportInd& /* msg */) {
      LOG(ERROR) << "on_event_range_report - should not be called";
  };

  legacy_hal::wifi_error legacy_status =
      legacy_hal_.lock()->nanRegisterCallbackHandlers(callback_handlers);
  if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+16 −6
Original line number Diff line number Diff line
@@ -843,11 +843,6 @@ struct NanConfigRequest {
   * A value of 0 is used to disable the MAC address randomization
   */
  uint32_t macAddressRandomizationIntervalSec;
  /**
   * Accept (if true) or not (if false) ranging requests from peers - whether in the context of
   * discovery or otherwise.
   */
  bool acceptRangingRequests;
  /**
   * Additional configuration provided per band: indexed by |NanBandIndex|.
   */
@@ -1014,7 +1009,22 @@ struct NanDiscoveryCommonConfig {
  bool securityEnabledInNdp;
  /**
   * Specifies whether or not there is a ranging requirement in this discovery session.
   * Note that ranging is only performed if all other match criteria with the peer are met.
   * Ranging is only performed if all other match criteria with the peer are met.
   * Note: specifying that ranging is required also implies that this device must automatically
   * accept ranging requests from peers.
   *   Solicited Publisher + Passive Subscriber:
   *     Publisher/Subscriber:
   *     true/true: ranging performed.
   *     true/false: subscriber doesn't require ranging (match if all other criteria met). I.e.
   *                 publisher requiring range doesn't gate subscriber matching.
   *     false/true: subscriber tries ranging but publisher refuses (no match).
   *     false/false: ranging isn't attempted and doesn't impact match.
   *   Unsolicited Publisher + Active Subscriber:
   *     Publisher/Subscriber:
   *     true/true: ranging performed.
   *     true/false: publisher attempts ranging but subscriber doesn't allow - no match.
   *     false/true: publisher doesn't attempt ranging, should not impact match.
   *     false/false: ranging isn't attempted and doesn't impact match.
   * NAN Spec: Service Discovery Extension Attribute (SDEA) / Control / Ranging Require.
   */
  bool rangingRequired;