blob: 1f220f3a29123d29b80d229c550f6aea8868e5cc [file] [log] [blame]
Roshan Pius3e2d6712016-10-06 13:16:23 -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 Pius3e2d6712016-10-06 13:16:23 -070017#include <android-base/logging.h>
18
Roshan Pius907d4a22016-10-27 12:48:12 -070019#include "hidl_return_util.h"
20#include "wifi_sta_iface.h"
Roshan Pius734fea02016-10-11 08:30:28 -070021#include "wifi_status_util.h"
Roshan Pius3e2d6712016-10-06 13:16:23 -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 Pius3e2d6712016-10-06 13:16:23 -070029
30WifiStaIface::WifiStaIface(const std::string& ifname,
31 const std::weak_ptr<WifiLegacyHal> legacy_hal)
32 : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
33
34void WifiStaIface::invalidate() {
35 legacy_hal_.reset();
Roshan Piusa04ba3f2016-10-27 14:36:26 -070036 event_callbacks_.clear();
Roshan Pius3e2d6712016-10-06 13:16:23 -070037 is_valid_ = false;
38}
39
Roshan Pius907d4a22016-10-27 12:48:12 -070040bool WifiStaIface::isValid() {
41 return is_valid_;
42}
43
Roshan Pius734fea02016-10-11 08:30:28 -070044Return<void> WifiStaIface::getName(getName_cb hidl_status_cb) {
Roshan Pius907d4a22016-10-27 12:48:12 -070045 return validateAndCall(this,
46 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
47 &WifiStaIface::getNameInternal,
48 hidl_status_cb);
Roshan Pius3e2d6712016-10-06 13:16:23 -070049}
50
Roshan Pius734fea02016-10-11 08:30:28 -070051Return<void> WifiStaIface::getType(getType_cb hidl_status_cb) {
Roshan Pius907d4a22016-10-27 12:48:12 -070052 return validateAndCall(this,
53 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
54 &WifiStaIface::getTypeInternal,
55 hidl_status_cb);
56}
57
Roshan Piusa04ba3f2016-10-27 14:36:26 -070058Return<void> WifiStaIface::registerEventCallback(
59 const sp<IWifiStaIfaceEventCallback>& callback,
60 registerEventCallback_cb hidl_status_cb) {
61 return validateAndCall(this,
62 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
63 &WifiStaIface::registerEventCallbackInternal,
64 hidl_status_cb,
65 callback);
66}
67
68Return<void> WifiStaIface::getCapabilities(getCapabilities_cb hidl_status_cb) {
69 return validateAndCall(this,
70 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
71 &WifiStaIface::getCapabilitiesInternal,
72 hidl_status_cb);
73}
74
75Return<void> WifiStaIface::getApfPacketFilterCapabilities(
76 getApfPacketFilterCapabilities_cb hidl_status_cb) {
77 return validateAndCall(this,
78 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
79 &WifiStaIface::getApfPacketFilterCapabilitiesInternal,
80 hidl_status_cb);
81}
82
83Return<void> WifiStaIface::installApfPacketFilter(
84 uint32_t cmd_id,
85 const hidl_vec<uint8_t>& program,
86 installApfPacketFilter_cb hidl_status_cb) {
87 return validateAndCall(this,
88 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
89 &WifiStaIface::installApfPacketFilterInternal,
90 hidl_status_cb,
91 cmd_id,
92 program);
93}
94
95Return<void> WifiStaIface::getBackgroundScanCapabilities(
96 getBackgroundScanCapabilities_cb hidl_status_cb) {
97 return validateAndCall(this,
98 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
99 &WifiStaIface::getBackgroundScanCapabilitiesInternal,
100 hidl_status_cb);
101}
102
103Return<void> WifiStaIface::getValidFrequenciesForBackgroundScan(
104 StaBackgroundScanBand band,
105 getValidFrequenciesForBackgroundScan_cb hidl_status_cb) {
106 return validateAndCall(
107 this,
108 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
109 &WifiStaIface::getValidFrequenciesForBackgroundScanInternal,
110 hidl_status_cb,
111 band);
112}
113
114Return<void> WifiStaIface::startBackgroundScan(
115 uint32_t cmd_id,
116 const StaBackgroundScanParameters& params,
117 startBackgroundScan_cb hidl_status_cb) {
118 return validateAndCall(this,
119 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
120 &WifiStaIface::startBackgroundScanInternal,
121 hidl_status_cb,
122 cmd_id,
123 params);
124}
125
126Return<void> WifiStaIface::stopBackgroundScan(
127 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) {
128 return validateAndCall(this,
129 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
130 &WifiStaIface::stopBackgroundScanInternal,
131 hidl_status_cb,
132 cmd_id);
133}
134
135Return<void> WifiStaIface::enableLinkLayerStatsCollection(
136 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) {
137 return validateAndCall(this,
138 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
139 &WifiStaIface::enableLinkLayerStatsCollectionInternal,
140 hidl_status_cb,
141 debug);
142}
143
144Return<void> WifiStaIface::disableLinkLayerStatsCollection(
145 disableLinkLayerStatsCollection_cb hidl_status_cb) {
146 return validateAndCall(this,
147 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
148 &WifiStaIface::disableLinkLayerStatsCollectionInternal,
149 hidl_status_cb);
150}
151
152Return<void> WifiStaIface::getLinkLayerStats(
153 getLinkLayerStats_cb hidl_status_cb) {
154 return validateAndCall(this,
155 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
156 &WifiStaIface::getLinkLayerStatsInternal,
157 hidl_status_cb);
158}
159
160Return<void> WifiStaIface::startDebugPacketFateMonitoring(
161 startDebugPacketFateMonitoring_cb hidl_status_cb) {
162 return validateAndCall(this,
163 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
164 &WifiStaIface::startDebugPacketFateMonitoringInternal,
165 hidl_status_cb);
166}
167
168Return<void> WifiStaIface::stopDebugPacketFateMonitoring(
169 stopDebugPacketFateMonitoring_cb hidl_status_cb) {
170 return validateAndCall(this,
171 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
172 &WifiStaIface::stopDebugPacketFateMonitoringInternal,
173 hidl_status_cb);
174}
175
176Return<void> WifiStaIface::getDebugTxPacketFates(
177 getDebugTxPacketFates_cb hidl_status_cb) {
178 return validateAndCall(this,
179 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
180 &WifiStaIface::getDebugTxPacketFatesInternal,
181 hidl_status_cb);
182}
183
184Return<void> WifiStaIface::getDebugRxPacketFates(
185 getDebugRxPacketFates_cb hidl_status_cb) {
186 return validateAndCall(this,
187 WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
188 &WifiStaIface::getDebugRxPacketFatesInternal,
189 hidl_status_cb);
190}
191
Roshan Pius907d4a22016-10-27 12:48:12 -0700192std::pair<WifiStatus, std::string> WifiStaIface::getNameInternal() {
193 return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
194}
195
196std::pair<WifiStatus, IfaceType> WifiStaIface::getTypeInternal() {
197 return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA};
Roshan Pius3e2d6712016-10-06 13:16:23 -0700198}
199
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700200WifiStatus WifiStaIface::registerEventCallbackInternal(
201 const sp<IWifiStaIfaceEventCallback>& callback) {
202 // TODO(b/31632518): remove the callback when the client is destroyed
203 event_callbacks_.emplace_back(callback);
204 return createWifiStatus(WifiStatusCode::SUCCESS);
205}
206
207std::pair<WifiStatus, uint32_t> WifiStaIface::getCapabilitiesInternal() {
208 // TODO implement
209 return {createWifiStatus(WifiStatusCode::SUCCESS), 0};
210}
211
212std::pair<WifiStatus, StaApfPacketFilterCapabilities>
213WifiStaIface::getApfPacketFilterCapabilitiesInternal() {
214 // TODO implement
215 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
216}
217
218WifiStatus WifiStaIface::installApfPacketFilterInternal(
219 uint32_t /* cmd_id */, const std::vector<uint8_t>& /* program */) {
220 // TODO implement
221 return createWifiStatus(WifiStatusCode::SUCCESS);
222}
223
224std::pair<WifiStatus, StaBackgroundScanCapabilities>
225WifiStaIface::getBackgroundScanCapabilitiesInternal() {
226 // TODO implement
227 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
228}
229
230std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
231WifiStaIface::getValidFrequenciesForBackgroundScanInternal(
232 StaBackgroundScanBand /* band */) {
233 // TODO implement
234 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
235}
236
237WifiStatus WifiStaIface::startBackgroundScanInternal(
238 uint32_t /* cmd_id */, const StaBackgroundScanParameters& /* params */) {
239 // TODO implement
240 return createWifiStatus(WifiStatusCode::SUCCESS);
241}
242
243WifiStatus WifiStaIface::stopBackgroundScanInternal(uint32_t /* cmd_id */) {
244 // TODO implement
245 return createWifiStatus(WifiStatusCode::SUCCESS);
246}
247
248WifiStatus WifiStaIface::enableLinkLayerStatsCollectionInternal(
249 bool /* debug */) {
250 // TODO implement
251 return createWifiStatus(WifiStatusCode::SUCCESS);
252}
253
254WifiStatus WifiStaIface::disableLinkLayerStatsCollectionInternal() {
255 // TODO implement
256 return createWifiStatus(WifiStatusCode::SUCCESS);
257}
258
259std::pair<WifiStatus, StaLinkLayerStats>
260WifiStaIface::getLinkLayerStatsInternal() {
261 // TODO implement
262 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
263}
264
265WifiStatus WifiStaIface::startDebugPacketFateMonitoringInternal() {
266 // TODO implement
267 return createWifiStatus(WifiStatusCode::SUCCESS);
268}
269
270WifiStatus WifiStaIface::stopDebugPacketFateMonitoringInternal() {
271 // TODO implement
272 return createWifiStatus(WifiStatusCode::SUCCESS);
273}
274
275std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
276WifiStaIface::getDebugTxPacketFatesInternal() {
277 // TODO implement
278 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
279}
280
281std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
282WifiStaIface::getDebugRxPacketFatesInternal() {
283 // TODO implement
284 return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
285}
286
Roshan Pius3e2d6712016-10-06 13:16:23 -0700287} // namespace implementation
288} // namespace V1_0
289} // namespace wifi
290} // namespace hardware
291} // namespace android