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 | |
| 86 | Return<void> WifiRttController::setChannelMap(uint32_t cmd_id, |
| 87 | const RttChannelMap& params, |
| 88 | uint32_t num_dw, |
| 89 | setChannelMap_cb hidl_status_cb) { |
| 90 | return validateAndCall(this, |
| 91 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 92 | &WifiRttController::setChannelMapInternal, |
| 93 | hidl_status_cb, |
| 94 | cmd_id, |
| 95 | params, |
| 96 | num_dw); |
| 97 | } |
| 98 | |
| 99 | Return<void> WifiRttController::clearChannelMap( |
| 100 | uint32_t cmd_id, clearChannelMap_cb hidl_status_cb) { |
| 101 | return validateAndCall(this, |
| 102 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 103 | &WifiRttController::clearChannelMapInternal, |
| 104 | hidl_status_cb, |
| 105 | cmd_id); |
| 106 | } |
| 107 | |
| 108 | Return<void> WifiRttController::getCapabilities( |
| 109 | getCapabilities_cb hidl_status_cb) { |
| 110 | return validateAndCall(this, |
| 111 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 112 | &WifiRttController::getCapabilitiesInternal, |
| 113 | hidl_status_cb); |
| 114 | } |
| 115 | |
| 116 | Return<void> WifiRttController::setDebugCfg(RttDebugType type, |
| 117 | setDebugCfg_cb hidl_status_cb) { |
| 118 | return validateAndCall(this, |
| 119 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 120 | &WifiRttController::setDebugCfgInternal, |
| 121 | hidl_status_cb, |
| 122 | type); |
| 123 | } |
| 124 | |
| 125 | Return<void> WifiRttController::getDebugInfo(getDebugInfo_cb hidl_status_cb) { |
| 126 | return validateAndCall(this, |
| 127 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 128 | &WifiRttController::getDebugInfoInternal, |
| 129 | hidl_status_cb); |
| 130 | } |
| 131 | |
| 132 | Return<void> WifiRttController::setLci(uint32_t cmd_id, |
| 133 | const RttLciInformation& lci, |
| 134 | setLci_cb hidl_status_cb) { |
| 135 | return validateAndCall(this, |
| 136 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 137 | &WifiRttController::setLciInternal, |
| 138 | hidl_status_cb, |
| 139 | cmd_id, |
| 140 | lci); |
| 141 | } |
| 142 | |
| 143 | Return<void> WifiRttController::setLcr(uint32_t cmd_id, |
| 144 | const RttLcrInformation& lcr, |
| 145 | setLcr_cb hidl_status_cb) { |
| 146 | return validateAndCall(this, |
| 147 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 148 | &WifiRttController::setLcrInternal, |
| 149 | hidl_status_cb, |
| 150 | cmd_id, |
| 151 | lcr); |
| 152 | } |
| 153 | |
| 154 | Return<void> WifiRttController::getResponderInfo( |
| 155 | getResponderInfo_cb hidl_status_cb) { |
| 156 | return validateAndCall(this, |
| 157 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 158 | &WifiRttController::getResponderInfoInternal, |
| 159 | hidl_status_cb); |
| 160 | } |
| 161 | |
| 162 | Return<void> WifiRttController::enableResponder( |
| 163 | uint32_t cmd_id, |
| 164 | const WifiChannelInfo& channel_hint, |
| 165 | uint32_t maxDurationSeconds, |
| 166 | const RttResponder& info, |
| 167 | enableResponder_cb hidl_status_cb) { |
| 168 | return validateAndCall(this, |
| 169 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 170 | &WifiRttController::enableResponderInternal, |
| 171 | hidl_status_cb, |
| 172 | cmd_id, |
| 173 | channel_hint, |
| 174 | maxDurationSeconds, |
| 175 | info); |
| 176 | } |
| 177 | |
| 178 | Return<void> WifiRttController::disableResponder( |
| 179 | uint32_t cmd_id, disableResponder_cb hidl_status_cb) { |
| 180 | return validateAndCall(this, |
| 181 | WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID, |
| 182 | &WifiRttController::disableResponderInternal, |
| 183 | hidl_status_cb, |
| 184 | cmd_id); |
| 185 | } |
| 186 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 187 | std::pair<WifiStatus, sp<IWifiIface>> |
| 188 | WifiRttController::getBoundIfaceInternal() { |
| 189 | return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_}; |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Roshan Pius | 7913f5e | 2016-10-27 17:09:30 -0700 | [diff] [blame] | 192 | WifiStatus WifiRttController::registerEventCallbackInternal( |
| 193 | const sp<IWifiRttControllerEventCallback>& callback) { |
| 194 | // TODO(b/31632518): remove the callback when the client is destroyed |
| 195 | event_callbacks_.emplace_back(callback); |
| 196 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 197 | } |
| 198 | |
| 199 | WifiStatus WifiRttController::rangeRequestInternal( |
| 200 | uint32_t /* cmd_id */, const std::vector<RttConfig>& /* rtt_configs */) { |
| 201 | // TODO implement |
| 202 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 203 | } |
| 204 | |
| 205 | WifiStatus WifiRttController::rangeCancelInternal( |
| 206 | uint32_t /* cmd_id */, |
| 207 | const std::vector<hidl_array<uint8_t, 6>>& /* addrs */) { |
| 208 | // TODO implement |
| 209 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 210 | } |
| 211 | |
| 212 | WifiStatus WifiRttController::setChannelMapInternal( |
| 213 | uint32_t /* cmd_id */, |
| 214 | const RttChannelMap& /* params */, |
| 215 | uint32_t /* num_dw */) { |
| 216 | // TODO implement |
| 217 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 218 | } |
| 219 | |
| 220 | WifiStatus WifiRttController::clearChannelMapInternal(uint32_t /* cmd_id */) { |
| 221 | // TODO implement |
| 222 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 223 | } |
| 224 | |
| 225 | std::pair<WifiStatus, RttCapabilities> |
| 226 | WifiRttController::getCapabilitiesInternal() { |
| 227 | // TODO implement |
| 228 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 229 | } |
| 230 | |
| 231 | WifiStatus WifiRttController::setDebugCfgInternal(RttDebugType /* type */) { |
| 232 | // TODO implement |
| 233 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 234 | } |
| 235 | |
| 236 | std::pair<WifiStatus, RttDebugInfo> WifiRttController::getDebugInfoInternal() { |
| 237 | // TODO implement |
| 238 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 239 | } |
| 240 | |
| 241 | WifiStatus WifiRttController::setLciInternal( |
| 242 | uint32_t /* cmd_id */, const RttLciInformation& /* lci */) { |
| 243 | // TODO implement |
| 244 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 245 | } |
| 246 | |
| 247 | WifiStatus WifiRttController::setLcrInternal( |
| 248 | uint32_t /* cmd_id */, const RttLcrInformation& /* lcr */) { |
| 249 | // TODO implement |
| 250 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 251 | } |
| 252 | |
| 253 | std::pair<WifiStatus, RttResponder> |
| 254 | WifiRttController::getResponderInfoInternal() { |
| 255 | // TODO implement |
| 256 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 257 | } |
| 258 | |
| 259 | WifiStatus WifiRttController::enableResponderInternal( |
| 260 | uint32_t /* cmd_id */, |
| 261 | const WifiChannelInfo& /* channel_hint */, |
| 262 | uint32_t /* maxDurationSeconds */, |
| 263 | const RttResponder& /* info */) { |
| 264 | // TODO implement |
| 265 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 266 | } |
| 267 | |
| 268 | WifiStatus WifiRttController::disableResponderInternal(uint32_t /* cmd_id */) { |
| 269 | // TODO implement |
| 270 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 271 | } |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 272 | } // namespace implementation |
| 273 | } // namespace V1_0 |
| 274 | } // namespace wifi |
| 275 | } // namespace hardware |
| 276 | } // namespace android |