xref: /aosp_15_r20/hardware/interfaces/wifi/aidl/default/wifi_p2p_iface.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1 /*
2  * Copyright (C) 2022 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 
17 #include "wifi_p2p_iface.h"
18 
19 #include <android-base/logging.h>
20 
21 #include "aidl_return_util.h"
22 #include "wifi_status_util.h"
23 
24 namespace aidl {
25 namespace android {
26 namespace hardware {
27 namespace wifi {
28 using aidl_return_util::validateAndCall;
29 
WifiP2pIface(const std::string & ifname,const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)30 WifiP2pIface::WifiP2pIface(const std::string& ifname,
31                            const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
32     : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
33 
invalidate()34 void WifiP2pIface::invalidate() {
35     legacy_hal_.reset();
36     is_valid_ = false;
37 }
38 
isValid()39 bool WifiP2pIface::isValid() {
40     return is_valid_;
41 }
42 
getName()43 std::string WifiP2pIface::getName() {
44     return ifname_;
45 }
46 
getName(std::string * _aidl_return)47 ndk::ScopedAStatus WifiP2pIface::getName(std::string* _aidl_return) {
48     return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
49                            &WifiP2pIface::getNameInternal, _aidl_return);
50 }
51 
getNameInternal()52 std::pair<std::string, ndk::ScopedAStatus> WifiP2pIface::getNameInternal() {
53     return {ifname_, ndk::ScopedAStatus::ok()};
54 }
55 
56 }  // namespace wifi
57 }  // namespace hardware
58 }  // namespace android
59 }  // namespace aidl
60