diff options
Diffstat (limited to 'wifi')
| -rw-r--r-- | wifi/1.3/default/wifi_chip.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/wifi/1.3/default/wifi_chip.cpp b/wifi/1.3/default/wifi_chip.cpp index 727aac534..3697d50b5 100644 --- a/wifi/1.3/default/wifi_chip.cpp +++ b/wifi/1.3/default/wifi_chip.cpp @@ -114,7 +114,7 @@ bool removeOldFilesInternal() { std::unique_ptr<DIR, decltype(&closedir)> dir_dump( opendir(kTombstoneFolderPath), closedir); if (!dir_dump) { - LOG(ERROR) << "Failed to open directory: " << strerror(errno); + PLOG(ERROR) << "Failed to open directory"; return false; } struct dirent* dp; @@ -128,8 +128,7 @@ bool removeOldFilesInternal() { struct stat cur_file_stat; std::string cur_file_path = kTombstoneFolderPath + cur_file_name; if (stat(cur_file_path.c_str(), &cur_file_stat) == -1) { - LOG(ERROR) << "Failed to get file stat for " << cur_file_path - << ": " << strerror(errno); + PLOG(ERROR) << "Failed to get file stat for " << cur_file_path; success = false; continue; } @@ -144,7 +143,7 @@ bool removeOldFilesInternal() { if (cur_file_count > kMaxRingBufferFileNum || cur_file.first < delete_files_before) { if (unlink(cur_file.second.c_str()) != 0) { - LOG(ERROR) << "Error deleting file " << strerror(errno); + PLOG(ERROR) << "Error deleting file"; success = false; } cur_file_count--; @@ -168,13 +167,11 @@ bool cpioWriteHeader(int out_fd, struct stat& st, const char* file_name, major(st.st_dev), minor(st.st_dev), major(st.st_rdev), minor(st.st_rdev), static_cast<uint32_t>(file_name_len), 0); if (write(out_fd, read_buf.data(), llen) == -1) { - LOG(ERROR) << "Error writing cpio header to file " << file_name << " " - << strerror(errno); + PLOG(ERROR) << "Error writing cpio header to file " << file_name; return false; } if (write(out_fd, file_name, file_name_len) == -1) { - LOG(ERROR) << "Error writing filename to file " << file_name << " " - << strerror(errno); + PLOG(ERROR) << "Error writing filename to file " << file_name; return false; } @@ -183,8 +180,7 @@ bool cpioWriteHeader(int out_fd, struct stat& st, const char* file_name, if (llen != 0) { const uint32_t zero = 0; if (write(out_fd, &zero, 4 - llen) == -1) { - LOG(ERROR) << "Error padding 0s to file " << file_name << " " - << strerror(errno); + PLOG(ERROR) << "Error padding 0s to file " << file_name; return false; } } @@ -200,17 +196,17 @@ size_t cpioWriteFileContent(int fd_read, int out_fd, struct stat& st) { while (llen > 0) { ssize_t bytes_read = read(fd_read, read_buf.data(), read_buf.size()); if (bytes_read == -1) { - LOG(ERROR) << "Error reading file " << strerror(errno); + PLOG(ERROR) << "Error reading file"; return ++n_error; } llen -= bytes_read; if (write(out_fd, read_buf.data(), bytes_read) == -1) { - LOG(ERROR) << "Error writing data to file " << strerror(errno); + PLOG(ERROR) << "Error writing data to file"; return ++n_error; } if (bytes_read == 0) { // this should never happen, but just in case // to unstuck from while loop - LOG(ERROR) << "Unexpected read result for " << strerror(errno); + PLOG(ERROR) << "Unexpected read result"; n_error++; break; } @@ -219,7 +215,7 @@ size_t cpioWriteFileContent(int fd_read, int out_fd, struct stat& st) { if (llen != 0) { const uint32_t zero = 0; if (write(out_fd, &zero, 4 - llen) == -1) { - LOG(ERROR) << "Error padding 0s to file " << strerror(errno); + PLOG(ERROR) << "Error padding 0s to file"; return ++n_error; } } @@ -234,7 +230,7 @@ bool cpioWriteFileTrailer(int out_fd) { sprintf(read_buf.data(), "070701%040X%056X%08XTRAILER!!!", 1, 0x0b, 0) + 4) == -1) { - LOG(ERROR) << "Error writing trailing bytes " << strerror(errno); + PLOG(ERROR) << "Error writing trailing bytes"; return false; } return true; @@ -249,7 +245,7 @@ size_t cpioArchiveFilesInDir(int out_fd, const char* input_dir) { std::unique_ptr<DIR, decltype(&closedir)> dir_dump(opendir(input_dir), closedir); if (!dir_dump) { - LOG(ERROR) << "Failed to open directory: " << strerror(errno); + PLOG(ERROR) << "Failed to open directory"; return ++n_error; } while ((dp = readdir(dir_dump.get()))) { @@ -263,15 +259,13 @@ size_t cpioArchiveFilesInDir(int out_fd, const char* input_dir) { struct stat st; const std::string cur_file_path = kTombstoneFolderPath + cur_file_name; if (stat(cur_file_path.c_str(), &st) == -1) { - LOG(ERROR) << "Failed to get file stat for " << cur_file_path - << ": " << strerror(errno); + PLOG(ERROR) << "Failed to get file stat for " << cur_file_path; n_error++; continue; } const int fd_read = open(cur_file_path.c_str(), O_RDONLY); if (fd_read == -1) { - LOG(ERROR) << "Failed to open file " << cur_file_path << " " - << strerror(errno); + PLOG(ERROR) << "Failed to open file " << cur_file_path; n_error++; continue; } @@ -1158,6 +1152,16 @@ WifiStatus WifiChip::handleChipConfiguration( // This probably is not a critical failure? LOG(ERROR) << "Failed to register radio mode change callback"; } + // Extract and save the version information into property. + std::pair<WifiStatus, IWifiChip::ChipDebugInfo> version_info; + version_info = WifiChip::requestChipDebugInfoInternal(); + if (WifiStatusCode::SUCCESS == version_info.first.code) { + property_set("vendor.wlan.firmware.version", + version_info.second.firmwareDescription.c_str()); + property_set("vendor.wlan.driver.version", + version_info.second.driverDescription.c_str()); + } + return createWifiStatus(WifiStatusCode::SUCCESS); } @@ -1373,14 +1377,14 @@ bool WifiChip::writeRingbufferFilesInternal() { kTombstoneFolderPath + item.first + "XXXXXXXXXX"; const int dump_fd = mkstemp(makeCharVec(file_path_raw).data()); if (dump_fd == -1) { - LOG(ERROR) << "create file failed: " << strerror(errno); + 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) { - LOG(ERROR) << "Error writing to file " << strerror(errno); + PLOG(ERROR) << "Error writing to file"; } } } |
