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
17 #include <android-base/logging.h>
18
19 #include "hidl_return_util.h"
20 #include "wifi_p2p_iface.h"
21 #include "wifi_status_util.h"
22
23 namespace android {
24 namespace hardware {
25 namespace wifi {
26 namespace V1_3 {
27 namespace implementation {
28 using hidl_return_util::validateAndCall;
29
WifiP2pIface(const std::string & ifname,const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)30 WifiP2pIface::WifiP2pIface(
31 const std::string& ifname,
32 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
33 : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
34
invalidate()35 void WifiP2pIface::invalidate() {
36 legacy_hal_.reset();
37 is_valid_ = false;
38 }
39
isValid()40 bool WifiP2pIface::isValid() { return is_valid_; }
41
getName()42 std::string WifiP2pIface::getName() { return ifname_; }
43
getName(getName_cb hidl_status_cb)44 Return<void> WifiP2pIface::getName(getName_cb hidl_status_cb) {
45 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
46 &WifiP2pIface::getNameInternal, hidl_status_cb);
47 }
48
getType(getType_cb hidl_status_cb)49 Return<void> WifiP2pIface::getType(getType_cb hidl_status_cb) {
50 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
51 &WifiP2pIface::getTypeInternal, hidl_status_cb);
52 }
53
getNameInternal()54 std::pair<WifiStatus, std::string> WifiP2pIface::getNameInternal() {
55 return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
56 }
57
getTypeInternal()58 std::pair<WifiStatus, IfaceType> WifiP2pIface::getTypeInternal() {
59 return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P};
60 }
61
62 } // namespace implementation
63 } // namespace V1_3
64 } // namespace wifi
65 } // namespace hardware
66 } // namespace android
67