blob: 6ac06292e936d1984241e7aeba5738e1aa693614 [file] [log] [blame]
Roshan Pius59268282016-10-06 20:23:47 -07001/*
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
Roshan Pius59268282016-10-06 20:23:47 -070017#include <android-base/logging.h>
18
Roshan Pius907d4a22016-10-27 12:48:12 -070019#include "hidl_return_util.h"
20#include "wifi_rtt_controller.h"
Roshan Pius734fea02016-10-11 08:30:28 -070021#include "wifi_status_util.h"
Roshan Pius59268282016-10-06 20:23:47 -070022
23namespace android {
24namespace hardware {
25namespace wifi {
26namespace V1_0 {
27namespace implementation {
Roshan Pius907d4a22016-10-27 12:48:12 -070028using hidl_return_util::validateAndCall;
Roshan Pius59268282016-10-06 20:23:47 -070029
30WifiRttController::WifiRttController(
31 const sp<IWifiIface>& bound_iface,
Roshan Pius6cedc972016-10-28 10:11:17 -070032 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
Roshan Pius59268282016-10-06 20:23:47 -070033 : bound_iface_(bound_iface), legacy_hal_(legacy_hal), is_valid_(true) {}
34
35void WifiRttController::invalidate() {
36 legacy_hal_.reset();
Roshan Pius7913f5e2016-10-27 17:09:30 -070037 event_callbacks_.clear();
Roshan Pius59268282016-10-06 20:23:47 -070038 is_valid_ = false;
39}
40
Roshan Pius907d4a22016-10-27 12:48:12 -070041bool WifiRttController::isValid() {
42 return is_valid_;
43}
44
Roshan Pius734fea02016-10-11 08:30:28 -070045Return<void> WifiRttController::getBoundIface(getBoundIface_cb hidl_status_cb) {
Roshan Pius907d4a22016-10-27 12:48:12 -070046 return validateAndCall(this,
47 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
48 &WifiRttController::getBoundIfaceInternal,
49 hidl_status_cb);
50}
51
Roshan Pius7913f5e2016-10-27 17:09:30 -070052Return<void> WifiRttController::registerEventCallback(
53 const sp<IWifiRttControllerEventCallback>& callback,
54 registerEventCallback_cb hidl_status_cb) {
55 return validateAndCall(this,
56 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
57 &WifiRttController::registerEventCallbackInternal,
58 hidl_status_cb,
59 callback);
60}
61
62Return<void> WifiRttController::rangeRequest(
63 uint32_t cmd_id,
64 const hidl_vec<RttConfig>& rtt_configs,
65 rangeRequest_cb hidl_status_cb) {
66 return validateAndCall(this,
67 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
68 &WifiRttController::rangeRequestInternal,
69 hidl_status_cb,
70 cmd_id,
71 rtt_configs);
72}
73
74Return<void> WifiRttController::rangeCancel(
75 uint32_t cmd_id,
76 const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
77 rangeCancel_cb hidl_status_cb) {
78 return validateAndCall(this,
79 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
80 &WifiRttController::rangeCancelInternal,
81 hidl_status_cb,
82 cmd_id,
83 addrs);
84}
85
86Return<void> WifiRttController::setChannelMap(uint32_t cmd_id,
87 const RttChannelMap& params,
88 uint32_t num_dw,
89 setChannelMap_cb hidl_status_cb) {
90 return validateAndCall(this,
91 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
92 &WifiRttController::setChannelMapInternal,
93 hidl_status_cb,
94 cmd_id,
95 params,
96 num_dw);
97}
98
99Return<void> WifiRttController::clearChannelMap(
100 uint32_t cmd_id, clearChannelMap_cb hidl_status_cb) {
101 return validateAndCall(this,
102 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
103 &WifiRttController::clearChannelMapInternal,
104 hidl_status_cb,
105 cmd_id);
106}
107
108Return<void> WifiRttController::getCapabilities(
109 getCapabilities_cb hidl_status_cb) {
110 return validateAndCall(this,
111 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
112 &WifiRttController::getCapabilitiesInternal,
113 hidl_status_cb);
114}
115
116Return<void> WifiRttController::setDebugCfg(RttDebugType type,
117 setDebugCfg_cb hidl_status_cb) {
118 return validateAndCall(this,
119 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
120 &WifiRttController::setDebugCfgInternal,
121 hidl_status_cb,
122 type);
123}
124
125Return<void> WifiRttController::getDebugInfo(getDebugInfo_cb hidl_status_cb) {
126 return validateAndCall(this,
127 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
128 &WifiRttController::getDebugInfoInternal,
129 hidl_status_cb);
130}
131
132Return<void> WifiRttController::setLci(uint32_t cmd_id,
133 const RttLciInformation& lci,
134 setLci_cb hidl_status_cb) {
135 return validateAndCall(this,
136 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
137 &WifiRttController::setLciInternal,
138 hidl_status_cb,
139 cmd_id,
140 lci);
141}
142
143Return<void> WifiRttController::setLcr(uint32_t cmd_id,
144 const RttLcrInformation& lcr,
145 setLcr_cb hidl_status_cb) {
146 return validateAndCall(this,
147 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
148 &WifiRttController::setLcrInternal,
149 hidl_status_cb,
150 cmd_id,
151 lcr);
152}
153
154Return<void> WifiRttController::getResponderInfo(
155 getResponderInfo_cb hidl_status_cb) {
156 return validateAndCall(this,
157 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
158 &WifiRttController::getResponderInfoInternal,
159 hidl_status_cb);
160}
161
162Return<void> WifiRttController::enableResponder(
163 uint32_t cmd_id,
164 const WifiChannelInfo& channel_hint,
165 uint32_t maxDurationSeconds,
166 const RttResponder& info,
167 enableResponder_cb hidl_status_cb) {
168 return validateAndCall(this,
169 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
170 &WifiRttController::enableResponderInternal,
171 hidl_status_cb,
172 cmd_id,
173 channel_hint,
174 maxDurationSeconds,
175 info);
176}
177
178Return<void> WifiRttController::disableResponder(
179 uint32_t cmd_id, disableResponder_cb hidl_status_cb) {
180 return validateAndCall(this,
181 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
182 &WifiRttController::disableResponderInternal,
183 hidl_status_cb,
184 cmd_id);
185}
186
Roshan Pius907d4a22016-10-27 12:48:12 -0700187std::pair<WifiStatus, sp<IWifiIface>>
188WifiRttController::getBoundIfaceInternal() {
189 return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_};
Roshan Pius59268282016-10-06 20:23:47 -0700190}
191
Roshan Pius7913f5e2016-10-27 17:09:30 -0700192WifiStatus WifiRttController::registerEventCallbackInternal(
193 const sp<IWifiRttControllerEventCallback>& callback) {
194 // TODO(b/31632518): remove the callback when the client is destroyed
195 event_callbacks_.emplace_back(callback);
196 return createWifiStatus(WifiStatusCode::SUCCESS);
197}
198
199WifiStatus WifiRttController::rangeRequestInternal(
200 uint32_t /* cmd_id */, const std::vector<RttConfig>& /* rtt_configs */) {
201 // TODO implement
202 return createWifiStatus(WifiStatusCode::SUCCESS);
203}
204
205WifiStatus WifiRttController::rangeCancelInternal(
206 uint32_t /* cmd_id */,
207 const std::vector<hidl_array<uint8_t, 6>>& /* addrs */) {
208 // TODO implement
209 return createWifiStatus(WifiStatusCode::SUCCESS);
210}
211
212WifiStatus WifiRttController::setChannelMapInternal(
213 uint32_t /* cmd_id */,
214 const RttChannelMap& /* params */,
215 uint32_t /* num_dw */) {
216 // TODO implement
217 return createWifiStatus(WifiStatusCode::SUCCESS);
218}
219
220WifiStatus WifiRttController::clearChannelMapInternal(uint32_t /* cmd_id */) {
221 // TODO implement
222 return createWifiStatus(WifiStatusCode::SUCCESS);
223}
224
225std::pair<WifiStatus, RttCapabilities>
226WifiRttController::getCapabilitiesInternal() {
227 // TODO implement
228 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
229}
230
231WifiStatus WifiRttController::setDebugCfgInternal(RttDebugType /* type */) {
232 // TODO implement
233 return createWifiStatus(WifiStatusCode::SUCCESS);
234}
235
236std::pair<WifiStatus, RttDebugInfo> WifiRttController::getDebugInfoInternal() {
237 // TODO implement
238 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
239}
240
241WifiStatus WifiRttController::setLciInternal(
242 uint32_t /* cmd_id */, const RttLciInformation& /* lci */) {
243 // TODO implement
244 return createWifiStatus(WifiStatusCode::SUCCESS);
245}
246
247WifiStatus WifiRttController::setLcrInternal(
248 uint32_t /* cmd_id */, const RttLcrInformation& /* lcr */) {
249 // TODO implement
250 return createWifiStatus(WifiStatusCode::SUCCESS);
251}
252
253std::pair<WifiStatus, RttResponder>
254WifiRttController::getResponderInfoInternal() {
255 // TODO implement
256 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
257}
258
259WifiStatus WifiRttController::enableResponderInternal(
260 uint32_t /* cmd_id */,
261 const WifiChannelInfo& /* channel_hint */,
262 uint32_t /* maxDurationSeconds */,
263 const RttResponder& /* info */) {
264 // TODO implement
265 return createWifiStatus(WifiStatusCode::SUCCESS);
266}
267
268WifiStatus WifiRttController::disableResponderInternal(uint32_t /* cmd_id */) {
269 // TODO implement
270 return createWifiStatus(WifiStatusCode::SUCCESS);
271}
Roshan Pius59268282016-10-06 20:23:47 -0700272} // namespace implementation
273} // namespace V1_0
274} // namespace wifi
275} // namespace hardware
276} // namespace android