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 | |
| 17 | #ifndef WIFI_NAN_IFACE_H_ |
| 18 | #define WIFI_NAN_IFACE_H_ |
| 19 | |
| 20 | #include <android-base/macros.h> |
| 21 | #include <android/hardware/wifi/1.0/IWifiNanIface.h> |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 22 | #include <android/hardware/wifi/1.0/IWifiNanIfaceEventCallback.h> |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 23 | |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 24 | #include "hidl_callback_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 25 | #include "wifi_legacy_hal.h" |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace wifi { |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame^] | 30 | namespace V1_1 { |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 31 | namespace implementation { |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame^] | 32 | using namespace android::hardware::wifi::V1_0; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * HIDL interface object used to control a NAN Iface instance. |
| 36 | */ |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame^] | 37 | class WifiNanIface : public V1_0::IWifiNanIface { |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 38 | public: |
| 39 | WifiNanIface(const std::string& ifname, |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 40 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 41 | // Refer to |WifiChip::invalidate()|. |
| 42 | void invalidate(); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 43 | bool isValid(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 44 | |
| 45 | // HIDL methods exposed. |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 46 | Return<void> getName(getName_cb hidl_status_cb) override; |
| 47 | Return<void> getType(getType_cb hidl_status_cb) override; |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 48 | Return<void> registerEventCallback( |
| 49 | const sp<IWifiNanIfaceEventCallback>& callback, |
| 50 | registerEventCallback_cb hidl_status_cb) override; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 51 | Return<void> getCapabilitiesRequest(uint16_t cmd_id, |
| 52 | getCapabilitiesRequest_cb hidl_status_cb) override; |
| 53 | Return<void> enableRequest(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 54 | const NanEnableRequest& msg, |
| 55 | enableRequest_cb hidl_status_cb) override; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 56 | Return<void> configRequest(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 57 | const NanConfigRequest& msg, |
| 58 | configRequest_cb hidl_status_cb) override; |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 59 | Return<void> disableRequest(uint16_t cmd_id, |
| 60 | disableRequest_cb hidl_status_cb) override; |
| 61 | Return<void> startPublishRequest(uint16_t cmd_id, |
| 62 | const NanPublishRequest& msg, |
| 63 | startPublishRequest_cb hidl_status_cb) override; |
| 64 | Return<void> stopPublishRequest(uint16_t cmd_id, |
Etan Cohen | 073bb99 | 2017-02-09 10:05:59 -0800 | [diff] [blame] | 65 | uint8_t sessionId, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 66 | stopPublishRequest_cb hidl_status_cb) override; |
| 67 | Return<void> startSubscribeRequest(uint16_t cmd_id, |
| 68 | const NanSubscribeRequest& msg, |
| 69 | startSubscribeRequest_cb hidl_status_cb) override; |
| 70 | Return<void> stopSubscribeRequest(uint16_t cmd_id, |
Etan Cohen | 073bb99 | 2017-02-09 10:05:59 -0800 | [diff] [blame] | 71 | uint8_t sessionId, |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 72 | stopSubscribeRequest_cb hidl_status_cb) override; |
| 73 | Return<void> transmitFollowupRequest(uint16_t cmd_id, |
| 74 | const NanTransmitFollowupRequest& msg, |
| 75 | transmitFollowupRequest_cb hidl_status_cb) override; |
| 76 | Return<void> createDataInterfaceRequest(uint16_t cmd_id, |
| 77 | const hidl_string& iface_name, |
| 78 | createDataInterfaceRequest_cb hidl_status_cb) override; |
| 79 | Return<void> deleteDataInterfaceRequest(uint16_t cmd_id, |
| 80 | const hidl_string& iface_name, |
| 81 | deleteDataInterfaceRequest_cb hidl_status_cb) override; |
| 82 | Return<void> initiateDataPathRequest(uint16_t cmd_id, |
| 83 | const NanInitiateDataPathRequest& msg, |
| 84 | initiateDataPathRequest_cb hidl_status_cb) override; |
| 85 | Return<void> respondToDataPathIndicationRequest( |
| 86 | uint16_t cmd_id, |
| 87 | const NanRespondToDataPathIndicationRequest& msg, |
| 88 | respondToDataPathIndicationRequest_cb hidl_status_cb) override; |
| 89 | Return<void> terminateDataPathRequest(uint16_t cmd_id, |
| 90 | uint32_t ndpInstanceId, |
| 91 | terminateDataPathRequest_cb hidl_status_cb) override; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 92 | |
| 93 | private: |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 94 | // Corresponding worker functions for the HIDL methods. |
| 95 | std::pair<WifiStatus, std::string> getNameInternal(); |
| 96 | std::pair<WifiStatus, IfaceType> getTypeInternal(); |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 97 | WifiStatus registerEventCallbackInternal( |
| 98 | const sp<IWifiNanIfaceEventCallback>& callback); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 99 | WifiStatus getCapabilitiesRequestInternal(uint16_t cmd_id); |
| 100 | WifiStatus enableRequestInternal(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 101 | const NanEnableRequest& msg); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 102 | WifiStatus configRequestInternal(uint16_t cmd_id, |
Roshan Pius | 0c92d44 | 2016-10-27 17:38:53 -0700 | [diff] [blame] | 103 | const NanConfigRequest& msg); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 104 | WifiStatus disableRequestInternal(uint16_t cmd_id); |
| 105 | WifiStatus startPublishRequestInternal(uint16_t cmd_id, |
| 106 | const NanPublishRequest& msg); |
Etan Cohen | 073bb99 | 2017-02-09 10:05:59 -0800 | [diff] [blame] | 107 | WifiStatus stopPublishRequestInternal(uint16_t cmd_id, uint8_t sessionId); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 108 | WifiStatus startSubscribeRequestInternal(uint16_t cmd_id, |
| 109 | const NanSubscribeRequest& msg); |
Etan Cohen | 073bb99 | 2017-02-09 10:05:59 -0800 | [diff] [blame] | 110 | WifiStatus stopSubscribeRequestInternal(uint16_t cmd_id, uint8_t sessionId); |
Etan Cohen | f01bcaa | 2016-12-25 09:42:21 -0800 | [diff] [blame] | 111 | WifiStatus transmitFollowupRequestInternal( |
| 112 | uint16_t cmd_id, const NanTransmitFollowupRequest& msg); |
| 113 | WifiStatus createDataInterfaceRequestInternal(uint16_t cmd_id, |
| 114 | const std::string& iface_name); |
| 115 | WifiStatus deleteDataInterfaceRequestInternal(uint16_t cmd_id, |
| 116 | const std::string& iface_name); |
| 117 | WifiStatus initiateDataPathRequestInternal( |
| 118 | uint16_t cmd_id, const NanInitiateDataPathRequest& msg); |
| 119 | WifiStatus respondToDataPathIndicationRequestInternal( |
| 120 | uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg); |
| 121 | WifiStatus terminateDataPathRequestInternal( |
| 122 | uint16_t cmd_id, uint32_t ndpInstanceId); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 123 | |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 124 | std::set<sp<IWifiNanIfaceEventCallback>> getEventCallbacks(); |
| 125 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 126 | std::string ifname_; |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 127 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 128 | bool is_valid_; |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 129 | hidl_callback_util::HidlCallbackHandler<IWifiNanIfaceEventCallback> |
| 130 | event_cb_handler_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 131 | |
| 132 | DISALLOW_COPY_AND_ASSIGN(WifiNanIface); |
| 133 | }; |
| 134 | |
| 135 | } // namespace implementation |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame^] | 136 | } // namespace V1_1 |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 137 | } // namespace wifi |
| 138 | } // namespace hardware |
| 139 | } // namespace android |
| 140 | |
| 141 | #endif // WIFI_NAN_IFACE_H_ |