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