blob: d4b1fcabf171aa413373b8d50c5693601c9cff20 [file] [log] [blame]
Roshan Pius3e2d6712016-10-06 13:16:23 -07001/*
Gabriel Biren631a8112022-12-01 22:29:32 +00002 * Copyright (C) 2016 The Android Open Source Project
Roshan Pius3e2d6712016-10-06 13:16:23 -07003 *
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
Gabriel Biren631a8112022-12-01 22:29:32 +000019#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 {
Gabriel Biren631a8112022-12-01 22:29:32 +000026namespace V1_6 {
27namespace implementation {
28using hidl_return_util::validateAndCall;
Roshan Pius3e2d6712016-10-06 13:16:23 -070029
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080030WifiP2pIface::WifiP2pIface(const std::string& ifname,
31 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
Roshan Pius3e2d6712016-10-06 13:16:23 -070032 : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
33
34void WifiP2pIface::invalidate() {
Roshan Piusabcf78f2017-10-06 16:30:38 -070035 legacy_hal_.reset();
36 is_valid_ = false;
Roshan Pius3e2d6712016-10-06 13:16:23 -070037}
38
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080039bool WifiP2pIface::isValid() {
40 return is_valid_;
41}
Roshan Pius907d4a22016-10-27 12:48:12 -070042
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080043std::string WifiP2pIface::getName() {
44 return ifname_;
45}
Roshan Pius675609b2017-10-31 14:24:58 -070046
Gabriel Biren631a8112022-12-01 22:29:32 +000047Return<void> WifiP2pIface::getName(getName_cb hidl_status_cb) {
Roshan Piusabcf78f2017-10-06 16:30:38 -070048 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
Gabriel Biren631a8112022-12-01 22:29:32 +000049 &WifiP2pIface::getNameInternal, hidl_status_cb);
Roshan Pius3e2d6712016-10-06 13:16:23 -070050}
51
Gabriel Biren631a8112022-12-01 22:29:32 +000052Return<void> WifiP2pIface::getType(getType_cb hidl_status_cb) {
53 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
54 &WifiP2pIface::getTypeInternal, hidl_status_cb);
Roshan Pius907d4a22016-10-27 12:48:12 -070055}
56
Gabriel Biren631a8112022-12-01 22:29:32 +000057std::pair<WifiStatus, std::string> WifiP2pIface::getNameInternal() {
58 return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
59}
60
61std::pair<WifiStatus, IfaceType> WifiP2pIface::getTypeInternal() {
62 return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P};
63}
64
65} // namespace implementation
66} // namespace V1_6
Roshan Pius3e2d6712016-10-06 13:16:23 -070067} // namespace wifi
68} // namespace hardware
69} // namespace android