ipc_constants.cpp \
aidl/android/net/wifi/IApInterface.aidl \
aidl/android/net/wifi/IClientInterface.aidl \
+ aidl/android/net/wifi/IInterfaceEventCallback.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;
+
+import android.net.wifi.IApInterface;
+import android.net.wifi.IClientInterface;
+
+// A callback for receiving events related to this chip.
+interface IInterfaceEventCallback {
+
+ // Signals that the provided interface is ready for future commands.
+ oneway void OnClientInterfaceReady(IClientInterface network_interface);
+ oneway void OnApInterfaceReady(IApInterface network_interface);
+
+ // Signals that an interface was torn down.
+ // No future callbacks will be delivered via this callback, and the callback
+ // is automatically unregistered.
+ oneway void OnClientTorndownEvent();
+ oneway void OnApTorndownEvent();
+}
import android.net.wifi.IApInterface;
import android.net.wifi.IClientInterface;
+import android.net.wifi.IInterfaceEventCallback;
// Service interface that exposes primitives for controlling the WiFi
// subsystems of a device.
// future interfaces immediately after this method returns.
void tearDownInterfaces();
+ // Register a callback to receive interface status updates.
+ //
+ // Multiple callbacks can be registered simultaneously.
+ // Duplicate registrations of the same callback will be ignored.
+ //
+ // @param callback object to add to the set of registered callbacks.
+ oneway void RegisterCallback(IInterfaceEventCallback callback);
+
+ // Remove a callback from the set of registered callbacks.
+ //
+ // This must be the same instance as previously registered.
+ // Requests to remove unknown callbacks will be ignored.
+ //
+ // @param callback object to remove from the set of registered callbacks.
+ oneway void UnregisterCallback(IInterfaceEventCallback callback);
+
}
using std::unique_ptr;
using android::net::wifi::IApInterface;
using android::net::wifi::IClientInterface;
+using android::net::wifi::IInterfaceEventCallback;
using android::wifi_hal::DriverTool;
using android::wifi_system::HalTool;
using android::wifi_system::HostapdManager;
scan_utils_(scan_utils) {
}
+Status Server::RegisterCallback(const sp<IInterfaceEventCallback>& callback) {
+ for (auto& it : interface_event_callbacks_) {
+ if (IInterface::asBinder(callback) == IInterface::asBinder(it)) {
+ LOG(WARNING) << "Ignore duplicate interface event callback registration";
+ return Status::ok();
+ }
+ }
+ LOG(INFO) << "New interface event callback registered";
+ interface_event_callbacks_.push_back(callback);
+ return Status::ok();
+}
+
+Status Server::UnregisterCallback(const sp<IInterfaceEventCallback>& callback) {
+ for (auto it = interface_event_callbacks_.begin();
+ it != interface_event_callbacks_.end();
+ it++) {
+ if (IInterface::asBinder(callback) == IInterface::asBinder(*it)) {
+ interface_event_callbacks_.erase(it);
+ LOG(INFO) << "Unregister interface event callback";
+ return Status::ok();
+ }
+ }
+ LOG(WARNING) << "Failed to find registered interface event callback"
+ << " to unregister";
+ return Status::ok();
+}
+
+
Status Server::createApInterface(sp<IApInterface>* created_interface) {
string interface_name;
uint32_t interface_index;
#include "android/net/wifi/BnWificond.h"
#include "android/net/wifi/IApInterface.h"
#include "android/net/wifi/IClientInterface.h"
+#include "android/net/wifi/IInterfaceEventCallback.h"
#include "wificond/ap_interface_impl.h"
#include "wificond/client_interface_impl.h"
ScanUtils* scan_utils);
~Server() override = default;
+ android::binder::Status RegisterCallback(
+ const android::sp<android::net::wifi::IInterfaceEventCallback>&
+ callback) override;
+ android::binder::Status UnregisterCallback(
+ const android::sp<android::net::wifi::IInterfaceEventCallback>&
+ callback) override;
+
android::binder::Status createApInterface(
android::sp<android::net::wifi::IApInterface>*
created_interface) override;
uint32_t wiphy_index_;
std::vector<std::unique_ptr<ApInterfaceImpl>> ap_interfaces_;
std::vector<std::unique_ptr<ClientInterfaceImpl>> client_interfaces_;
+ std::vector<android::sp<android::net::wifi::IInterfaceEventCallback>>
+ interface_event_callbacks_;
DISALLOW_COPY_AND_ASSIGN(Server);
};