wifi: Add WifiRttController object
Create the WifiRttController object and add the createRttController
method in WifiChip.
Bug: 31991232
Test: Compiles
Change-Id: I34649097c96488c660bef5acceac1a6478f80dca
diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk
index ecb16e2..3fd5fba 100644
--- a/wifi/1.0/default/Android.mk
+++ b/wifi/1.0/default/Android.mk
@@ -25,6 +25,7 @@
wifi_legacy_hal.cpp \
wifi_nan_iface.cpp \
wifi_p2p_iface.cpp \
+ wifi_rtt_controller.cpp \
wifi_sta_iface.cpp
LOCAL_SHARED_LIBRARIES := \
android.hardware.wifi@1.0 \
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
index d0bdd39..82dce94 100644
--- a/wifi/1.0/default/wifi_chip.cpp
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -346,11 +346,30 @@
return Void();
}
+Return<void> WifiChip::createRttController(const sp<IWifiIface>& bound_iface,
+ createRttController_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_);
+ rtt_controllers_.emplace_back(rtt);
+ cb(rtt);
+ return Void();
+}
+
void WifiChip::invalidateAndRemoveAllIfaces() {
invalidateAndClear(ap_iface_);
invalidateAndClear(nan_iface_);
invalidateAndClear(p2p_iface_);
invalidateAndClear(sta_iface_);
+ // Since all the ifaces are invalid now, all RTT controller objects
+ // using those ifaces also need to be invalidated.
+ for (const auto& rtt : rtt_controllers_) {
+ rtt->invalidate();
+ }
+ rtt_controllers_.clear();
}
} // namespace implementation
diff --git a/wifi/1.0/default/wifi_chip.h b/wifi/1.0/default/wifi_chip.h
index d191e8f..94ffa63 100644
--- a/wifi/1.0/default/wifi_chip.h
+++ b/wifi/1.0/default/wifi_chip.h
@@ -26,6 +26,7 @@
#include "wifi_legacy_hal.h"
#include "wifi_nan_iface.h"
#include "wifi_p2p_iface.h"
+#include "wifi_rtt_controller.h"
#include "wifi_sta_iface.h"
namespace android {
@@ -82,6 +83,8 @@
Return<void> getStaIfaceNames(getStaIfaceNames_cb cb) override;
Return<void> getStaIface(const hidl_string& ifname,
getStaIface_cb cb) override;
+ Return<void> createRttController(const sp<IWifiIface>& bound_iface,
+ createRttController_cb cb) override;
private:
void invalidateAndRemoveAllIfaces();
@@ -93,6 +96,7 @@
sp<WifiNanIface> nan_iface_;
sp<WifiP2pIface> p2p_iface_;
sp<WifiStaIface> sta_iface_;
+ std::vector<sp<WifiRttController>> rtt_controllers_;
bool is_valid_;
DISALLOW_COPY_AND_ASSIGN(WifiChip);
diff --git a/wifi/1.0/default/wifi_rtt_controller.cpp b/wifi/1.0/default/wifi_rtt_controller.cpp
new file mode 100644
index 0000000..e2df1a8
--- /dev/null
+++ b/wifi/1.0/default/wifi_rtt_controller.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_rtt_controller.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+WifiRttController::WifiRttController(
+ const sp<IWifiIface>& bound_iface,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal)
+ : bound_iface_(bound_iface), legacy_hal_(legacy_hal), is_valid_(true) {}
+
+void WifiRttController::invalidate() {
+ legacy_hal_.reset();
+ is_valid_ = false;
+}
+
+Return<void> WifiRttController::getBoundIface(getBoundIface_cb cb) {
+ cb(bound_iface_);
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.0/default/wifi_rtt_controller.h b/wifi/1.0/default/wifi_rtt_controller.h
new file mode 100644
index 0000000..8d78b93
--- /dev/null
+++ b/wifi/1.0/default/wifi_rtt_controller.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_RTT_CONTROLLER_H_
+#define WIFI_RTT_CONTROLLER_H_
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifiIface.h>
+#include <android/hardware/wifi/1.0/IWifiRttController.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * HIDL interface object used to control all RTT operations.
+ */
+class WifiRttController : public IWifiRttController {
+ public:
+ WifiRttController(const sp<IWifiIface>& bound_iface,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+
+ // HIDL methods exposed.
+ Return<void> getBoundIface(getBoundIface_cb cb) override;
+
+ private:
+ sp<IWifiIface> bound_iface_;
+ std::weak_ptr<WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(WifiRttController);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // WIFI_RTT_CONTROLLER_H_