diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-09-25 15:53:40 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-09-25 15:53:40 +0000 |
commit | ed71033637dfcffcf7d50d17c375cfac96d5a610 (patch) | |
tree | 8dc8476454ef625324011473f70a058d61d875bd | |
parent | 80aa1aaab3c6bdda277da6a47aff02431178e6d0 (diff) | |
parent | ef00e78a52488dcd4c194710afb9c371c46754cb (diff) | |
download | device_generic_goldfish-ed71033637dfcffcf7d50d17c375cfac96d5a610.tar.gz device_generic_goldfish-ed71033637dfcffcf7d50d17c375cfac96d5a610.tar.bz2 device_generic_goldfish-ed71033637dfcffcf7d50d17c375cfac96d5a610.zip |
Snap for 6863807 from ef00e78a52488dcd4c194710afb9c371c46754cb to rvc-d2-release
Change-Id: If78c80e30833e9fe23d66d2e1fea9558dda7826d
-rw-r--r-- | init.ranchu.rc | 3 | ||||
-rw-r--r-- | wifi/wifi_hal/Android.bp | 1 | ||||
-rw-r--r-- | wifi/wifi_hal/interface.cpp | 24 | ||||
-rw-r--r-- | wifi/wifi_hal/netlinkmessage.cpp | 37 | ||||
-rw-r--r-- | wifi/wifi_hal/netlinkmessage.h | 3 |
5 files changed, 25 insertions, 43 deletions
diff --git a/init.ranchu.rc b/init.ranchu.rc index d2e5bded..9be9885b 100644 --- a/init.ranchu.rc +++ b/init.ranchu.rc @@ -62,8 +62,7 @@ on boot setprop ro.opengles.version ${ro.kernel.qemu.opengles.version} setprop ro.zygote.disable_gl_preload 1 - # 0: omx; 4: c2 default now - setprop debug.stagefright.ccodec 4 + setprop debug.stagefright.ccodec 0 setprop debug.stagefright.ccodec ${ro.kernel.qemu.media.ccodec} setprop dalvik.vm.heapsize 192m diff --git a/wifi/wifi_hal/Android.bp b/wifi/wifi_hal/Android.bp index 88c1e30d..64310034 100644 --- a/wifi/wifi_hal/Android.bp +++ b/wifi/wifi_hal/Android.bp @@ -28,6 +28,7 @@ cc_library_static { "wifi_hal.cpp", ], shared_libs: [ + "libnl", "liblog", "libcutils", "libhardware_legacy", diff --git a/wifi/wifi_hal/interface.cpp b/wifi/wifi_hal/interface.cpp index 7c683e52..47d81543 100644 --- a/wifi/wifi_hal/interface.cpp +++ b/wifi/wifi_hal/interface.cpp @@ -86,6 +86,9 @@ wifi_error Interface::getName(char* name, size_t size) { return WIFI_SUCCESS; } +// Wifi legacy HAL implicitly assumes getLinkStats is blocking and +// handler will be set to nullptr immediately after invocation. +// Therefore, this function will wait until onLinkStatsReply is called. wifi_error Interface::getLinkStats(wifi_request_id requestId, wifi_stats_result_handler handler) { NetlinkMessage message(RTM_GETLINK, mNetlink.getSequenceNumber()); @@ -97,12 +100,21 @@ wifi_error Interface::getLinkStats(wifi_request_id requestId, info->ifi_flags = 0; info->ifi_change = 0xFFFFFFFF; - bool success = mNetlink.sendMessage(message, - std::bind(&Interface::onLinkStatsReply, - this, - requestId, - handler, - std::placeholders::_1)); + std::condition_variable condition; + std::mutex mutex; + std::unique_lock<std::mutex> lock(mutex); + bool stopped = false; + auto callback = [this, requestId, &handler, + &mutex, &condition, &stopped] (const NetlinkMessage& message) { + stopped = true; + std::unique_lock<std::mutex> lock(mutex); + onLinkStatsReply(requestId, handler, message); + condition.notify_all(); + }; + bool success = mNetlink.sendMessage(message, callback); + while (!stopped) { + condition.wait(lock); + } return success ? WIFI_SUCCESS : WIFI_ERROR_UNKNOWN; } diff --git a/wifi/wifi_hal/netlinkmessage.cpp b/wifi/wifi_hal/netlinkmessage.cpp index baf5800d..06bb7438 100644 --- a/wifi/wifi_hal/netlinkmessage.cpp +++ b/wifi/wifi_hal/netlinkmessage.cpp @@ -22,6 +22,7 @@ #include <linux/rtnetlink.h> #include <sys/types.h> #include <unistd.h> +#include <netlink/msg.h> size_t getSpaceForMessageType(uint16_t type) { switch (type) { @@ -51,13 +52,12 @@ NetlinkMessage::NetlinkMessage(const char* data, size_t size) bool NetlinkMessage::getAttribute(int attributeId, void* data, size_t size) const { const void* value = nullptr; - uint16_t attrSize = 0; - if (!findAttribute(attributeId, &value, &attrSize)) { - return false; - } - if (size > attrSize) { + const auto attr = nlmsg_find_attr((struct nlmsghdr*)mData.data(), sizeof(ifinfomsg), attributeId); + if (!attr) { return false; } + value = (const uint8_t*) attr + NLA_HDRLEN; + size = attr->nla_len; memcpy(data, value, size); return true; } @@ -71,30 +71,3 @@ uint32_t NetlinkMessage::sequence() const { auto header = reinterpret_cast<const nlmsghdr*>(mData.data()); return header->nlmsg_seq; } - -bool NetlinkMessage::findAttribute(int attributeId, - const void** value, - uint16_t* size) const { - const uint8_t* end = mData.data() + mData.size(); - size_t attrOffset = getSpaceForMessageType(type()); - if (attrOffset == 0) { - return false; - } - const uint8_t* attribute = mData.data() + attrOffset; - while (attribute < end) { - auto header = reinterpret_cast<const nlattr*>(attribute); - if (header->nla_len == 0) { - // The length should include the header so the length should always - // be greater than zero. If it doesn't we're going to end up looping - // forever so ignore this. - return false; - } - if (header->nla_type == attributeId) { - *value = attribute + NLA_HDRLEN; - *size = header->nla_len; - return true; - } - attribute += header->nla_len; - } - return false; -} diff --git a/wifi/wifi_hal/netlinkmessage.h b/wifi/wifi_hal/netlinkmessage.h index 45fd7cdb..5e1a3b80 100644 --- a/wifi/wifi_hal/netlinkmessage.h +++ b/wifi/wifi_hal/netlinkmessage.h @@ -60,9 +60,6 @@ private: NetlinkMessage& operator=(const NetlinkMessage&) = delete; bool getAttribute(int attributeId, void* data, size_t size) const; - bool findAttribute(int attributeId, - const void** value, - uint16_t* size) const; std::vector<uint8_t> mData; }; |