diff options
| author | Ningyuan Wang <nywang@google.com> | 2016-08-18 15:26:15 -0700 |
|---|---|---|
| committer | Ningyuan Wang <nywang@google.com> | 2016-08-18 18:03:49 -0700 |
| commit | 14de8b2ce5ef49218e48002a3ac0728847e90372 (patch) | |
| tree | 9c8f9cccc3c164a4f610fd6f0631c4df329f6ef7 /client_interface_impl.cpp | |
| parent | 5a34c89bf63f387c38b5e60e8c733de7051e22ae (diff) | |
| download | platform_system_connectivity_wificond-14de8b2ce5ef49218e48002a3ac0728847e90372.tar.gz platform_system_connectivity_wificond-14de8b2ce5ef49218e48002a3ac0728847e90372.tar.bz2 platform_system_connectivity_wificond-14de8b2ce5ef49218e48002a3ac0728847e90372.zip | |
Monitor scan results for current client interface
This CL includes the following changes:
1. Add functions which can subscribe and unsubscribe scan results
notification in ScanUtils, so we don't need to expose a NetlinkManager
object to ClientInterfaceImpl.
2. ClientInterfaceImpl subscribes the scan results when it is
initialized. It unsubscribes the scan results when it is destroyed.
3. ClientInterfaceImpl requests scan results objects using ScanUtils.
In later CLs these objects are supposed to be sent to java framework
through binder.
4. Add corresponding mock classes and unit tests adjustment for the
changes above.
This CL won't enable the scan results monitoring unless we uncomment
SubscribeToEvents() in NetlinkManager::Start().
BUG=30896985
TEST=compile, unit tests, manual tests
Manual test:
1. Uncomment SubscribeToEvents() in NetlinkManager::Start().
2. Call ScanResult::DebugLog() in ClientInterfaceImpl::
OnScanResultsReady().
After 1 and 2 we can see detail scan results in wificond logs.
Change-Id: I502fb4704ffce4dd2bf8de8d0d5d9293b2b43d9a
Diffstat (limited to 'client_interface_impl.cpp')
| -rw-r--r-- | client_interface_impl.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/client_interface_impl.cpp b/client_interface_impl.cpp index 0adcb42..998daee 100644 --- a/client_interface_impl.cpp +++ b/client_interface_impl.cpp @@ -16,32 +16,41 @@ #include "wificond/client_interface_impl.h" +#include <vector> + #include <android-base/logging.h> #include <wifi_system/wifi.h> #include "wificond/client_interface_binder.h" -#include "wificond/net/netlink_utils.h" +#include "wificond/scanning/scan_result.h" +#include "wificond/scanning/scan_utils.h" using android::net::wifi::IClientInterface; using android::sp; + +using namespace std::placeholders; using std::string; +using std::vector; namespace android { namespace wificond { ClientInterfaceImpl::ClientInterfaceImpl(const std::string& interface_name, - uint32_t interface_index) + uint32_t interface_index, + ScanUtils* scan_utils) : interface_name_(interface_name), interface_index_(interface_index), + scan_utils_(scan_utils), binder_(new ClientInterfaceBinder(this)) { - // This log keeps compiler happy. - LOG(DEBUG) << "Created client interface " << interface_name_ - << " with index " << interface_index_; + scan_utils_->SubscribeScanResultNotification( + interface_index_, + std::bind(&ClientInterfaceImpl::OnScanResultsReady, this, _1, _2, _3)); } ClientInterfaceImpl::~ClientInterfaceImpl() { binder_->NotifyImplDead(); DisableSupplicant(); + scan_utils_->UnsubscribeScanResultNotification(interface_index_); } sp<android::net::wifi::IClientInterface> ClientInterfaceImpl::GetBinder() const { @@ -56,5 +65,17 @@ bool ClientInterfaceImpl::DisableSupplicant() { return (wifi_system::wifi_stop_supplicant() == 0); } +void ClientInterfaceImpl::OnScanResultsReady( + uint32_t interface_index, + std::vector<std::vector<uint8_t>>& ssids, + std::vector<uint32_t>& frequencies) { + vector<ScanResult> scan_results; + // TODO(nywang): Find a way to differentiate scan results for + // internel/external scan request. This is useful when location is + // scanning using regular NL80211 commands. + scan_utils_->GetScanResult(interface_index, &scan_results); + // TODO(nywang): Send these scan results back to java framework. +} + } // namespace wificond } // namespace android |
