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 | #ifndef WIFI_STA_IFACE_H_ |
| 18 | #define WIFI_STA_IFACE_H_ |
| 19 | |
| 20 | #include <android-base/macros.h> |
| 21 | #include <android/hardware/wifi/1.0/IWifiStaIface.h> |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 22 | #include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.h> |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 23 | |
| 24 | #include "wifi_legacy_hal.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace hardware { |
| 28 | namespace wifi { |
| 29 | namespace V1_0 { |
| 30 | namespace implementation { |
| 31 | |
| 32 | /** |
| 33 | * HIDL interface object used to control a STA Iface instance. |
| 34 | */ |
| 35 | class WifiStaIface : public IWifiStaIface { |
| 36 | public: |
| 37 | WifiStaIface(const std::string& ifname, |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 38 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 39 | // Refer to |WifiChip::invalidate()|. |
| 40 | void invalidate(); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 41 | bool isValid(); |
Roshan Pius | 970f031 | 2016-12-05 15:25:51 -0800 | [diff] [blame] | 42 | std::vector<sp<IWifiStaIfaceEventCallback>> getEventCallbacks(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 43 | |
| 44 | // HIDL methods exposed. |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 45 | Return<void> getName(getName_cb hidl_status_cb) override; |
| 46 | Return<void> getType(getType_cb hidl_status_cb) override; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 47 | Return<void> registerEventCallback( |
| 48 | const sp<IWifiStaIfaceEventCallback>& callback, |
| 49 | registerEventCallback_cb hidl_status_cb) override; |
| 50 | Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override; |
| 51 | Return<void> getApfPacketFilterCapabilities( |
| 52 | getApfPacketFilterCapabilities_cb hidl_status_cb) override; |
| 53 | Return<void> installApfPacketFilter( |
| 54 | uint32_t cmd_id, |
| 55 | const hidl_vec<uint8_t>& program, |
| 56 | installApfPacketFilter_cb hidl_status_cb) override; |
| 57 | Return<void> getBackgroundScanCapabilities( |
| 58 | getBackgroundScanCapabilities_cb hidl_status_cb) override; |
| 59 | Return<void> getValidFrequenciesForBackgroundScan( |
| 60 | StaBackgroundScanBand band, |
| 61 | getValidFrequenciesForBackgroundScan_cb hidl_status_cb) override; |
| 62 | Return<void> startBackgroundScan( |
| 63 | uint32_t cmd_id, |
| 64 | const StaBackgroundScanParameters& params, |
| 65 | startBackgroundScan_cb hidl_status_cb) override; |
| 66 | Return<void> stopBackgroundScan( |
| 67 | uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override; |
| 68 | Return<void> enableLinkLayerStatsCollection( |
| 69 | bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override; |
| 70 | Return<void> disableLinkLayerStatsCollection( |
| 71 | disableLinkLayerStatsCollection_cb hidl_status_cb) override; |
| 72 | Return<void> getLinkLayerStats(getLinkLayerStats_cb hidl_status_cb) override; |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 73 | Return<void> startRssiMonitoring( |
| 74 | uint32_t cmd_id, |
| 75 | int32_t max_rssi, |
| 76 | int32_t min_rssi, |
| 77 | startRssiMonitoring_cb hidl_status_cb) override; |
| 78 | Return<void> stopRssiMonitoring( |
| 79 | uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override; |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame^] | 80 | Return<void> getRoamingCapabilities( |
| 81 | getRoamingCapabilities_cb hidl_status_cb) override; |
| 82 | Return<void> configureRoaming(const StaRoamingConfig& config, |
| 83 | configureRoaming_cb hidl_status_cb) override; |
| 84 | Return<void> setRoamingState(StaRoamingState state, |
| 85 | setRoamingState_cb hidl_status_cb) override; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 86 | Return<void> startDebugPacketFateMonitoring( |
| 87 | startDebugPacketFateMonitoring_cb hidl_status_cb) override; |
| 88 | Return<void> stopDebugPacketFateMonitoring( |
| 89 | stopDebugPacketFateMonitoring_cb hidl_status_cb) override; |
| 90 | Return<void> getDebugTxPacketFates( |
| 91 | getDebugTxPacketFates_cb hidl_status_cb) override; |
| 92 | Return<void> getDebugRxPacketFates( |
| 93 | getDebugRxPacketFates_cb hidl_status_cb) override; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 94 | |
| 95 | private: |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 96 | // Corresponding worker functions for the HIDL methods. |
| 97 | std::pair<WifiStatus, std::string> getNameInternal(); |
| 98 | std::pair<WifiStatus, IfaceType> getTypeInternal(); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 99 | WifiStatus registerEventCallbackInternal( |
| 100 | const sp<IWifiStaIfaceEventCallback>& callback); |
| 101 | std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); |
| 102 | std::pair<WifiStatus, StaApfPacketFilterCapabilities> |
| 103 | getApfPacketFilterCapabilitiesInternal(); |
| 104 | WifiStatus installApfPacketFilterInternal( |
| 105 | uint32_t cmd_id, const std::vector<uint8_t>& program); |
| 106 | std::pair<WifiStatus, StaBackgroundScanCapabilities> |
| 107 | getBackgroundScanCapabilitiesInternal(); |
| 108 | std::pair<WifiStatus, std::vector<WifiChannelInMhz>> |
| 109 | getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band); |
| 110 | WifiStatus startBackgroundScanInternal( |
| 111 | uint32_t cmd_id, const StaBackgroundScanParameters& params); |
| 112 | WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); |
| 113 | WifiStatus enableLinkLayerStatsCollectionInternal(bool debug); |
| 114 | WifiStatus disableLinkLayerStatsCollectionInternal(); |
| 115 | std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal(); |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 116 | WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, |
| 117 | int32_t max_rssi, |
| 118 | int32_t min_rssi); |
| 119 | WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame^] | 120 | std::pair<WifiStatus, StaRoamingCapabilities> |
| 121 | getRoamingCapabilitiesInternal(); |
| 122 | WifiStatus configureRoamingInternal(const StaRoamingConfig& config); |
| 123 | WifiStatus setRoamingStateInternal(StaRoamingState state); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 124 | WifiStatus startDebugPacketFateMonitoringInternal(); |
| 125 | WifiStatus stopDebugPacketFateMonitoringInternal(); |
| 126 | std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> |
| 127 | getDebugTxPacketFatesInternal(); |
| 128 | std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> |
| 129 | getDebugRxPacketFatesInternal(); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 130 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 131 | std::string ifname_; |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 132 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 133 | std::vector<sp<IWifiStaIfaceEventCallback>> event_callbacks_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 134 | bool is_valid_; |
| 135 | |
| 136 | DISALLOW_COPY_AND_ASSIGN(WifiStaIface); |
| 137 | }; |
| 138 | |
| 139 | } // namespace implementation |
| 140 | } // namespace V1_0 |
| 141 | } // namespace wifi |
| 142 | } // namespace hardware |
| 143 | } // namespace android |
| 144 | |
| 145 | #endif // WIFI_STA_IFACE_H_ |