Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 1 | /* |
| 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 Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 17 | #include <android-base/logging.h> |
| 18 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
| 20 | #include "wifi_nan_iface.h" |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 21 | #include "wifi_status_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace wifi { |
| 26 | namespace V1_0 { |
| 27 | namespace implementation { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 28 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 29 | |
| 30 | WifiNanIface::WifiNanIface(const std::string& ifname, |
| 31 | const std::weak_ptr<WifiLegacyHal> legacy_hal) |
| 32 | : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {} |
| 33 | |
| 34 | void WifiNanIface::invalidate() { |
| 35 | legacy_hal_.reset(); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame^] | 36 | event_callbacks_.clear(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 37 | is_valid_ = false; |
| 38 | } |
| 39 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 40 | bool WifiNanIface::isValid() { |
| 41 | return is_valid_; |
| 42 | } |
| 43 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 44 | Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 45 | return validateAndCall(this, |
| 46 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 47 | &WifiNanIface::getNameInternal, |
| 48 | hidl_status_cb); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame^] | 51 | Return<void> WifiNanIface::registerEventCallback( |
| 52 | const sp<IWifiNanIfaceEventCallback>& callback, |
| 53 | registerEventCallback_cb hidl_status_cb) { |
| 54 | return validateAndCall(this, |
| 55 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 56 | &WifiNanIface::registerEventCallbackInternal, |
| 57 | hidl_status_cb, |
| 58 | callback); |
| 59 | } |
| 60 | |
| 61 | Return<void> WifiNanIface::enableRequest(uint32_t cmd_id, |
| 62 | const NanEnableRequest& msg, |
| 63 | enableRequest_cb hidl_status_cb) { |
| 64 | return validateAndCall(this, |
| 65 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 66 | &WifiNanIface::enableRequestInternal, |
| 67 | hidl_status_cb, |
| 68 | cmd_id, |
| 69 | msg); |
| 70 | } |
| 71 | |
| 72 | Return<void> WifiNanIface::disableRequest(uint32_t cmd_id, |
| 73 | disableRequest_cb hidl_status_cb) { |
| 74 | return validateAndCall(this, |
| 75 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 76 | &WifiNanIface::disableRequestInternal, |
| 77 | hidl_status_cb, |
| 78 | cmd_id); |
| 79 | } |
| 80 | |
| 81 | Return<void> WifiNanIface::publishRequest(uint32_t cmd_id, |
| 82 | const NanPublishRequest& msg, |
| 83 | publishRequest_cb hidl_status_cb) { |
| 84 | return validateAndCall(this, |
| 85 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 86 | &WifiNanIface::publishRequestInternal, |
| 87 | hidl_status_cb, |
| 88 | cmd_id, |
| 89 | msg); |
| 90 | } |
| 91 | |
| 92 | Return<void> WifiNanIface::publishCancelRequest( |
| 93 | uint32_t cmd_id, |
| 94 | const NanPublishCancelRequest& msg, |
| 95 | publishCancelRequest_cb hidl_status_cb) { |
| 96 | return validateAndCall(this, |
| 97 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 98 | &WifiNanIface::publishCancelRequestInternal, |
| 99 | hidl_status_cb, |
| 100 | cmd_id, |
| 101 | msg); |
| 102 | } |
| 103 | |
| 104 | Return<void> WifiNanIface::subscribeRequest( |
| 105 | uint32_t cmd_id, |
| 106 | const NanSubscribeRequest& msg, |
| 107 | subscribeRequest_cb hidl_status_cb) { |
| 108 | return validateAndCall(this, |
| 109 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 110 | &WifiNanIface::subscribeRequestInternal, |
| 111 | hidl_status_cb, |
| 112 | cmd_id, |
| 113 | msg); |
| 114 | } |
| 115 | |
| 116 | Return<void> WifiNanIface::subscribeCancelRequest( |
| 117 | uint32_t cmd_id, |
| 118 | const NanSubscribeCancelRequest& msg, |
| 119 | subscribeCancelRequest_cb hidl_status_cb) { |
| 120 | return validateAndCall(this, |
| 121 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 122 | &WifiNanIface::subscribeCancelRequestInternal, |
| 123 | hidl_status_cb, |
| 124 | cmd_id, |
| 125 | msg); |
| 126 | } |
| 127 | |
| 128 | Return<void> WifiNanIface::transmitFollowupRequest( |
| 129 | uint32_t cmd_id, |
| 130 | const NanTransmitFollowupRequest& msg, |
| 131 | transmitFollowupRequest_cb hidl_status_cb) { |
| 132 | return validateAndCall(this, |
| 133 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 134 | &WifiNanIface::transmitFollowupRequestInternal, |
| 135 | hidl_status_cb, |
| 136 | cmd_id, |
| 137 | msg); |
| 138 | } |
| 139 | |
| 140 | Return<void> WifiNanIface::configRequest(uint32_t cmd_id, |
| 141 | const NanConfigRequest& msg, |
| 142 | configRequest_cb hidl_status_cb) { |
| 143 | return validateAndCall(this, |
| 144 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 145 | &WifiNanIface::configRequestInternal, |
| 146 | hidl_status_cb, |
| 147 | cmd_id, |
| 148 | msg); |
| 149 | } |
| 150 | |
| 151 | Return<void> WifiNanIface::beaconSdfPayloadRequest( |
| 152 | uint32_t cmd_id, |
| 153 | const NanBeaconSdfPayloadRequest& msg, |
| 154 | beaconSdfPayloadRequest_cb hidl_status_cb) { |
| 155 | return validateAndCall(this, |
| 156 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 157 | &WifiNanIface::beaconSdfPayloadRequestInternal, |
| 158 | hidl_status_cb, |
| 159 | cmd_id, |
| 160 | msg); |
| 161 | } |
| 162 | |
| 163 | Return<void> WifiNanIface::getVersion(getVersion_cb hidl_status_cb) { |
| 164 | return validateAndCall(this, |
| 165 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 166 | &WifiNanIface::getVersionInternal, |
| 167 | hidl_status_cb); |
| 168 | } |
| 169 | |
| 170 | Return<void> WifiNanIface::getCapabilities(uint32_t cmd_id, |
| 171 | getCapabilities_cb hidl_status_cb) { |
| 172 | return validateAndCall(this, |
| 173 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 174 | &WifiNanIface::getCapabilitiesInternal, |
| 175 | hidl_status_cb, |
| 176 | cmd_id); |
| 177 | } |
| 178 | |
| 179 | Return<void> WifiNanIface::dataInterfaceCreate( |
| 180 | uint32_t cmd_id, |
| 181 | const hidl_string& iface_name, |
| 182 | dataInterfaceCreate_cb hidl_status_cb) { |
| 183 | return validateAndCall(this, |
| 184 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 185 | &WifiNanIface::dataInterfaceCreateInternal, |
| 186 | hidl_status_cb, |
| 187 | cmd_id, |
| 188 | iface_name); |
| 189 | } |
| 190 | |
| 191 | Return<void> WifiNanIface::dataInterfaceDelete( |
| 192 | uint32_t cmd_id, |
| 193 | const hidl_string& iface_name, |
| 194 | dataInterfaceDelete_cb hidl_status_cb) { |
| 195 | return validateAndCall(this, |
| 196 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 197 | &WifiNanIface::dataInterfaceDeleteInternal, |
| 198 | hidl_status_cb, |
| 199 | cmd_id, |
| 200 | iface_name); |
| 201 | } |
| 202 | |
| 203 | Return<void> WifiNanIface::dataRequestInitiator( |
| 204 | uint32_t cmd_id, |
| 205 | const NanDataPathInitiatorRequest& msg, |
| 206 | dataRequestInitiator_cb hidl_status_cb) { |
| 207 | return validateAndCall(this, |
| 208 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 209 | &WifiNanIface::dataRequestInitiatorInternal, |
| 210 | hidl_status_cb, |
| 211 | cmd_id, |
| 212 | msg); |
| 213 | } |
| 214 | |
| 215 | Return<void> WifiNanIface::dataIndicationResponse( |
| 216 | uint32_t cmd_id, |
| 217 | const NanDataPathIndicationResponse& msg, |
| 218 | dataIndicationResponse_cb hidl_status_cb) { |
| 219 | return validateAndCall(this, |
| 220 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 221 | &WifiNanIface::dataIndicationResponseInternal, |
| 222 | hidl_status_cb, |
| 223 | cmd_id, |
| 224 | msg); |
| 225 | } |
| 226 | |
| 227 | Return<void> WifiNanIface::dataEnd(uint32_t cmd_id, |
| 228 | const NanDataPathEndRequest& msg, |
| 229 | dataEnd_cb hidl_status_cb) { |
| 230 | return validateAndCall(this, |
| 231 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 232 | &WifiNanIface::dataEndInternal, |
| 233 | hidl_status_cb, |
| 234 | cmd_id, |
| 235 | msg); |
| 236 | } |
| 237 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 238 | Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 239 | return validateAndCall(this, |
| 240 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 241 | &WifiNanIface::getTypeInternal, |
| 242 | hidl_status_cb); |
| 243 | } |
| 244 | |
| 245 | std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() { |
| 246 | return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; |
| 247 | } |
| 248 | |
| 249 | std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() { |
| 250 | return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN}; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame^] | 253 | WifiStatus WifiNanIface::registerEventCallbackInternal( |
| 254 | const sp<IWifiNanIfaceEventCallback>& callback) { |
| 255 | // TODO(b/31632518): remove the callback when the client is destroyed |
| 256 | event_callbacks_.emplace_back(callback); |
| 257 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 258 | } |
| 259 | |
| 260 | WifiStatus WifiNanIface::enableRequestInternal( |
| 261 | uint32_t /* cmd_id */, const NanEnableRequest& /* msg */) { |
| 262 | // TODO implement |
| 263 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 264 | } |
| 265 | |
| 266 | WifiStatus WifiNanIface::disableRequestInternal(uint32_t /* cmd_id */) { |
| 267 | // TODO implement |
| 268 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 269 | } |
| 270 | |
| 271 | WifiStatus WifiNanIface::publishRequestInternal( |
| 272 | uint32_t /* cmd_id */, const NanPublishRequest& /* msg */) { |
| 273 | // TODO implement |
| 274 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 275 | } |
| 276 | |
| 277 | WifiStatus WifiNanIface::publishCancelRequestInternal( |
| 278 | uint32_t /* cmd_id */, const NanPublishCancelRequest& /* msg */) { |
| 279 | // TODO implement |
| 280 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 281 | } |
| 282 | WifiStatus WifiNanIface::subscribeRequestInternal( |
| 283 | uint32_t /* cmd_id */, const NanSubscribeRequest& /* msg */) { |
| 284 | // TODO implement |
| 285 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 286 | } |
| 287 | WifiStatus WifiNanIface::subscribeCancelRequestInternal( |
| 288 | uint32_t /* cmd_id */, const NanSubscribeCancelRequest& /* msg */) { |
| 289 | // TODO implement |
| 290 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 291 | } |
| 292 | WifiStatus WifiNanIface::transmitFollowupRequestInternal( |
| 293 | uint32_t /* cmd_id */, const NanTransmitFollowupRequest& /* msg */) { |
| 294 | // TODO implement |
| 295 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 296 | } |
| 297 | WifiStatus WifiNanIface::configRequestInternal( |
| 298 | uint32_t /* cmd_id */, const NanConfigRequest& /* msg */) { |
| 299 | // TODO implement |
| 300 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 301 | } |
| 302 | WifiStatus WifiNanIface::beaconSdfPayloadRequestInternal( |
| 303 | uint32_t /* cmd_id */, const NanBeaconSdfPayloadRequest& /* msg */) { |
| 304 | // TODO implement |
| 305 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 306 | } |
| 307 | std::pair<WifiStatus, NanVersion> WifiNanIface::getVersionInternal() { |
| 308 | // TODO implement |
| 309 | return {createWifiStatus(WifiStatusCode::SUCCESS), 0}; |
| 310 | } |
| 311 | WifiStatus WifiNanIface::getCapabilitiesInternal(uint32_t /* cmd_id */) { |
| 312 | // TODO implement |
| 313 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 314 | } |
| 315 | WifiStatus WifiNanIface::dataInterfaceCreateInternal( |
| 316 | uint32_t /* cmd_id */, const std::string& /* iface_name */) { |
| 317 | // TODO implement |
| 318 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 319 | } |
| 320 | WifiStatus WifiNanIface::dataInterfaceDeleteInternal( |
| 321 | uint32_t /* cmd_id */, const std::string& /* iface_name */) { |
| 322 | // TODO implement |
| 323 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 324 | } |
| 325 | WifiStatus WifiNanIface::dataRequestInitiatorInternal( |
| 326 | uint32_t /* cmd_id */, const NanDataPathInitiatorRequest& /* msg */) { |
| 327 | // TODO implement |
| 328 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 329 | } |
| 330 | WifiStatus WifiNanIface::dataIndicationResponseInternal( |
| 331 | uint32_t /* cmd_id */, const NanDataPathIndicationResponse& /* msg */) { |
| 332 | // TODO implement |
| 333 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 334 | } |
| 335 | WifiStatus WifiNanIface::dataEndInternal( |
| 336 | uint32_t /* cmd_id */, const NanDataPathEndRequest& /* msg */) { |
| 337 | // TODO implement |
| 338 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 339 | } |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 340 | } // namespace implementation |
| 341 | } // namespace V1_0 |
| 342 | } // namespace wifi |
| 343 | } // namespace hardware |
| 344 | } // namespace android |