Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 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 "wifi_p2p_iface.h" |
| 18 | |
| 19 | #include <android-base/logging.h> |
| 20 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 21 | #include "wifi_status_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace wifi { |
| 26 | namespace V1_0 { |
| 27 | namespace implementation { |
| 28 | |
| 29 | WifiP2pIface::WifiP2pIface(const std::string& ifname, |
| 30 | const std::weak_ptr<WifiLegacyHal> legacy_hal) |
| 31 | : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {} |
| 32 | |
| 33 | void WifiP2pIface::invalidate() { |
| 34 | legacy_hal_.reset(); |
| 35 | is_valid_ = false; |
| 36 | } |
| 37 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 38 | Return<void> WifiP2pIface::getName(getName_cb hidl_status_cb) { |
| 39 | if (!is_valid_) { |
| 40 | hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID), |
| 41 | hidl_string()); |
| 42 | return Void(); |
| 43 | } |
| 44 | hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), ifname_); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 45 | return Void(); |
| 46 | } |
| 47 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 48 | Return<void> WifiP2pIface::getType(getType_cb hidl_status_cb) { |
| 49 | if (!is_valid_) { |
| 50 | hidl_status_cb(createWifiStatus(WifiStatusCode::ERROR_WIFI_IFACE_INVALID), |
| 51 | IfaceType::P2P); |
| 52 | return Void(); |
| 53 | } |
| 54 | hidl_status_cb(createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P); |
| 55 | return Void(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | } // namespace implementation |
| 59 | } // namespace V1_0 |
| 60 | } // namespace wifi |
| 61 | } // namespace hardware |
| 62 | } // namespace android |