diff options
author | Christopher Wiley <wiley@google.com> | 2016-06-27 08:59:53 -0700 |
---|---|---|
committer | Mitchell Wills <mwills@google.com> | 2016-08-29 15:24:08 -0700 |
commit | 891717b67018483387cab44683a069f4989f19a6 (patch) | |
tree | 45318063c0346605e230cadc255686d6e7e4debb | |
parent | cb9748fe5a57ba5e2a1c1b25d15d8e4f7fd48945 (diff) | |
download | platform_packages_apps_Test_connectivity-891717b67018483387cab44683a069f4989f19a6.tar.gz platform_packages_apps_Test_connectivity-891717b67018483387cab44683a069f4989f19a6.tar.bz2 platform_packages_apps_Test_connectivity-891717b67018483387cab44683a069f4989f19a6.zip |
Use updated mock-able libwifi-system interfaceandroid-n-mr1-preview-2android-n-mr1-preview-1
While here, replace copy/pasted code with shared functionality.
Bug: 29634806
Change-Id: If1a7b7e8baebdbccb8208bac194d95b4d2649814
-rw-r--r-- | sl4n/facades/wifi/wifi_facade.cpp | 57 | ||||
-rw-r--r-- | sl4n/facades/wifi/wifi_facade.h | 1 |
2 files changed, 7 insertions, 51 deletions
diff --git a/sl4n/facades/wifi/wifi_facade.cpp b/sl4n/facades/wifi/wifi_facade.cpp index e3f8575..f45cf9e 100644 --- a/sl4n/facades/wifi/wifi_facade.cpp +++ b/sl4n/facades/wifi/wifi_facade.cpp @@ -30,7 +30,8 @@ #include <utils/command_receiver.h> #include <utils/common_utils.h> #include <hardware_legacy/wifi_hal.h> -#include <wifi_system/hal.h> +#include <wifi_system/hal_tool.h> +#include <wifi_system/interface_tool.h> #include "wifi_facade.h" @@ -50,20 +51,21 @@ std::tuple<bool, int> WifiFacade::WifiInit() { } bool WifiFacade::WifiStartHal() { + android::wifi_system::InterfaceTool if_tool; if (wifi_hal_handle == NULL) { - if (!android::wifi_system::init_wifi_hal_function_table(&hal_fn)) { + android::wifi_system::HalTool hal_tool; + if (!hal_tool.InitFunctionTable(&hal_fn)) { return false; } - int ret = BringInterfaceUpDown(kWlanInterface, 1); - if (ret != 0) { + if (!if_tool.SetWifiUpState(true)) { return false; } res = hal_fn.wifi_initialize(&wifi_hal_handle); return res == WIFI_SUCCESS; } else { - return BringInterfaceUpDown(kWlanInterface, 1) == 0; + return if_tool.SetWifiUpState(true); } } @@ -146,51 +148,6 @@ std::tuple<int, int> WifiFacade::WifiGetSupportedFeatureSet() { } } -// TODO: copy of set_iface_flags from Wi-Fi JNI. Consolidate into a support -// library. -int WifiFacade::BringInterfaceUpDown(const char *ifname, int dev_up) { - struct ifreq ifr; - int ret; - int sock = socket(PF_INET, SOCK_DGRAM, 0); - if (sock < 0) { - LOG(ERROR) << "Bad socket: " << sock; - return -errno; - } - - memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); - - if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) { - ret = errno ? -errno : -999; - LOG(ERROR) << "Could not read interface " << ifname << " flags: " << errno; - close(sock); - return ret; - } - - if (dev_up) { - if (ifr.ifr_flags & IFF_UP) { - close(sock); - return 0; - } - ifr.ifr_flags |= IFF_UP; - } else { - if (!(ifr.ifr_flags & IFF_UP)) { - close(sock); - return 0; - } - ifr.ifr_flags &= ~IFF_UP; - } - - if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) { - LOG(ERROR) << "Could not set interface " << ifname << " flags: " << errno; - ret = errno ? -errno : -999; - close(sock); - return ret; - } - close(sock); - return 0; -} - ////////////////// // wrappers ///////////////// diff --git a/sl4n/facades/wifi/wifi_facade.h b/sl4n/facades/wifi/wifi_facade.h index d78ab66..c028c5b 100644 --- a/sl4n/facades/wifi/wifi_facade.h +++ b/sl4n/facades/wifi/wifi_facade.h @@ -46,5 +46,4 @@ class WifiFacade { bool SharedValidator(); bool WifiStartHal(); bool WifiGetInterfaces(); - int BringInterfaceUpDown(const char *ifname, int dev_up); }; |