Roshan Pius | 5926828 | 2016-10-06 20:23:47 -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 | 5926828 | 2016-10-06 20:23:47 -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_rtt_controller.h" |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 21 | #include "wifi_status_util.h" |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -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 | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 29 | |
| 30 | WifiRttController::WifiRttController( |
| 31 | const sp<IWifiIface>& bound_iface, |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 32 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 33 | : bound_iface_(bound_iface), legacy_hal_(legacy_hal), is_valid_(true) {} |
| 34 | |
| 35 | void WifiRttController::invalidate() { |
| 36 | legacy_hal_.reset(); |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 37 | event_callbacks_.clear(); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 38 | is_valid_ = false; |
| 39 | } |
| 40 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 41 | bool WifiRttController::isValid() { |
| 42 | return is_valid_; |
| 43 | } |
| 44 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 45 | Return<void> WifiRttController::getBoundIface(getBoundIface_cb hidl_status_cb) { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 46 | return validateAndCall(this, |
| 47 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 48 | &WifiRttController::getBoundIfaceInternal, |
| 49 | hidl_status_cb); |
| 50 | } |
| 51 | |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 52 | Return<void> WifiRttController::registerEventCallback( |
| 53 | const sp<IWifiRttControllerEventCallback>& callback, |
| 54 | registerEventCallback_cb hidl_status_cb) { |
| 55 | return validateAndCall(this, |
| 56 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 57 | &WifiRttController::registerEventCallbackInternal, |
| 58 | hidl_status_cb, |
| 59 | callback); |
| 60 | } |
| 61 | |
| 62 | Return<void> WifiRttController::rangeRequest( |
| 63 | uint32_t cmd_id, |
| 64 | const hidl_vec<RttConfig>& rtt_configs, |
| 65 | rangeRequest_cb hidl_status_cb) { |
| 66 | return validateAndCall(this, |
| 67 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 68 | &WifiRttController::rangeRequestInternal, |
| 69 | hidl_status_cb, |
| 70 | cmd_id, |
| 71 | rtt_configs); |
| 72 | } |
| 73 | |
| 74 | Return<void> WifiRttController::rangeCancel( |
| 75 | uint32_t cmd_id, |
| 76 | const hidl_vec<hidl_array<uint8_t, 6>>& addrs, |
| 77 | rangeCancel_cb hidl_status_cb) { |
| 78 | return validateAndCall(this, |
| 79 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 80 | &WifiRttController::rangeCancelInternal, |
| 81 | hidl_status_cb, |
| 82 | cmd_id, |
| 83 | addrs); |
| 84 | } |
| 85 | |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 86 | Return<void> WifiRttController::getCapabilities( |
| 87 | getCapabilities_cb hidl_status_cb) { |
| 88 | return validateAndCall(this, |
| 89 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 90 | &WifiRttController::getCapabilitiesInternal, |
| 91 | hidl_status_cb); |
| 92 | } |
| 93 | |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 94 | Return<void> WifiRttController::setLci(uint32_t cmd_id, |
| 95 | const RttLciInformation& lci, |
| 96 | setLci_cb hidl_status_cb) { |
| 97 | return validateAndCall(this, |
| 98 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 99 | &WifiRttController::setLciInternal, |
| 100 | hidl_status_cb, |
| 101 | cmd_id, |
| 102 | lci); |
| 103 | } |
| 104 | |
| 105 | Return<void> WifiRttController::setLcr(uint32_t cmd_id, |
| 106 | const RttLcrInformation& lcr, |
| 107 | setLcr_cb hidl_status_cb) { |
| 108 | return validateAndCall(this, |
| 109 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 110 | &WifiRttController::setLcrInternal, |
| 111 | hidl_status_cb, |
| 112 | cmd_id, |
| 113 | lcr); |
| 114 | } |
| 115 | |
| 116 | Return<void> WifiRttController::getResponderInfo( |
| 117 | getResponderInfo_cb hidl_status_cb) { |
| 118 | return validateAndCall(this, |
| 119 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 120 | &WifiRttController::getResponderInfoInternal, |
| 121 | hidl_status_cb); |
| 122 | } |
| 123 | |
| 124 | Return<void> WifiRttController::enableResponder( |
| 125 | uint32_t cmd_id, |
| 126 | const WifiChannelInfo& channel_hint, |
| 127 | uint32_t maxDurationSeconds, |
| 128 | const RttResponder& info, |
| 129 | enableResponder_cb hidl_status_cb) { |
| 130 | return validateAndCall(this, |
| 131 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 132 | &WifiRttController::enableResponderInternal, |
| 133 | hidl_status_cb, |
| 134 | cmd_id, |
| 135 | channel_hint, |
| 136 | maxDurationSeconds, |
| 137 | info); |
| 138 | } |
| 139 | |
| 140 | Return<void> WifiRttController::disableResponder( |
| 141 | uint32_t cmd_id, disableResponder_cb hidl_status_cb) { |
| 142 | return validateAndCall(this, |
| 143 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 144 | &WifiRttController::disableResponderInternal, |
| 145 | hidl_status_cb, |
| 146 | cmd_id); |
| 147 | } |
| 148 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 149 | std::pair<WifiStatus, sp<IWifiIface>> |
| 150 | WifiRttController::getBoundIfaceInternal() { |
| 151 | return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_}; |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 154 | WifiStatus WifiRttController::registerEventCallbackInternal( |
| 155 | const sp<IWifiRttControllerEventCallback>& callback) { |
| 156 | // TODO(b/31632518): remove the callback when the client is destroyed |
| 157 | event_callbacks_.emplace_back(callback); |
| 158 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 159 | } |
| 160 | |
| 161 | WifiStatus WifiRttController::rangeRequestInternal( |
| 162 | uint32_t /* cmd_id */, const std::vector<RttConfig>& /* rtt_configs */) { |
| 163 | // TODO implement |
| 164 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 165 | } |
| 166 | |
| 167 | WifiStatus WifiRttController::rangeCancelInternal( |
| 168 | uint32_t /* cmd_id */, |
| 169 | const std::vector<hidl_array<uint8_t, 6>>& /* addrs */) { |
| 170 | // TODO implement |
| 171 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 172 | } |
| 173 | |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 174 | std::pair<WifiStatus, RttCapabilities> |
| 175 | WifiRttController::getCapabilitiesInternal() { |
| 176 | // TODO implement |
| 177 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 178 | } |
| 179 | |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 180 | WifiStatus WifiRttController::setLciInternal( |
| 181 | uint32_t /* cmd_id */, const RttLciInformation& /* lci */) { |
| 182 | // TODO implement |
| 183 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 184 | } |
| 185 | |
| 186 | WifiStatus WifiRttController::setLcrInternal( |
| 187 | uint32_t /* cmd_id */, const RttLcrInformation& /* lcr */) { |
| 188 | // TODO implement |
| 189 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 190 | } |
| 191 | |
| 192 | std::pair<WifiStatus, RttResponder> |
| 193 | WifiRttController::getResponderInfoInternal() { |
| 194 | // TODO implement |
| 195 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 196 | } |
| 197 | |
| 198 | WifiStatus WifiRttController::enableResponderInternal( |
| 199 | uint32_t /* cmd_id */, |
| 200 | const WifiChannelInfo& /* channel_hint */, |
| 201 | uint32_t /* maxDurationSeconds */, |
| 202 | const RttResponder& /* info */) { |
| 203 | // TODO implement |
| 204 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 205 | } |
| 206 | |
| 207 | WifiStatus WifiRttController::disableResponderInternal(uint32_t /* cmd_id */) { |
| 208 | // TODO implement |
| 209 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 210 | } |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 211 | } // namespace implementation |
| 212 | } // namespace V1_0 |
| 213 | } // namespace wifi |
| 214 | } // namespace hardware |
| 215 | } // namespace android |