blob: fd5f68b6a8f66d4859fa7e0d90771c6ee6330958 [file] [log] [blame]
Ahmed ElArabawy687ce132022-01-11 16:42:48 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef WIFI_RTT_CONTROLLER_H_
18#define WIFI_RTT_CONTROLLER_H_
19
20#include <android-base/macros.h>
21#include <android/hardware/wifi/1.0/IWifiIface.h>
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080022#include <android/hardware/wifi/1.6/IWifiRttController.h>
23#include <android/hardware/wifi/1.6/IWifiRttControllerEventCallback.h>
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080024
25#include "wifi_legacy_hal.h"
26
27namespace android {
28namespace hardware {
29namespace wifi {
30namespace V1_6 {
31namespace implementation {
32
33/**
34 * HIDL interface object used to control all RTT operations.
35 */
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080036class WifiRttController : public V1_6::IWifiRttController {
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080037 public:
38 WifiRttController(const std::string& iface_name, const sp<IWifiIface>& bound_iface,
39 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
40 // Refer to |WifiChip::invalidate()|.
41 void invalidate();
42 bool isValid();
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080043 std::vector<sp<V1_6::IWifiRttControllerEventCallback>> getEventCallbacks();
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080044 std::string getIfaceName();
45
46 // HIDL methods exposed.
47 Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
48 Return<void> registerEventCallback(const sp<V1_0::IWifiRttControllerEventCallback>& callback,
49 registerEventCallback_cb hidl_status_cb) override;
50 Return<void> rangeRequest(uint32_t cmd_id, const hidl_vec<V1_0::RttConfig>& rtt_configs,
51 rangeRequest_cb hidl_status_cb) override;
52 Return<void> rangeCancel(uint32_t cmd_id, const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
53 rangeCancel_cb hidl_status_cb) override;
54 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
55 Return<void> setLci(uint32_t cmd_id, const RttLciInformation& lci,
56 setLci_cb hidl_status_cb) override;
57 Return<void> setLcr(uint32_t cmd_id, const RttLcrInformation& lcr,
58 setLcr_cb hidl_status_cb) override;
59 Return<void> getResponderInfo(getResponderInfo_cb hidl_status_cb) override;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080060 Return<void> enableResponder(uint32_t cmd_id, const V1_0::WifiChannelInfo& channel_hint,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080061 uint32_t max_duration_seconds, const V1_0::RttResponder& info,
62 enableResponder_cb hidl_status_cb) override;
63 Return<void> disableResponder(uint32_t cmd_id, disableResponder_cb hidl_status_cb) override;
64 Return<void> registerEventCallback_1_4(
65 const sp<V1_4::IWifiRttControllerEventCallback>& callback,
66 registerEventCallback_1_4_cb hidl_status_cb) override;
67 Return<void> rangeRequest_1_4(uint32_t cmd_id, const hidl_vec<V1_4::RttConfig>& rtt_configs,
68 rangeRequest_1_4_cb hidl_status_cb) override;
69 Return<void> getCapabilities_1_4(getCapabilities_1_4_cb hidl_status_cb) override;
70 Return<void> getResponderInfo_1_4(getResponderInfo_1_4_cb hidl_status_cb) override;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080071 Return<void> enableResponder_1_4(uint32_t cmd_id, const V1_0::WifiChannelInfo& channel_hint,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080072 uint32_t max_duration_seconds, const V1_4::RttResponder& info,
73 enableResponder_1_4_cb hidl_status_cb) override;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080074 Return<void> registerEventCallback_1_6(
75 const sp<V1_6::IWifiRttControllerEventCallback>& callback,
76 registerEventCallback_1_6_cb hidl_status_cb) override;
77 Return<void> rangeRequest_1_6(uint32_t cmd_id, const hidl_vec<V1_6::RttConfig>& rtt_configs,
78 rangeRequest_1_6_cb hidl_status_cb) override;
79 Return<void> getCapabilities_1_6(getCapabilities_1_6_cb hidl_status_cb) override;
80 Return<void> getResponderInfo_1_6(getResponderInfo_1_6_cb hidl_status_cb) override;
81 Return<void> enableResponder_1_6(uint32_t cmd_id, const V1_6::WifiChannelInfo& channel_hint,
82 uint32_t max_duration_seconds, const V1_6::RttResponder& info,
83 enableResponder_1_6_cb hidl_status_cb) override;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080084
85 private:
86 // Corresponding worker functions for the HIDL methods.
87 std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
88 WifiStatus registerEventCallbackInternal(
89 const sp<V1_0::IWifiRttControllerEventCallback>& callback);
90 WifiStatus rangeRequestInternal(uint32_t cmd_id,
91 const std::vector<V1_0::RttConfig>& rtt_configs);
92 WifiStatus rangeCancelInternal(uint32_t cmd_id,
93 const std::vector<hidl_array<uint8_t, 6>>& addrs);
94 std::pair<WifiStatus, V1_0::RttCapabilities> getCapabilitiesInternal();
95 WifiStatus setLciInternal(uint32_t cmd_id, const RttLciInformation& lci);
96 WifiStatus setLcrInternal(uint32_t cmd_id, const RttLcrInformation& lcr);
97 std::pair<WifiStatus, V1_0::RttResponder> getResponderInfoInternal();
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080098 WifiStatus enableResponderInternal(uint32_t cmd_id, const V1_0::WifiChannelInfo& channel_hint,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080099 uint32_t max_duration_seconds,
100 const V1_0::RttResponder& info);
101 WifiStatus disableResponderInternal(uint32_t cmd_id);
102 WifiStatus registerEventCallbackInternal_1_4(
103 const sp<V1_4::IWifiRttControllerEventCallback>& callback);
104 WifiStatus rangeRequestInternal_1_4(uint32_t cmd_id,
105 const std::vector<V1_4::RttConfig>& rtt_configs);
106 std::pair<WifiStatus, V1_4::RttCapabilities> getCapabilitiesInternal_1_4();
107 std::pair<WifiStatus, V1_4::RttResponder> getResponderInfoInternal_1_4();
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800108 WifiStatus enableResponderInternal_1_4(uint32_t cmd_id,
109 const V1_0::WifiChannelInfo& channel_hint,
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800110 uint32_t max_duration_seconds,
111 const V1_4::RttResponder& info);
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800112 WifiStatus registerEventCallbackInternal_1_6(
113 const sp<V1_6::IWifiRttControllerEventCallback>& callback);
114 WifiStatus rangeRequestInternal_1_6(uint32_t cmd_id,
115 const std::vector<V1_6::RttConfig>& rtt_configs);
116 std::pair<WifiStatus, V1_6::RttCapabilities> getCapabilitiesInternal_1_6();
117 std::pair<WifiStatus, V1_6::RttResponder> getResponderInfoInternal_1_6();
118 WifiStatus enableResponderInternal_1_6(uint32_t cmd_id,
119 const V1_6::WifiChannelInfo& channel_hint,
120 uint32_t max_duration_seconds,
121 const V1_6::RttResponder& info);
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800122
123 std::string ifname_;
124 sp<IWifiIface> bound_iface_;
125 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800126 std::vector<sp<V1_6::IWifiRttControllerEventCallback>> event_callbacks_;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800127 bool is_valid_;
128
129 DISALLOW_COPY_AND_ASSIGN(WifiRttController);
130};
131
132} // namespace implementation
133} // namespace V1_6
134} // namespace wifi
135} // namespace hardware
136} // namespace android
137
138#endif // WIFI_RTT_CONTROLLER_H_