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" |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 20 | #include "hidl_struct_util.h" |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 21 | #include "wifi_nan_iface.h" |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 22 | #include "wifi_status_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace wifi { |
| 27 | namespace V1_0 { |
| 28 | namespace implementation { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 29 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 30 | |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 31 | WifiNanIface::WifiNanIface( |
| 32 | const std::string& ifname, |
| 33 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 34 | : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) { |
| 35 | // Register all the callbacks here. these should be valid for the lifetime |
| 36 | // of the object. Whenever the mode changes legacy HAL will remove |
| 37 | // all of these callbacks. |
| 38 | legacy_hal::NanCallbackHandlers callback_handlers; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 39 | android::wp<WifiNanIface> weak_ptr_this(this); |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 40 | |
| 41 | // Callback for response. |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 42 | callback_handlers.on_notify_response = [weak_ptr_this]( |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 43 | legacy_hal::transaction_id id, const legacy_hal::NanResponseMsg& msg) { |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 44 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 45 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 46 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 47 | return; |
| 48 | } |
| 49 | WifiNanStatus wifiNanStatus; |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 50 | if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl(msg, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 51 | &wifiNanStatus)) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 52 | LOG(ERROR) << "Failed to convert nan response header"; |
| 53 | return; |
| 54 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 55 | |
| 56 | switch (msg.response_type) { |
| 57 | case legacy_hal::NAN_RESPONSE_ENABLED: { |
| 58 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 59 | if (!callback->notifyEnableResponse(id, wifiNanStatus).isOk()) { |
| 60 | LOG(ERROR) << "Failed to invoke the callback"; |
| 61 | } |
| 62 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 63 | break; |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 64 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 65 | case legacy_hal::NAN_RESPONSE_DISABLED: { |
| 66 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 67 | if (!callback->notifyDisableResponse(id, wifiNanStatus).isOk()) { |
| 68 | LOG(ERROR) << "Failed to invoke the callback"; |
| 69 | } |
| 70 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 71 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 72 | } |
| 73 | case legacy_hal::NAN_RESPONSE_PUBLISH: { |
| 74 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 75 | if (!callback->notifyStartPublishResponse(id, wifiNanStatus, |
| 76 | msg.body.publish_response.publish_id).isOk()) { |
| 77 | LOG(ERROR) << "Failed to invoke the callback"; |
| 78 | } |
| 79 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 80 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 81 | } |
| 82 | case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: { |
| 83 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 84 | if (!callback->notifyStopPublishResponse(id, wifiNanStatus).isOk()) { |
| 85 | LOG(ERROR) << "Failed to invoke the callback"; |
| 86 | } |
| 87 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 88 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 89 | } |
| 90 | case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: { |
| 91 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 92 | if (!callback->notifyTransmitFollowupResponse(id, wifiNanStatus).isOk()) { |
| 93 | LOG(ERROR) << "Failed to invoke the callback"; |
| 94 | } |
| 95 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 96 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 97 | } |
| 98 | case legacy_hal::NAN_RESPONSE_SUBSCRIBE: { |
| 99 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 100 | if (!callback->notifyStartSubscribeResponse(id, wifiNanStatus, |
| 101 | msg.body.subscribe_response.subscribe_id).isOk()) { |
| 102 | LOG(ERROR) << "Failed to invoke the callback"; |
| 103 | } |
| 104 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 105 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 106 | } |
| 107 | case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: { |
| 108 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 109 | if (!callback->notifyStopSubscribeResponse(id, wifiNanStatus).isOk()) { |
| 110 | LOG(ERROR) << "Failed to invoke the callback"; |
| 111 | } |
| 112 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 113 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 114 | } |
| 115 | case legacy_hal::NAN_RESPONSE_CONFIG: { |
| 116 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 117 | if (!callback->notifyConfigResponse(id, wifiNanStatus).isOk()) { |
| 118 | LOG(ERROR) << "Failed to invoke the callback"; |
| 119 | } |
| 120 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 121 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 122 | } |
| 123 | case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD: { |
| 124 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 125 | if (!callback->notifyBeaconSdfPayloadResponse(id, wifiNanStatus).isOk()) { |
| 126 | LOG(ERROR) << "Failed to invoke the callback"; |
| 127 | } |
| 128 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 129 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 130 | } |
| 131 | case legacy_hal::NAN_GET_CAPABILITIES: { |
| 132 | NanCapabilities hidl_struct; |
| 133 | if (!hidl_struct_util::convertLegacyNanCapabilitiesResponseToHidl( |
| 134 | msg.body.nan_capabilities, &hidl_struct)) { |
| 135 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 136 | return; |
| 137 | } |
| 138 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 139 | if (!callback->notifyCapabilitiesResponse(id, wifiNanStatus, |
| 140 | hidl_struct).isOk()) { |
| 141 | LOG(ERROR) << "Failed to invoke the callback"; |
| 142 | } |
| 143 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 144 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 145 | } |
| 146 | case legacy_hal::NAN_DP_INTERFACE_CREATE: { |
| 147 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 148 | if (!callback->notifyCreateDataInterfaceResponse(id, wifiNanStatus).isOk()) { |
| 149 | LOG(ERROR) << "Failed to invoke the callback"; |
| 150 | } |
| 151 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 152 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 153 | } |
| 154 | case legacy_hal::NAN_DP_INTERFACE_DELETE: { |
| 155 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 156 | if (!callback->notifyDeleteDataInterfaceResponse(id, wifiNanStatus).isOk()) { |
| 157 | LOG(ERROR) << "Failed to invoke the callback"; |
| 158 | } |
| 159 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 160 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 161 | } |
| 162 | case legacy_hal::NAN_DP_INITIATOR_RESPONSE: { |
| 163 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 164 | if (!callback->notifyInitiateDataPathResponse(id, wifiNanStatus, |
| 165 | msg.body.data_request_response.ndp_instance_id).isOk()) { |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 166 | LOG(ERROR) << "Failed to invoke the callback"; |
| 167 | } |
| 168 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 169 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 170 | } |
| 171 | case legacy_hal::NAN_DP_RESPONDER_RESPONSE: { |
| 172 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 173 | if (!callback->notifyRespondToDataPathIndicationResponse(id, wifiNanStatus).isOk()) { |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 174 | LOG(ERROR) << "Failed to invoke the callback"; |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | case legacy_hal::NAN_DP_END: { |
| 179 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 180 | if (!callback->notifyTerminateDataPathResponse(id, wifiNanStatus).isOk()) { |
| 181 | LOG(ERROR) << "Failed to invoke the callback"; |
| 182 | } |
| 183 | } |
Etan Cohen | 4bbc209 | 2017-01-30 13:28:37 -0800 | [diff] [blame^] | 184 | break; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 185 | } |
| 186 | case legacy_hal::NAN_RESPONSE_TCA: |
| 187 | /* fall through */ |
| 188 | case legacy_hal::NAN_RESPONSE_STATS: |
| 189 | /* fall through */ |
| 190 | case legacy_hal::NAN_RESPONSE_ERROR: |
| 191 | /* fall through */ |
| 192 | default: |
| 193 | LOG(ERROR) << "Unknown or unhandled response type: " << msg.response_type; |
| 194 | return; |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 195 | } |
| 196 | }; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 197 | |
| 198 | callback_handlers.on_event_disc_eng_event = [weak_ptr_this]( |
| 199 | const legacy_hal::NanDiscEngEventInd& msg) { |
| 200 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 201 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 202 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 203 | return; |
| 204 | } |
| 205 | NanClusterEventInd hidl_struct; |
| 206 | // event types defined identically - hence can be cast |
| 207 | hidl_struct.eventType = (NanClusterEventType) msg.event_type; |
| 208 | hidl_struct.addr = msg.data.mac_addr.addr; |
| 209 | |
| 210 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 211 | if (!callback->eventClusterEvent(hidl_struct).isOk()) { |
| 212 | LOG(ERROR) << "Failed to invoke the callback"; |
| 213 | } |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | callback_handlers.on_event_disabled = [weak_ptr_this]( |
| 218 | const legacy_hal::NanDisabledInd& msg) { |
| 219 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 220 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 221 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 222 | return; |
| 223 | } |
| 224 | WifiNanStatus status; |
| 225 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 226 | status.description = msg.nan_reason; |
| 227 | |
| 228 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 229 | if (!callback->eventDisabled(status).isOk()) { |
| 230 | LOG(ERROR) << "Failed to invoke the callback"; |
| 231 | } |
| 232 | } |
| 233 | }; |
| 234 | |
| 235 | callback_handlers.on_event_publish_terminated = [weak_ptr_this]( |
| 236 | const legacy_hal::NanPublishTerminatedInd& msg) { |
| 237 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 238 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 239 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 240 | return; |
| 241 | } |
| 242 | WifiNanStatus status; |
| 243 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 244 | status.description = msg.nan_reason; |
| 245 | |
| 246 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 247 | if (!callback->eventPublishTerminated(msg.publish_id, status).isOk()) { |
| 248 | LOG(ERROR) << "Failed to invoke the callback"; |
| 249 | } |
| 250 | } |
| 251 | }; |
| 252 | |
| 253 | callback_handlers.on_event_subscribe_terminated = [weak_ptr_this]( |
| 254 | const legacy_hal::NanSubscribeTerminatedInd& msg) { |
| 255 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 256 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 257 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 258 | return; |
| 259 | } |
| 260 | WifiNanStatus status; |
| 261 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 262 | status.description = msg.nan_reason; |
| 263 | |
| 264 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 265 | if (!callback->eventSubscribeTerminated(msg.subscribe_id, status).isOk()) { |
| 266 | LOG(ERROR) << "Failed to invoke the callback"; |
| 267 | } |
| 268 | } |
| 269 | }; |
| 270 | |
| 271 | callback_handlers.on_event_match = [weak_ptr_this]( |
| 272 | const legacy_hal::NanMatchInd& msg) { |
| 273 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 274 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 275 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 276 | return; |
| 277 | } |
| 278 | NanMatchInd hidl_struct; |
| 279 | if (!hidl_struct_util::convertLegacyNanMatchIndToHidl( |
| 280 | msg, &hidl_struct)) { |
| 281 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 282 | return; |
| 283 | } |
| 284 | |
| 285 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 286 | if (!callback->eventMatch(hidl_struct).isOk()) { |
| 287 | LOG(ERROR) << "Failed to invoke the callback"; |
| 288 | } |
| 289 | } |
| 290 | }; |
| 291 | |
| 292 | callback_handlers.on_event_match_expired = [weak_ptr_this]( |
| 293 | const legacy_hal::NanMatchExpiredInd& msg) { |
| 294 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 295 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 296 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 297 | return; |
| 298 | } |
| 299 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 300 | if (!callback->eventMatchExpired(msg.publish_subscribe_id, |
| 301 | msg.requestor_instance_id).isOk()) { |
| 302 | LOG(ERROR) << "Failed to invoke the callback"; |
| 303 | } |
| 304 | } |
| 305 | }; |
| 306 | |
| 307 | callback_handlers.on_event_followup = [weak_ptr_this]( |
| 308 | const legacy_hal::NanFollowupInd& msg) { |
| 309 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 310 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 311 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 312 | return; |
| 313 | } |
| 314 | NanFollowupReceivedInd hidl_struct; |
| 315 | if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl( |
| 316 | msg, &hidl_struct)) { |
| 317 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 322 | if (!callback->eventFollowupReceived(hidl_struct).isOk()) { |
| 323 | LOG(ERROR) << "Failed to invoke the callback"; |
| 324 | } |
| 325 | } |
| 326 | }; |
| 327 | |
| 328 | callback_handlers.on_event_transmit_follow_up = [weak_ptr_this]( |
| 329 | const legacy_hal::NanTransmitFollowupInd& msg) { |
| 330 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 331 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 332 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 333 | return; |
| 334 | } |
| 335 | WifiNanStatus status; |
| 336 | status.status = hidl_struct_util::convertLegacyNanStatusTypeToHidl(msg.reason); |
| 337 | status.description = msg.nan_reason; |
| 338 | |
| 339 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 340 | if (!callback->eventTransmitFollowup(msg.id, status).isOk()) { |
| 341 | LOG(ERROR) << "Failed to invoke the callback"; |
| 342 | } |
| 343 | } |
| 344 | }; |
| 345 | |
| 346 | callback_handlers.on_event_data_path_request = [weak_ptr_this]( |
| 347 | const legacy_hal::NanDataPathRequestInd& msg) { |
| 348 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 349 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 350 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 351 | return; |
| 352 | } |
| 353 | NanDataPathRequestInd hidl_struct; |
| 354 | if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl( |
| 355 | msg, &hidl_struct)) { |
| 356 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 357 | return; |
| 358 | } |
| 359 | |
| 360 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 361 | if (!callback->eventDataPathRequest(hidl_struct).isOk()) { |
| 362 | LOG(ERROR) << "Failed to invoke the callback"; |
| 363 | } |
| 364 | } |
| 365 | }; |
| 366 | |
| 367 | callback_handlers.on_event_data_path_confirm = [weak_ptr_this]( |
| 368 | const legacy_hal::NanDataPathConfirmInd& msg) { |
| 369 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 370 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 371 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 372 | return; |
| 373 | } |
| 374 | NanDataPathConfirmInd hidl_struct; |
| 375 | if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl( |
| 376 | msg, &hidl_struct)) { |
| 377 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 378 | return; |
| 379 | } |
| 380 | |
| 381 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 382 | if (!callback->eventDataPathConfirm(hidl_struct).isOk()) { |
| 383 | LOG(ERROR) << "Failed to invoke the callback"; |
| 384 | } |
| 385 | } |
| 386 | }; |
| 387 | |
| 388 | callback_handlers.on_event_data_path_end = [weak_ptr_this]( |
| 389 | const legacy_hal::NanDataPathEndInd& msg) { |
| 390 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 391 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 392 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 393 | return; |
| 394 | } |
| 395 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 396 | for (int i = 0; i < msg.num_ndp_instances; ++i) { |
| 397 | if (!callback->eventDataPathTerminated(msg.ndp_instance_id[i]).isOk()) { |
| 398 | LOG(ERROR) << "Failed to invoke the callback"; |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | }; |
| 403 | |
| 404 | callback_handlers.on_event_beacon_sdf_payload = [weak_ptr_this]( |
| 405 | const legacy_hal::NanBeaconSdfPayloadInd& msg) { |
| 406 | const auto shared_ptr_this = weak_ptr_this.promote(); |
| 407 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { |
| 408 | LOG(ERROR) << "Callback invoked on an invalid object"; |
| 409 | return; |
| 410 | } |
| 411 | NanBeaconSdfPayloadInd hidl_struct; |
| 412 | if (!hidl_struct_util::convertLegacyNanBeaconSdfPayloadIndToHidl( |
| 413 | msg, &hidl_struct)) { |
| 414 | LOG(ERROR) << "Failed to convert nan capabilities response"; |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | for (const auto& callback : shared_ptr_this->event_callbacks_) { |
| 419 | if (!callback->eventBeaconSdfPayload(hidl_struct).isOk()) { |
| 420 | LOG(ERROR) << "Failed to invoke the callback"; |
| 421 | } |
| 422 | } |
| 423 | }; |
| 424 | |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 425 | legacy_hal::wifi_error legacy_status = |
| 426 | legacy_hal_.lock()->nanRegisterCallbackHandlers(callback_handlers); |
| 427 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 428 | LOG(ERROR) << "Failed to register nan callbacks. Invalidating object"; |
| 429 | invalidate(); |
| 430 | } |
| 431 | } |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 432 | |
| 433 | void WifiNanIface::invalidate() { |
| 434 | legacy_hal_.reset(); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 435 | event_callbacks_.clear(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 436 | is_valid_ = false; |
| 437 | } |
| 438 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 439 | bool WifiNanIface::isValid() { |
| 440 | return is_valid_; |
| 441 | } |
| 442 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 443 | Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 444 | return validateAndCall(this, |
| 445 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 446 | &WifiNanIface::getNameInternal, |
| 447 | hidl_status_cb); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 448 | } |
| 449 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 450 | Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) { |
| 451 | return validateAndCall(this, |
| 452 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 453 | &WifiNanIface::getTypeInternal, |
| 454 | hidl_status_cb); |
| 455 | } |
| 456 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 457 | Return<void> WifiNanIface::registerEventCallback( |
| 458 | const sp<IWifiNanIfaceEventCallback>& callback, |
| 459 | registerEventCallback_cb hidl_status_cb) { |
| 460 | return validateAndCall(this, |
| 461 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 462 | &WifiNanIface::registerEventCallbackInternal, |
| 463 | hidl_status_cb, |
| 464 | callback); |
| 465 | } |
| 466 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 467 | Return<void> WifiNanIface::getCapabilitiesRequest(uint16_t cmd_id, |
| 468 | getCapabilitiesRequest_cb hidl_status_cb) { |
| 469 | return validateAndCall(this, |
| 470 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 471 | &WifiNanIface::getCapabilitiesRequestInternal, |
| 472 | hidl_status_cb, |
| 473 | cmd_id); |
| 474 | } |
| 475 | |
| 476 | Return<void> WifiNanIface::enableRequest(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 477 | const NanEnableRequest& msg, |
| 478 | enableRequest_cb hidl_status_cb) { |
| 479 | return validateAndCall(this, |
| 480 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 481 | &WifiNanIface::enableRequestInternal, |
| 482 | hidl_status_cb, |
| 483 | cmd_id, |
| 484 | msg); |
| 485 | } |
| 486 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 487 | Return<void> WifiNanIface::configRequest(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 488 | const NanConfigRequest& msg, |
| 489 | configRequest_cb hidl_status_cb) { |
| 490 | return validateAndCall(this, |
| 491 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 492 | &WifiNanIface::configRequestInternal, |
| 493 | hidl_status_cb, |
| 494 | cmd_id, |
| 495 | msg); |
| 496 | } |
| 497 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 498 | Return<void> WifiNanIface::disableRequest(uint16_t cmd_id, |
| 499 | disableRequest_cb hidl_status_cb) { |
| 500 | return validateAndCall(this, |
| 501 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 502 | &WifiNanIface::disableRequestInternal, |
| 503 | hidl_status_cb, |
| 504 | cmd_id); |
| 505 | } |
| 506 | |
| 507 | Return<void> WifiNanIface::startPublishRequest(uint16_t cmd_id, |
| 508 | const NanPublishRequest& msg, |
| 509 | startPublishRequest_cb hidl_status_cb) { |
| 510 | return validateAndCall(this, |
| 511 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 512 | &WifiNanIface::startPublishRequestInternal, |
| 513 | hidl_status_cb, |
| 514 | cmd_id, |
| 515 | msg); |
| 516 | } |
| 517 | |
| 518 | Return<void> WifiNanIface::stopPublishRequest( |
| 519 | uint16_t cmd_id, |
| 520 | uint16_t sessionId, |
| 521 | stopPublishRequest_cb hidl_status_cb) { |
| 522 | return validateAndCall(this, |
| 523 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 524 | &WifiNanIface::stopPublishRequestInternal, |
| 525 | hidl_status_cb, |
| 526 | cmd_id, |
| 527 | sessionId); |
| 528 | } |
| 529 | |
| 530 | Return<void> WifiNanIface::startSubscribeRequest( |
| 531 | uint16_t cmd_id, |
| 532 | const NanSubscribeRequest& msg, |
| 533 | startSubscribeRequest_cb hidl_status_cb) { |
| 534 | return validateAndCall(this, |
| 535 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 536 | &WifiNanIface::startSubscribeRequestInternal, |
| 537 | hidl_status_cb, |
| 538 | cmd_id, |
| 539 | msg); |
| 540 | } |
| 541 | |
| 542 | Return<void> WifiNanIface::stopSubscribeRequest( |
| 543 | uint16_t cmd_id, |
| 544 | uint16_t sessionId, |
| 545 | stopSubscribeRequest_cb hidl_status_cb) { |
| 546 | return validateAndCall(this, |
| 547 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 548 | &WifiNanIface::stopSubscribeRequestInternal, |
| 549 | hidl_status_cb, |
| 550 | cmd_id, |
| 551 | sessionId); |
| 552 | } |
| 553 | |
| 554 | Return<void> WifiNanIface::transmitFollowupRequest( |
| 555 | uint16_t cmd_id, |
| 556 | const NanTransmitFollowupRequest& msg, |
| 557 | transmitFollowupRequest_cb hidl_status_cb) { |
| 558 | return validateAndCall(this, |
| 559 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 560 | &WifiNanIface::transmitFollowupRequestInternal, |
| 561 | hidl_status_cb, |
| 562 | cmd_id, |
| 563 | msg); |
| 564 | } |
| 565 | |
| 566 | Return<void> WifiNanIface::createDataInterfaceRequest( |
| 567 | uint16_t cmd_id, |
| 568 | const hidl_string& iface_name, |
| 569 | createDataInterfaceRequest_cb hidl_status_cb) { |
| 570 | return validateAndCall(this, |
| 571 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 572 | &WifiNanIface::createDataInterfaceRequestInternal, |
| 573 | hidl_status_cb, |
| 574 | cmd_id, |
| 575 | iface_name); |
| 576 | } |
| 577 | |
| 578 | Return<void> WifiNanIface::deleteDataInterfaceRequest( |
| 579 | uint16_t cmd_id, |
| 580 | const hidl_string& iface_name, |
| 581 | deleteDataInterfaceRequest_cb hidl_status_cb) { |
| 582 | return validateAndCall(this, |
| 583 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 584 | &WifiNanIface::deleteDataInterfaceRequestInternal, |
| 585 | hidl_status_cb, |
| 586 | cmd_id, |
| 587 | iface_name); |
| 588 | } |
| 589 | |
| 590 | Return<void> WifiNanIface::initiateDataPathRequest( |
| 591 | uint16_t cmd_id, |
| 592 | const NanInitiateDataPathRequest& msg, |
| 593 | initiateDataPathRequest_cb hidl_status_cb) { |
| 594 | return validateAndCall(this, |
| 595 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 596 | &WifiNanIface::initiateDataPathRequestInternal, |
| 597 | hidl_status_cb, |
| 598 | cmd_id, |
| 599 | msg); |
| 600 | } |
| 601 | |
| 602 | Return<void> WifiNanIface::respondToDataPathIndicationRequest( |
| 603 | uint16_t cmd_id, |
| 604 | const NanRespondToDataPathIndicationRequest& msg, |
| 605 | respondToDataPathIndicationRequest_cb hidl_status_cb) { |
| 606 | return validateAndCall(this, |
| 607 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 608 | &WifiNanIface::respondToDataPathIndicationRequestInternal, |
| 609 | hidl_status_cb, |
| 610 | cmd_id, |
| 611 | msg); |
| 612 | } |
| 613 | |
| 614 | Return<void> WifiNanIface::terminateDataPathRequest(uint16_t cmd_id, uint32_t ndpInstanceId, |
| 615 | terminateDataPathRequest_cb hidl_status_cb) { |
| 616 | return validateAndCall(this, |
| 617 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 618 | &WifiNanIface::terminateDataPathRequestInternal, |
| 619 | hidl_status_cb, |
| 620 | cmd_id, |
| 621 | ndpInstanceId); |
| 622 | } |
| 623 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 624 | Return<void> WifiNanIface::beaconSdfPayloadRequest( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 625 | uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 626 | const NanBeaconSdfPayloadRequest& msg, |
| 627 | beaconSdfPayloadRequest_cb hidl_status_cb) { |
| 628 | return validateAndCall(this, |
| 629 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 630 | &WifiNanIface::beaconSdfPayloadRequestInternal, |
| 631 | hidl_status_cb, |
| 632 | cmd_id, |
| 633 | msg); |
| 634 | } |
| 635 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 636 | std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() { |
| 637 | return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; |
| 638 | } |
| 639 | |
| 640 | std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() { |
| 641 | return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN}; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 642 | } |
| 643 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 644 | WifiStatus WifiNanIface::registerEventCallbackInternal( |
| 645 | const sp<IWifiNanIfaceEventCallback>& callback) { |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 646 | // TODO(b/31632518): remove the callback when the client is destroyed and/or |
| 647 | // make sure that the same callback is only registered once (i.e. detect duplicates) |
| 648 | // OR: consider having a single listener - not clear why multiple listeners (managers) are |
| 649 | // necessary, nor how they would coordinate (at least command IDs). |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 650 | event_callbacks_.emplace_back(callback); |
| 651 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 652 | } |
| 653 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 654 | WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t cmd_id) { |
| 655 | legacy_hal::wifi_error legacy_status = |
| 656 | legacy_hal_.lock()->nanGetCapabilities(cmd_id); |
| 657 | return createWifiStatusFromLegacyError(legacy_status); |
| 658 | } |
| 659 | |
| 660 | WifiStatus WifiNanIface::enableRequestInternal(uint16_t cmd_id, |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 661 | const NanEnableRequest& msg) { |
| 662 | legacy_hal::NanEnableRequest legacy_msg; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 663 | if (!hidl_struct_util::convertHidlNanEnableRequestToLegacy(msg, &legacy_msg)) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 664 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 665 | } |
| 666 | legacy_hal::wifi_error legacy_status = |
| 667 | legacy_hal_.lock()->nanEnableRequest(cmd_id, legacy_msg); |
| 668 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 669 | } |
| 670 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 671 | WifiStatus WifiNanIface::configRequestInternal( |
| 672 | uint16_t cmd_id, const NanConfigRequest& msg) { |
| 673 | legacy_hal::NanConfigRequest legacy_msg; |
| 674 | if (!hidl_struct_util::convertHidlNanConfigRequestToLegacy(msg, |
| 675 | &legacy_msg)) { |
| 676 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 677 | } |
| 678 | legacy_hal::wifi_error legacy_status = |
| 679 | legacy_hal_.lock()->nanConfigRequest(cmd_id, legacy_msg); |
| 680 | return createWifiStatusFromLegacyError(legacy_status); |
| 681 | } |
| 682 | |
| 683 | WifiStatus WifiNanIface::disableRequestInternal(uint16_t cmd_id) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 684 | legacy_hal::wifi_error legacy_status = |
| 685 | legacy_hal_.lock()->nanDisableRequest(cmd_id); |
| 686 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 687 | } |
| 688 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 689 | WifiStatus WifiNanIface::startPublishRequestInternal(uint16_t cmd_id, |
| 690 | const NanPublishRequest& msg) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 691 | legacy_hal::NanPublishRequest legacy_msg; |
| 692 | if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg, |
| 693 | &legacy_msg)) { |
| 694 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 695 | } |
| 696 | legacy_hal::wifi_error legacy_status = |
| 697 | legacy_hal_.lock()->nanPublishRequest(cmd_id, legacy_msg); |
| 698 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 699 | } |
| 700 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 701 | WifiStatus WifiNanIface::stopPublishRequestInternal( |
| 702 | uint16_t cmd_id, uint16_t sessionId) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 703 | legacy_hal::NanPublishCancelRequest legacy_msg; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 704 | legacy_msg.publish_id = sessionId; |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 705 | legacy_hal::wifi_error legacy_status = |
| 706 | legacy_hal_.lock()->nanPublishCancelRequest(cmd_id, legacy_msg); |
| 707 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 708 | } |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 709 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 710 | WifiStatus WifiNanIface::startSubscribeRequestInternal( |
| 711 | uint16_t cmd_id, const NanSubscribeRequest& msg) { |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 712 | legacy_hal::NanSubscribeRequest legacy_msg; |
| 713 | if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy(msg, |
| 714 | &legacy_msg)) { |
| 715 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 716 | } |
| 717 | legacy_hal::wifi_error legacy_status = |
| 718 | legacy_hal_.lock()->nanSubscribeRequest(cmd_id, legacy_msg); |
| 719 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 720 | } |
Roshan Pius | f5f51fd | 2016-12-01 13:54:24 -0800 | [diff] [blame] | 721 | |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 722 | WifiStatus WifiNanIface::stopSubscribeRequestInternal( |
| 723 | uint16_t cmd_id, uint16_t sessionId) { |
| 724 | legacy_hal::NanSubscribeCancelRequest legacy_msg; |
| 725 | legacy_msg.subscribe_id = sessionId; |
| 726 | legacy_hal::wifi_error legacy_status = |
| 727 | legacy_hal_.lock()->nanSubscribeCancelRequest(cmd_id, legacy_msg); |
| 728 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 729 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 730 | |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 731 | WifiStatus WifiNanIface::transmitFollowupRequestInternal( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 732 | uint16_t cmd_id, const NanTransmitFollowupRequest& msg) { |
| 733 | legacy_hal::NanTransmitFollowupRequest legacy_msg; |
| 734 | if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy(msg, &legacy_msg)) { |
| 735 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 736 | } |
| 737 | legacy_hal::wifi_error legacy_status = |
| 738 | legacy_hal_.lock()->nanTransmitFollowupRequest(cmd_id, legacy_msg); |
| 739 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 740 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 741 | |
| 742 | WifiStatus WifiNanIface::createDataInterfaceRequestInternal( |
| 743 | uint16_t cmd_id, const std::string& iface_name) { |
| 744 | legacy_hal::wifi_error legacy_status = |
| 745 | legacy_hal_.lock()->nanDataInterfaceCreate(cmd_id, iface_name); |
| 746 | return createWifiStatusFromLegacyError(legacy_status); |
| 747 | } |
| 748 | WifiStatus WifiNanIface::deleteDataInterfaceRequestInternal( |
| 749 | uint16_t cmd_id, const std::string& iface_name) { |
| 750 | legacy_hal::wifi_error legacy_status = |
| 751 | legacy_hal_.lock()->nanDataInterfaceDelete(cmd_id, iface_name); |
| 752 | return createWifiStatusFromLegacyError(legacy_status); |
| 753 | } |
| 754 | WifiStatus WifiNanIface::initiateDataPathRequestInternal( |
| 755 | uint16_t cmd_id, const NanInitiateDataPathRequest& msg) { |
| 756 | legacy_hal::NanDataPathInitiatorRequest legacy_msg; |
| 757 | if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy(msg, &legacy_msg)) { |
| 758 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 759 | } |
| 760 | legacy_hal::wifi_error legacy_status = |
| 761 | legacy_hal_.lock()->nanDataRequestInitiator(cmd_id, legacy_msg); |
| 762 | return createWifiStatusFromLegacyError(legacy_status); |
| 763 | } |
| 764 | WifiStatus WifiNanIface::respondToDataPathIndicationRequestInternal( |
| 765 | uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg) { |
| 766 | legacy_hal::NanDataPathIndicationResponse legacy_msg; |
| 767 | if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy(msg, &legacy_msg)) { |
| 768 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 769 | } |
| 770 | legacy_hal::wifi_error legacy_status = |
| 771 | legacy_hal_.lock()->nanDataIndicationResponse(cmd_id, legacy_msg); |
| 772 | return createWifiStatusFromLegacyError(legacy_status); |
| 773 | } |
| 774 | WifiStatus WifiNanIface::terminateDataPathRequestInternal( |
| 775 | uint16_t cmd_id, uint32_t ndpInstanceId) { |
| 776 | legacy_hal::NanDataPathEndRequest* legacy_msg = (legacy_hal::NanDataPathEndRequest*)malloc( |
| 777 | sizeof(legacy_hal::NanDataPathEndRequest) + sizeof(uint32_t)); |
| 778 | legacy_msg->num_ndp_instances = 1; |
| 779 | legacy_msg->ndp_instance_id[0] = ndpInstanceId; |
| 780 | |
| 781 | legacy_hal::wifi_error legacy_status = |
| 782 | legacy_hal_.lock()->nanDataEnd(cmd_id, *legacy_msg); |
| 783 | free(legacy_msg); |
| 784 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 785 | } |
| 786 | WifiStatus WifiNanIface::beaconSdfPayloadRequestInternal( |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 787 | uint16_t cmd_id, const NanBeaconSdfPayloadRequest& msg) { |
| 788 | legacy_hal::NanBeaconSdfPayloadRequest legacy_msg; |
| 789 | if (!hidl_struct_util::convertHidlNanBeaconSdfPayloadRequestToLegacy(msg, &legacy_msg)) { |
| 790 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 791 | } |
| 792 | legacy_hal::wifi_error legacy_status = |
| 793 | legacy_hal_.lock()->nanBeaconSdfPayloadRequest(cmd_id, legacy_msg); |
| 794 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 795 | } |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 796 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 797 | } // namespace implementation |
| 798 | } // namespace V1_0 |
| 799 | } // namespace wifi |
| 800 | } // namespace hardware |
| 801 | } // namespace android |