ap_interface_binder.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #include "wificond/ap_interface_binder.h"
  17. #include <android-base/logging.h>
  18. #include "wificond/ap_interface_impl.h"
  19. using android::net::wifi::IApInterfaceEventCallback;
  20. namespace android {
  21. namespace wificond {
  22. ApInterfaceBinder::ApInterfaceBinder(ApInterfaceImpl* impl)
  23. : impl_{impl}, ap_interface_event_callback_(nullptr) {}
  24. ApInterfaceBinder::~ApInterfaceBinder() {
  25. }
  26. void ApInterfaceBinder::NotifyNumAssociatedStationsChanged(int num_stations) {
  27. if (ap_interface_event_callback_ != nullptr) {
  28. ap_interface_event_callback_->onNumAssociatedStationsChanged(num_stations);
  29. }
  30. }
  31. void ApInterfaceBinder::NotifySoftApChannelSwitched(
  32. int frequency, ChannelBandwidth channel_bandwidth) {
  33. if (ap_interface_event_callback_ == nullptr) {
  34. return;
  35. }
  36. int bandwidth;
  37. switch (channel_bandwidth) {
  38. case ChannelBandwidth::BW_INVALID:
  39. bandwidth = IApInterfaceEventCallback::BANDWIDTH_INVALID;
  40. break;
  41. case ChannelBandwidth::BW_20_NOHT:
  42. bandwidth = IApInterfaceEventCallback::BANDWIDTH_20_NOHT;
  43. break;
  44. case ChannelBandwidth::BW_20:
  45. bandwidth = IApInterfaceEventCallback::BANDWIDTH_20;
  46. break;
  47. case ChannelBandwidth::BW_40:
  48. bandwidth = IApInterfaceEventCallback::BANDWIDTH_40;
  49. break;
  50. case ChannelBandwidth::BW_80:
  51. bandwidth = IApInterfaceEventCallback::BANDWIDTH_80;
  52. break;
  53. case ChannelBandwidth::BW_80P80:
  54. bandwidth = IApInterfaceEventCallback::BANDWIDTH_80P80;
  55. break;
  56. case ChannelBandwidth::BW_160:
  57. bandwidth = IApInterfaceEventCallback::BANDWIDTH_160;
  58. break;
  59. default:
  60. bandwidth = IApInterfaceEventCallback::BANDWIDTH_INVALID;
  61. }
  62. ap_interface_event_callback_->onSoftApChannelSwitched(frequency, bandwidth);
  63. }
  64. binder::Status ApInterfaceBinder::registerCallback(
  65. const sp<IApInterfaceEventCallback>& callback, bool* out_success) {
  66. *out_success = true;
  67. ap_interface_event_callback_ = callback;
  68. return binder::Status::ok();
  69. }
  70. binder::Status ApInterfaceBinder::getInterfaceName(std::string* out_name) {
  71. *out_name = impl_->GetInterfaceName();
  72. return binder::Status::ok();
  73. }
  74. binder::Status ApInterfaceBinder::getNumberOfAssociatedStations(
  75. int* out_num_of_stations) {
  76. *out_num_of_stations = impl_->GetNumberOfAssociatedStations();
  77. return binder::Status::ok();
  78. }
  79. } // namespace wificond
  80. } // namespace android