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 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 17 | #include <android-base/logging.h> |
| 18 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
| 20 | #include "wifi_ap_iface.h" |
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 { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 28 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 29 | |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame^] | 30 | WifiApIface::WifiApIface( |
| 31 | const std::string& ifname, |
| 32 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal) |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 33 | : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {} |
| 34 | |
| 35 | void WifiApIface::invalidate() { |
| 36 | legacy_hal_.reset(); |
| 37 | is_valid_ = false; |
| 38 | } |
| 39 | |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 40 | bool WifiApIface::isValid() { |
| 41 | return is_valid_; |
| 42 | } |
| 43 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 44 | Return<void> WifiApIface::getName(getName_cb hidl_status_cb) { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 45 | return validateAndCall(this, |
| 46 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 47 | &WifiApIface::getNameInternal, |
| 48 | hidl_status_cb); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 51 | Return<void> WifiApIface::getType(getType_cb hidl_status_cb) { |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 52 | return validateAndCall(this, |
| 53 | WifiStatusCode::ERROR_WIFI_IFACE_INVALID, |
| 54 | &WifiApIface::getTypeInternal, |
| 55 | hidl_status_cb); |
| 56 | } |
| 57 | |
| 58 | std::pair<WifiStatus, std::string> WifiApIface::getNameInternal() { |
| 59 | return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; |
| 60 | } |
| 61 | |
| 62 | std::pair<WifiStatus, IfaceType> WifiApIface::getTypeInternal() { |
| 63 | return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::AP}; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | } // namespace implementation |
| 67 | } // namespace V1_0 |
| 68 | } // namespace wifi |
| 69 | } // namespace hardware |
| 70 | } // namespace android |