blob: b4a2116f2bd9d3f5f4458dbedfc2bfa1cf9c4eed [file] [log] [blame]
Ahmed ElArabawy687ce132022-01-11 16:42:48 -08001/*
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_RTT_CONTROLLER_H_
18#define WIFI_RTT_CONTROLLER_H_
19
20#include <android-base/macros.h>
21#include <android/hardware/wifi/1.0/IWifiIface.h>
22#include <android/hardware/wifi/1.4/IWifiRttController.h>
23#include <android/hardware/wifi/1.4/IWifiRttControllerEventCallback.h>
24
25#include "wifi_legacy_hal.h"
26
27namespace android {
28namespace hardware {
29namespace wifi {
30namespace V1_6 {
31namespace implementation {
32
33/**
34 * HIDL interface object used to control all RTT operations.
35 */
36class WifiRttController : public V1_4::IWifiRttController {
37 public:
38 WifiRttController(const std::string& iface_name, const sp<IWifiIface>& bound_iface,
39 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
40 // Refer to |WifiChip::invalidate()|.
41 void invalidate();
42 bool isValid();
43 std::vector<sp<V1_4::IWifiRttControllerEventCallback>> getEventCallbacks();
44 std::string getIfaceName();
45
46 // HIDL methods exposed.
47 Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
48 Return<void> registerEventCallback(const sp<V1_0::IWifiRttControllerEventCallback>& callback,
49 registerEventCallback_cb hidl_status_cb) override;
50 Return<void> rangeRequest(uint32_t cmd_id, const hidl_vec<V1_0::RttConfig>& rtt_configs,
51 rangeRequest_cb hidl_status_cb) override;
52 Return<void> rangeCancel(uint32_t cmd_id, const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
53 rangeCancel_cb hidl_status_cb) override;
54 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
55 Return<void> setLci(uint32_t cmd_id, const RttLciInformation& lci,
56 setLci_cb hidl_status_cb) override;
57 Return<void> setLcr(uint32_t cmd_id, const RttLcrInformation& lcr,
58 setLcr_cb hidl_status_cb) override;
59 Return<void> getResponderInfo(getResponderInfo_cb hidl_status_cb) override;
60 Return<void> enableResponder(uint32_t cmd_id, const WifiChannelInfo& channel_hint,
61 uint32_t max_duration_seconds, const V1_0::RttResponder& info,
62 enableResponder_cb hidl_status_cb) override;
63 Return<void> disableResponder(uint32_t cmd_id, disableResponder_cb hidl_status_cb) override;
64 Return<void> registerEventCallback_1_4(
65 const sp<V1_4::IWifiRttControllerEventCallback>& callback,
66 registerEventCallback_1_4_cb hidl_status_cb) override;
67 Return<void> rangeRequest_1_4(uint32_t cmd_id, const hidl_vec<V1_4::RttConfig>& rtt_configs,
68 rangeRequest_1_4_cb hidl_status_cb) override;
69 Return<void> getCapabilities_1_4(getCapabilities_1_4_cb hidl_status_cb) override;
70 Return<void> getResponderInfo_1_4(getResponderInfo_1_4_cb hidl_status_cb) override;
71 Return<void> enableResponder_1_4(uint32_t cmd_id, const WifiChannelInfo& channel_hint,
72 uint32_t max_duration_seconds, const V1_4::RttResponder& info,
73 enableResponder_1_4_cb hidl_status_cb) override;
74
75 private:
76 // Corresponding worker functions for the HIDL methods.
77 std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
78 WifiStatus registerEventCallbackInternal(
79 const sp<V1_0::IWifiRttControllerEventCallback>& callback);
80 WifiStatus rangeRequestInternal(uint32_t cmd_id,
81 const std::vector<V1_0::RttConfig>& rtt_configs);
82 WifiStatus rangeCancelInternal(uint32_t cmd_id,
83 const std::vector<hidl_array<uint8_t, 6>>& addrs);
84 std::pair<WifiStatus, V1_0::RttCapabilities> getCapabilitiesInternal();
85 WifiStatus setLciInternal(uint32_t cmd_id, const RttLciInformation& lci);
86 WifiStatus setLcrInternal(uint32_t cmd_id, const RttLcrInformation& lcr);
87 std::pair<WifiStatus, V1_0::RttResponder> getResponderInfoInternal();
88 WifiStatus enableResponderInternal(uint32_t cmd_id, const WifiChannelInfo& channel_hint,
89 uint32_t max_duration_seconds,
90 const V1_0::RttResponder& info);
91 WifiStatus disableResponderInternal(uint32_t cmd_id);
92 WifiStatus registerEventCallbackInternal_1_4(
93 const sp<V1_4::IWifiRttControllerEventCallback>& callback);
94 WifiStatus rangeRequestInternal_1_4(uint32_t cmd_id,
95 const std::vector<V1_4::RttConfig>& rtt_configs);
96 std::pair<WifiStatus, V1_4::RttCapabilities> getCapabilitiesInternal_1_4();
97 std::pair<WifiStatus, V1_4::RttResponder> getResponderInfoInternal_1_4();
98 WifiStatus enableResponderInternal_1_4(uint32_t cmd_id, const WifiChannelInfo& channel_hint,
99 uint32_t max_duration_seconds,
100 const V1_4::RttResponder& info);
101
102 std::string ifname_;
103 sp<IWifiIface> bound_iface_;
104 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
105 std::vector<sp<V1_4::IWifiRttControllerEventCallback>> event_callbacks_;
106 bool is_valid_;
107
108 DISALLOW_COPY_AND_ASSIGN(WifiRttController);
109};
110
111} // namespace implementation
112} // namespace V1_6
113} // namespace wifi
114} // namespace hardware
115} // namespace android
116
117#endif // WIFI_RTT_CONTROLLER_H_