client_interface_binder.cpp \
client_interface_impl.cpp \
looper_backed_event_loop.cpp \
+ rtt/rtt_controller_binder.cpp \
+ rtt/rtt_controller_impl.cpp \
scanning/scan_result.cpp \
scanning/scan_utils.cpp \
server.cpp
aidl/android/net/wifi/IANQPDoneCallback.aidl \
aidl/android/net/wifi/IClientInterface.aidl \
aidl/android/net/wifi/IInterfaceEventCallback.aidl \
+ aidl/android/net/wifi/IRttClient.aidl \
+ aidl/android/net/wifi/IRttController.aidl \
aidl/android/net/wifi/IWificond.aidl
LOCAL_SHARED_LIBRARIES := \
libbinder
--- /dev/null
+/*
+ * 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.
+ */
+
+package android.net.wifi;
+
+interface IRttClient {
+ // TODO(nywang) add functions
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+package android.net.wifi;
+
+interface IRttController {
+ // TODO(nywang) add functions
+}
import android.net.wifi.IApInterface;
import android.net.wifi.IClientInterface;
import android.net.wifi.IInterfaceEventCallback;
+import android.net.wifi.IRttClient;
+import android.net.wifi.IRttController;
// Service interface that exposes primitives for controlling the WiFi
// subsystems of a device.
// @param callback object to remove from the set of registered callbacks.
oneway void UnregisterCallback(IInterfaceEventCallback callback);
+ // Obtain a reference to a IRttController that can be used to
+ // request ranging information.
+ // Results will be returned via the registered IRttClient.
+ IRttController registerRttClient(IRttClient rttClient);
+
+ // Remove an IRttClient from the set of registered IRttClient callbacks.
+ // @param rttClient object to remove from the set of registered
+ // IRttClient callbacks.
+ void unregisterRttClient(IRttClient rttClient);
}
--- /dev/null
+/*
+ * 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 "wificond/rtt/rtt_controller_binder.h"
+
+#include "wificond/rtt/rtt_controller_impl.h"
+
+namespace android {
+namespace wificond {
+
+RttControllerBinder::RttControllerBinder(RttControllerImpl* impl) : impl_{impl} {
+}
+
+RttControllerBinder::~RttControllerBinder() {
+}
+
+} // namespace wificond
+} // namespace android
--- /dev/null
+/*
+ * 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 WIFICOND_RTT_CONTROLLER_BINDER_H_
+#define WIFICOND_RTT_CONTROLLER_BINDER_H_
+
+#include <android-base/macros.h>
+#include <binder/Status.h>
+
+#include "android/net/wifi/BnRttController.h"
+
+namespace android {
+namespace wificond {
+
+class RttControllerImpl;
+
+class RttControllerBinder : public android::net::wifi::BnRttController {
+ public:
+ explicit RttControllerBinder(RttControllerImpl* impl);
+ ~RttControllerBinder() override;
+
+ // Called by |impl_| its destruction.
+ // This informs the binder proxy that no future manipulations of |impl_|
+ // by remote processes are possible.
+ void NotifyImplDead() { impl_ = nullptr; }
+
+ private:
+ RttControllerImpl* impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(RttControllerBinder);
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_RTT_CONTROLLER_BINDER_H_
--- /dev/null
+/*
+ * 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 "wificond/rtt/rtt_controller_impl.h"
+
+#include <android-base/logging.h>
+
+#include "wificond/rtt/rtt_controller_binder.h"
+
+using android::net::wifi::IRttClient;
+using android::net::wifi::IRttController;
+using android::sp;
+
+namespace android {
+namespace wificond {
+
+RttControllerImpl::RttControllerImpl()
+ : binder_(new RttControllerBinder(this)) {
+ // TODO(nywang): create a HAL RttController object.
+}
+
+RttControllerImpl::~RttControllerImpl() {
+ binder_->NotifyImplDead();
+}
+
+sp<IRttController> RttControllerImpl::GetBinder() const {
+ return binder_;
+}
+
+bool RttControllerImpl::RegisterRttClient(android::sp<IRttClient> client) {
+ for (auto& it : clients_) {
+ if (IRttClient::asBinder(client) == IRttClient::asBinder(it)) {
+ LOG(WARNING) << "Ignore duplicate RttClient registration";
+ return false;
+ }
+ }
+ clients_.push_back(client);
+ return true;
+
+}
+
+bool RttControllerImpl::UnregisterRttClient(android::sp<IRttClient> client) {
+ for (auto it = clients_.begin(); it != clients_.end(); it++) {
+ if (IRttClient::asBinder(client) == IRttClient::asBinder(*it)) {
+ clients_.erase(it);
+ return true;
+ }
+ }
+ LOG(WARNING) << "Failed to find registered RttClient to unregister";
+ return false;
+}
+
+size_t RttControllerImpl::GetClientCount() const {
+ return clients_.size();
+}
+
+} // namespace wificond
+} // namespace android
--- /dev/null
+/*
+ * 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 WIFICOND_RTT_CONTROLLER_IMPL_H_
+#define WIFICOND_RTT_CONTROLLER_IMPL_H_
+
+#include <vector>
+
+#include <android-base/macros.h>
+
+#include "android/net/wifi/IRttController.h"
+#include "android/net/wifi/IRttClient.h"
+
+namespace android {
+namespace wificond {
+
+class RttControllerBinder;
+
+class RttControllerImpl {
+ public:
+ RttControllerImpl();
+ ~RttControllerImpl();
+
+ bool RegisterRttClient(android::sp<android::net::wifi::IRttClient> client);
+ bool UnregisterRttClient(android::sp<android::net::wifi::IRttClient> client);
+ size_t GetClientCount() const;
+
+ // Get a pointer to the binder representing this RttControllerImpl.
+ android::sp<android::net::wifi::IRttController> GetBinder() const;
+
+ private:
+ const android::sp<RttControllerBinder> binder_;
+ std::vector<android::sp<android::net::wifi::IRttClient>> clients_;
+
+ DISALLOW_COPY_AND_ASSIGN(RttControllerImpl);
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_RTT_CONTROLLER_IMPL_H_
using android::net::wifi::IApInterface;
using android::net::wifi::IClientInterface;
using android::net::wifi::IInterfaceEventCallback;
+using android::net::wifi::IRttClient;
+using android::net::wifi::IRttController;
using android::wifi_hal::DriverTool;
using android::wifi_system::HalTool;
using android::wifi_system::HostapdManager;
return Status::ok();
}
+Status Server::registerRttClient(const sp<IRttClient>& rtt_client,
+ sp<IRttController>* out_rtt_controller) {
+ if (rtt_controller_ == nullptr) {
+ rtt_controller_.reset(new RttControllerImpl());
+ }
+ rtt_controller_->RegisterRttClient(rtt_client);
+
+ *out_rtt_controller = rtt_controller_->GetBinder();
+ return Status::ok();
+}
+
+Status Server::unregisterRttClient(const sp<IRttClient>& rttClient) {
+ rtt_controller_->UnregisterRttClient(rttClient);
+ if (rtt_controller_->GetClientCount() == 0) {
+ rtt_controller_.reset();
+ }
+ return Status::ok();
+}
Status Server::createApInterface(sp<IApInterface>* created_interface) {
string interface_name;
#include "wificond/ap_interface_impl.h"
#include "wificond/client_interface_impl.h"
+#include "wificond/rtt/rtt_controller_impl.h"
namespace android {
namespace wificond {
const android::sp<android::net::wifi::IInterfaceEventCallback>&
callback) override;
+ android::binder::Status registerRttClient(
+ const ::android::sp<::android::net::wifi::IRttClient>& rtt_client,
+ ::android::sp<::android::net::wifi::IRttController>*
+ out_rtt_controller) override;
+
+ android::binder::Status unregisterRttClient(
+ const ::android::sp<::android::net::wifi::IRttClient>&
+ rttClient) override;
+
android::binder::Status createApInterface(
android::sp<android::net::wifi::IApInterface>*
created_interface) override;
std::vector<android::sp<android::net::wifi::IInterfaceEventCallback>>
interface_event_callbacks_;
+ std::unique_ptr<RttControllerImpl> rtt_controller_;
+
DISALLOW_COPY_AND_ASSIGN(Server);
};