blob: ac8ac95f46fe66429153dcaf64711dfdad7a0c02 [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
Roshan Pius7913f5e2016-10-27 17:09:30 -070086Return<void> WifiRttController::getCapabilities(
87 getCapabilities_cb hidl_status_cb) {
88 return validateAndCall(this,
89 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
90 &WifiRttController::getCapabilitiesInternal,
91 hidl_status_cb);
92}
93
Roshan Pius7913f5e2016-10-27 17:09:30 -070094Return<void> WifiRttController::setLci(uint32_t cmd_id,
95 const RttLciInformation& lci,
96 setLci_cb hidl_status_cb) {
97 return validateAndCall(this,
98 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
99 &WifiRttController::setLciInternal,
100 hidl_status_cb,
101 cmd_id,
102 lci);
103}
104
105Return<void> WifiRttController::setLcr(uint32_t cmd_id,
106 const RttLcrInformation& lcr,
107 setLcr_cb hidl_status_cb) {
108 return validateAndCall(this,
109 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
110 &WifiRttController::setLcrInternal,
111 hidl_status_cb,
112 cmd_id,
113 lcr);
114}
115
116Return<void> WifiRttController::getResponderInfo(
117 getResponderInfo_cb hidl_status_cb) {
118 return validateAndCall(this,
119 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
120 &WifiRttController::getResponderInfoInternal,
121 hidl_status_cb);
122}
123
124Return<void> WifiRttController::enableResponder(
125 uint32_t cmd_id,
126 const WifiChannelInfo& channel_hint,
127 uint32_t maxDurationSeconds,
128 const RttResponder& info,
129 enableResponder_cb hidl_status_cb) {
130 return validateAndCall(this,
131 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
132 &WifiRttController::enableResponderInternal,
133 hidl_status_cb,
134 cmd_id,
135 channel_hint,
136 maxDurationSeconds,
137 info);
138}
139
140Return<void> WifiRttController::disableResponder(
141 uint32_t cmd_id, disableResponder_cb hidl_status_cb) {
142 return validateAndCall(this,
143 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
144 &WifiRttController::disableResponderInternal,
145 hidl_status_cb,
146 cmd_id);
147}
148
Roshan Pius907d4a22016-10-27 12:48:12 -0700149std::pair<WifiStatus, sp<IWifiIface>>
150WifiRttController::getBoundIfaceInternal() {
151 return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_};
Roshan Pius59268282016-10-06 20:23:47 -0700152}
153
Roshan Pius7913f5e2016-10-27 17:09:30 -0700154WifiStatus WifiRttController::registerEventCallbackInternal(
155 const sp<IWifiRttControllerEventCallback>& callback) {
156 // TODO(b/31632518): remove the callback when the client is destroyed
157 event_callbacks_.emplace_back(callback);
158 return createWifiStatus(WifiStatusCode::SUCCESS);
159}
160
161WifiStatus WifiRttController::rangeRequestInternal(
162 uint32_t /* cmd_id */, const std::vector<RttConfig>& /* rtt_configs */) {
163 // TODO implement
164 return createWifiStatus(WifiStatusCode::SUCCESS);
165}
166
167WifiStatus WifiRttController::rangeCancelInternal(
168 uint32_t /* cmd_id */,
169 const std::vector<hidl_array<uint8_t, 6>>& /* addrs */) {
170 // TODO implement
171 return createWifiStatus(WifiStatusCode::SUCCESS);
172}
173
Roshan Pius7913f5e2016-10-27 17:09:30 -0700174std::pair<WifiStatus, RttCapabilities>
175WifiRttController::getCapabilitiesInternal() {
176 // TODO implement
177 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
178}
179
Roshan Pius7913f5e2016-10-27 17:09:30 -0700180WifiStatus WifiRttController::setLciInternal(
181 uint32_t /* cmd_id */, const RttLciInformation& /* lci */) {
182 // TODO implement
183 return createWifiStatus(WifiStatusCode::SUCCESS);
184}
185
186WifiStatus WifiRttController::setLcrInternal(
187 uint32_t /* cmd_id */, const RttLcrInformation& /* lcr */) {
188 // TODO implement
189 return createWifiStatus(WifiStatusCode::SUCCESS);
190}
191
192std::pair<WifiStatus, RttResponder>
193WifiRttController::getResponderInfoInternal() {
194 // TODO implement
195 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
196}
197
198WifiStatus WifiRttController::enableResponderInternal(
199 uint32_t /* cmd_id */,
200 const WifiChannelInfo& /* channel_hint */,
201 uint32_t /* maxDurationSeconds */,
202 const RttResponder& /* info */) {
203 // TODO implement
204 return createWifiStatus(WifiStatusCode::SUCCESS);
205}
206
207WifiStatus WifiRttController::disableResponderInternal(uint32_t /* cmd_id */) {
208 // TODO implement
209 return createWifiStatus(WifiStatusCode::SUCCESS);
210}
Roshan Pius59268282016-10-06 20:23:47 -0700211} // namespace implementation
212} // namespace V1_0
213} // namespace wifi
214} // namespace hardware
215} // namespace android