mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 06:22:53 +00:00
Synchronize on_ring_buffer_data_callback and writeRingbufferFiles am: 25b3a6f0a4 am: 7a67f397d9
Change-Id: I8db3dc7107f87860f4f5a6c344c50fb60427f0e4
This commit is contained in:
committed by
Automerger Merge Worker
commit
c7c9ccff1a
@@ -1314,13 +1314,18 @@ WifiStatus WifiChip::registerDebugRingBufferCallback() {
|
||||
LOG(ERROR) << "Error converting ring buffer status";
|
||||
return;
|
||||
}
|
||||
const auto& target = shared_ptr_this->ringbuffer_map_.find(name);
|
||||
if (target != shared_ptr_this->ringbuffer_map_.end()) {
|
||||
Ringbuffer& cur_buffer = target->second;
|
||||
cur_buffer.append(data);
|
||||
} else {
|
||||
LOG(ERROR) << "Ringname " << name << " not found";
|
||||
return;
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(shared_ptr_this->lock_t);
|
||||
const auto& target =
|
||||
shared_ptr_this->ringbuffer_map_.find(name);
|
||||
if (target != shared_ptr_this->ringbuffer_map_.end()) {
|
||||
Ringbuffer& cur_buffer = target->second;
|
||||
cur_buffer.append(data);
|
||||
} else {
|
||||
LOG(ERROR) << "Ringname " << name << " not found";
|
||||
return;
|
||||
}
|
||||
// unlock
|
||||
}
|
||||
};
|
||||
legacy_hal::wifi_error legacy_status =
|
||||
@@ -1595,25 +1600,29 @@ bool WifiChip::writeRingbufferFilesInternal() {
|
||||
return false;
|
||||
}
|
||||
// write ringbuffers to file
|
||||
for (const auto& item : ringbuffer_map_) {
|
||||
const Ringbuffer& cur_buffer = item.second;
|
||||
if (cur_buffer.getData().empty()) {
|
||||
continue;
|
||||
}
|
||||
const std::string file_path_raw =
|
||||
kTombstoneFolderPath + item.first + "XXXXXXXXXX";
|
||||
const int dump_fd = mkstemp(makeCharVec(file_path_raw).data());
|
||||
if (dump_fd == -1) {
|
||||
PLOG(ERROR) << "create file failed";
|
||||
return false;
|
||||
}
|
||||
unique_fd file_auto_closer(dump_fd);
|
||||
for (const auto& cur_block : cur_buffer.getData()) {
|
||||
if (write(dump_fd, cur_block.data(),
|
||||
sizeof(cur_block[0]) * cur_block.size()) == -1) {
|
||||
PLOG(ERROR) << "Error writing to file";
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(lock_t);
|
||||
for (const auto& item : ringbuffer_map_) {
|
||||
const Ringbuffer& cur_buffer = item.second;
|
||||
if (cur_buffer.getData().empty()) {
|
||||
continue;
|
||||
}
|
||||
const std::string file_path_raw =
|
||||
kTombstoneFolderPath + item.first + "XXXXXXXXXX";
|
||||
const int dump_fd = mkstemp(makeCharVec(file_path_raw).data());
|
||||
if (dump_fd == -1) {
|
||||
PLOG(ERROR) << "create file failed";
|
||||
return false;
|
||||
}
|
||||
unique_fd file_auto_closer(dump_fd);
|
||||
for (const auto& cur_block : cur_buffer.getData()) {
|
||||
if (write(dump_fd, cur_block.data(),
|
||||
sizeof(cur_block[0]) * cur_block.size()) == -1) {
|
||||
PLOG(ERROR) << "Error writing to file";
|
||||
}
|
||||
}
|
||||
}
|
||||
// unlock
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
#include <android-base/macros.h>
|
||||
#include <android/hardware/wifi/1.4/IWifiChip.h>
|
||||
@@ -272,6 +273,7 @@ class WifiChip : public V1_4::IWifiChip {
|
||||
bool is_valid_;
|
||||
// Members pertaining to chip configuration.
|
||||
uint32_t current_mode_id_;
|
||||
std::mutex lock_t;
|
||||
std::vector<IWifiChip::ChipMode> modes_;
|
||||
// The legacy ring buffer callback API has only a global callback
|
||||
// registration mechanism. Use this to check if we have already
|
||||
|
||||
Reference in New Issue
Block a user