Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -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 | |
Ningyuan Wang | 808c670 | 2016-07-15 16:47:54 -0700 | [diff] [blame] | 17 | #include "wificond/ap_interface_binder.h" |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 18 | |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 19 | #include <android-base/logging.h> |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 20 | |
| 21 | #include "wificond/ap_interface_impl.h" |
| 22 | |
Etan Cohen | 067e119 | 2020-02-15 17:36:36 -0800 | [diff] [blame] | 23 | using android::net::wifi::nl80211::IApInterfaceEventCallback; |
| 24 | using android::net::wifi::nl80211::NativeWifiClient; |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 25 | |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 26 | namespace android { |
| 27 | namespace wificond { |
| 28 | |
Mehdi Alizadeh | d69e841 | 2017-09-13 14:26:29 -0700 | [diff] [blame] | 29 | ApInterfaceBinder::ApInterfaceBinder(ApInterfaceImpl* impl) |
| 30 | : impl_{impl}, ap_interface_event_callback_(nullptr) {} |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 31 | |
| 32 | ApInterfaceBinder::~ApInterfaceBinder() { |
| 33 | } |
| 34 | |
lesl | 414ba9c | 2019-12-04 15:33:20 +0800 | [diff] [blame] | 35 | void ApInterfaceBinder::NotifyConnectedClientsChanged(const NativeWifiClient client, bool isConnected) { |
Mehdi Alizadeh | d69e841 | 2017-09-13 14:26:29 -0700 | [diff] [blame] | 36 | if (ap_interface_event_callback_ != nullptr) { |
lesl | 414ba9c | 2019-12-04 15:33:20 +0800 | [diff] [blame] | 37 | ap_interface_event_callback_->onConnectedClientsChanged(client, isConnected); |
Mehdi Alizadeh | d69e841 | 2017-09-13 14:26:29 -0700 | [diff] [blame] | 38 | } |
| 39 | } |
| 40 | |
Mehdi Alizadeh | 4332ce6 | 2018-03-14 17:12:34 -0700 | [diff] [blame] | 41 | void ApInterfaceBinder::NotifySoftApChannelSwitched( |
| 42 | int frequency, ChannelBandwidth channel_bandwidth) { |
| 43 | if (ap_interface_event_callback_ == nullptr) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | int bandwidth; |
| 48 | switch (channel_bandwidth) { |
| 49 | case ChannelBandwidth::BW_INVALID: |
| 50 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_INVALID; |
| 51 | break; |
| 52 | case ChannelBandwidth::BW_20_NOHT: |
| 53 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_20_NOHT; |
| 54 | break; |
| 55 | case ChannelBandwidth::BW_20: |
| 56 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_20; |
| 57 | break; |
| 58 | case ChannelBandwidth::BW_40: |
| 59 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_40; |
| 60 | break; |
| 61 | case ChannelBandwidth::BW_80: |
| 62 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_80; |
| 63 | break; |
| 64 | case ChannelBandwidth::BW_80P80: |
| 65 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_80P80; |
| 66 | break; |
| 67 | case ChannelBandwidth::BW_160: |
| 68 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_160; |
| 69 | break; |
Ahmed ElArabawy | b9b95b6 | 2021-12-16 14:33:23 -0800 | [diff] [blame] | 70 | case ChannelBandwidth::BW_320: |
| 71 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_320; |
| 72 | break; |
Mehdi Alizadeh | 4332ce6 | 2018-03-14 17:12:34 -0700 | [diff] [blame] | 73 | default: |
| 74 | bandwidth = IApInterfaceEventCallback::BANDWIDTH_INVALID; |
| 75 | } |
| 76 | ap_interface_event_callback_->onSoftApChannelSwitched(frequency, bandwidth); |
| 77 | } |
| 78 | |
Roshan Pius | 1731b15 | 2018-02-11 18:29:22 -0800 | [diff] [blame] | 79 | binder::Status ApInterfaceBinder::registerCallback( |
Mehdi Alizadeh | d69e841 | 2017-09-13 14:26:29 -0700 | [diff] [blame] | 80 | const sp<IApInterfaceEventCallback>& callback, bool* out_success) { |
Roshan Pius | 1731b15 | 2018-02-11 18:29:22 -0800 | [diff] [blame] | 81 | *out_success = true; |
| 82 | ap_interface_event_callback_ = callback; |
Christopher Wiley | 1f8dd45 | 2016-07-18 15:30:58 -0700 | [diff] [blame] | 83 | return binder::Status::ok(); |
| 84 | } |
| 85 | |
Christopher Wiley | 223dfaa | 2016-09-26 10:21:16 -0700 | [diff] [blame] | 86 | binder::Status ApInterfaceBinder::getInterfaceName(std::string* out_name) { |
Christopher Wiley | 223dfaa | 2016-09-26 10:21:16 -0700 | [diff] [blame] | 87 | *out_name = impl_->GetInterfaceName(); |
| 88 | return binder::Status::ok(); |
| 89 | } |
| 90 | |
Christopher Wiley | f229bbe | 2016-06-22 17:20:04 -0700 | [diff] [blame] | 91 | } // namespace wificond |
| 92 | } // namespace android |