blob: b7eab89d9fbdeec5bdf509640deb584a8ec26022 [file] [log] [blame]
Roshan Pius59268282016-10-06 20:23:47 -07001/*
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 Pius59268282016-10-06 20:23:47 -070017#include <android-base/logging.h>
18
Roshan Pius907d4a22016-10-27 12:48:12 -070019#include "hidl_return_util.h"
20#include "wifi_rtt_controller.h"
Roshan Pius734fea02016-10-11 08:30:28 -070021#include "wifi_status_util.h"
Roshan Pius59268282016-10-06 20:23:47 -070022
23namespace android {
24namespace hardware {
25namespace wifi {
26namespace V1_0 {
27namespace implementation {
Roshan Pius907d4a22016-10-27 12:48:12 -070028using hidl_return_util::validateAndCall;
Roshan Pius59268282016-10-06 20:23:47 -070029
30WifiRttController::WifiRttController(
31 const sp<IWifiIface>& bound_iface,
32 const std::weak_ptr<WifiLegacyHal> legacy_hal)
33 : bound_iface_(bound_iface), legacy_hal_(legacy_hal), is_valid_(true) {}
34
35void WifiRttController::invalidate() {
36 legacy_hal_.reset();
37 is_valid_ = false;
38}
39
Roshan Pius907d4a22016-10-27 12:48:12 -070040bool WifiRttController::isValid() {
41 return is_valid_;
42}
43
Roshan Pius734fea02016-10-11 08:30:28 -070044Return<void> WifiRttController::getBoundIface(getBoundIface_cb hidl_status_cb) {
Roshan Pius907d4a22016-10-27 12:48:12 -070045 return validateAndCall(this,
46 WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
47 &WifiRttController::getBoundIfaceInternal,
48 hidl_status_cb);
49}
50
51std::pair<WifiStatus, sp<IWifiIface>>
52WifiRttController::getBoundIfaceInternal() {
53 return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_};
Roshan Pius59268282016-10-06 20:23:47 -070054}
55
56} // namespace implementation
57} // namespace V1_0
58} // namespace wifi
59} // namespace hardware
60} // namespace android