diff options
author | Christopher Wiley <wiley@google.com> | 2016-08-30 01:12:36 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-08-30 01:12:36 +0000 |
commit | 7bdf8840fddd728320a6213c2f53ba5088d2998e (patch) | |
tree | 45318063c0346605e230cadc255686d6e7e4debb | |
parent | c5a48b920f300474680b2f914aa5769695c959ec (diff) | |
parent | ac5801814e6acf7468d3a274aba498f1df44c68c (diff) | |
download | platform_packages_apps_Test_connectivity-7bdf8840fddd728320a6213c2f53ba5088d2998e.tar.gz platform_packages_apps_Test_connectivity-7bdf8840fddd728320a6213c2f53ba5088d2998e.tar.bz2 platform_packages_apps_Test_connectivity-7bdf8840fddd728320a6213c2f53ba5088d2998e.zip |
Merge commit '891717b' into nyc-dev-plus-aosp
am: ac5801814e
Change-Id: If53e2221f5330971c3600520559e0ab960cb1523
-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); }; |