blob: 9384cfa890fda4635ceb8454ffb1befe9cff2d62 [file] [log] [blame]
Christopher Wileyf229bbe2016-06-22 17:20:04 -07001/*
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 Wang808c6702016-07-15 16:47:54 -070017#include "wificond/ap_interface_binder.h"
Christopher Wileyf229bbe2016-06-22 17:20:04 -070018
Christopher Wiley1f8dd452016-07-18 15:30:58 -070019#include <android-base/logging.h>
Christopher Wiley1f8dd452016-07-18 15:30:58 -070020
21#include "wificond/ap_interface_impl.h"
22
Etan Cohen067e1192020-02-15 17:36:36 -080023using android::net::wifi::nl80211::IApInterfaceEventCallback;
24using android::net::wifi::nl80211::NativeWifiClient;
Christopher Wiley1f8dd452016-07-18 15:30:58 -070025
Christopher Wileyf229bbe2016-06-22 17:20:04 -070026namespace android {
27namespace wificond {
28
Mehdi Alizadehd69e8412017-09-13 14:26:29 -070029ApInterfaceBinder::ApInterfaceBinder(ApInterfaceImpl* impl)
30 : impl_{impl}, ap_interface_event_callback_(nullptr) {}
Christopher Wileyf229bbe2016-06-22 17:20:04 -070031
32ApInterfaceBinder::~ApInterfaceBinder() {
33}
34
lesl414ba9c2019-12-04 15:33:20 +080035void ApInterfaceBinder::NotifyConnectedClientsChanged(const NativeWifiClient client, bool isConnected) {
Mehdi Alizadehd69e8412017-09-13 14:26:29 -070036 if (ap_interface_event_callback_ != nullptr) {
lesl414ba9c2019-12-04 15:33:20 +080037 ap_interface_event_callback_->onConnectedClientsChanged(client, isConnected);
Mehdi Alizadehd69e8412017-09-13 14:26:29 -070038 }
39}
40
Mehdi Alizadeh4332ce62018-03-14 17:12:34 -070041void 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 ElArabawyb9b95b62021-12-16 14:33:23 -080070 case ChannelBandwidth::BW_320:
71 bandwidth = IApInterfaceEventCallback::BANDWIDTH_320;
72 break;
Mehdi Alizadeh4332ce62018-03-14 17:12:34 -070073 default:
74 bandwidth = IApInterfaceEventCallback::BANDWIDTH_INVALID;
75 }
76 ap_interface_event_callback_->onSoftApChannelSwitched(frequency, bandwidth);
77}
78
Roshan Pius1731b152018-02-11 18:29:22 -080079binder::Status ApInterfaceBinder::registerCallback(
Mehdi Alizadehd69e8412017-09-13 14:26:29 -070080 const sp<IApInterfaceEventCallback>& callback, bool* out_success) {
Roshan Pius1731b152018-02-11 18:29:22 -080081 *out_success = true;
82 ap_interface_event_callback_ = callback;
Christopher Wiley1f8dd452016-07-18 15:30:58 -070083 return binder::Status::ok();
84}
85
Christopher Wiley223dfaa2016-09-26 10:21:16 -070086binder::Status ApInterfaceBinder::getInterfaceName(std::string* out_name) {
Christopher Wiley223dfaa2016-09-26 10:21:16 -070087 *out_name = impl_->GetInterfaceName();
88 return binder::Status::ok();
89}
90
Christopher Wileyf229bbe2016-06-22 17:20:04 -070091} // namespace wificond
92} // namespace android