blob: 9e7341f248cebc79e1852c18feb9754a8c46b091 [file] [log] [blame]
Roshan Pius3e2d6712016-10-06 13:16:23 -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 Pius3e2d6712016-10-06 13:16:23 -070017#include <android-base/logging.h>
18
Roshan Pius907d4a22016-10-27 12:48:12 -070019#include "hidl_return_util.h"
20#include "wifi_p2p_iface.h"
Roshan Pius734fea02016-10-11 08:30:28 -070021#include "wifi_status_util.h"
Roshan Pius3e2d6712016-10-06 13:16:23 -070022
23namespace android {
24namespace hardware {
25namespace wifi {
Ahmed ElArabawyf501a982019-07-23 15:02:22 -070026namespace V1_4 {
Roshan Pius3e2d6712016-10-06 13:16:23 -070027namespace implementation {
Roshan Pius907d4a22016-10-27 12:48:12 -070028using hidl_return_util::validateAndCall;
Roshan Pius3e2d6712016-10-06 13:16:23 -070029
Roshan Pius6cedc972016-10-28 10:11:17 -070030WifiP2pIface::WifiP2pIface(
31 const std::string& ifname,
32 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
Roshan Pius3e2d6712016-10-06 13:16:23 -070033 : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
34
35void WifiP2pIface::invalidate() {
Roshan Piusabcf78f2017-10-06 16:30:38 -070036 legacy_hal_.reset();
37 is_valid_ = false;
Roshan Pius3e2d6712016-10-06 13:16:23 -070038}
39
Roshan Piusabcf78f2017-10-06 16:30:38 -070040bool WifiP2pIface::isValid() { return is_valid_; }
Roshan Pius907d4a22016-10-27 12:48:12 -070041
Roshan Pius675609b2017-10-31 14:24:58 -070042std::string WifiP2pIface::getName() { return ifname_; }
43
Roshan Pius734fea02016-10-11 08:30:28 -070044Return<void> WifiP2pIface::getName(getName_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -070045 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
46 &WifiP2pIface::getNameInternal, hidl_status_cb);
Roshan Pius3e2d6712016-10-06 13:16:23 -070047}
48
Roshan Pius734fea02016-10-11 08:30:28 -070049Return<void> WifiP2pIface::getType(getType_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -070050 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
51 &WifiP2pIface::getTypeInternal, hidl_status_cb);
Roshan Pius907d4a22016-10-27 12:48:12 -070052}
53
54std::pair<WifiStatus, std::string> WifiP2pIface::getNameInternal() {
Roshan Piusabcf78f2017-10-06 16:30:38 -070055 return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
Roshan Pius907d4a22016-10-27 12:48:12 -070056}
57
58std::pair<WifiStatus, IfaceType> WifiP2pIface::getTypeInternal() {
Roshan Piusabcf78f2017-10-06 16:30:38 -070059 return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P};
Roshan Pius3e2d6712016-10-06 13:16:23 -070060}
61
62} // namespace implementation
Ahmed ElArabawyf501a982019-07-23 15:02:22 -070063} // namespace V1_4
Roshan Pius3e2d6712016-10-06 13:16:23 -070064} // namespace wifi
65} // namespace hardware
66} // namespace android