diff options
-rw-r--r-- | power-libperfmgr/libperfmgr/FileNode.cc | 5 | ||||
-rw-r--r-- | power-libperfmgr/libperfmgr/HintManager.cc | 12 | ||||
-rw-r--r-- | power-libperfmgr/libperfmgr/include/perfmgr/FileNode.h | 4 |
3 files changed, 17 insertions, 4 deletions
diff --git a/power-libperfmgr/libperfmgr/FileNode.cc b/power-libperfmgr/libperfmgr/FileNode.cc index 88417848..05f0746d 100644 --- a/power-libperfmgr/libperfmgr/FileNode.cc +++ b/power-libperfmgr/libperfmgr/FileNode.cc @@ -31,11 +31,12 @@ namespace android { namespace perfmgr { FileNode::FileNode(std::string name, std::string node_path, std::vector<RequestGroup> req_sorted, - std::size_t default_val_index, bool reset_on_init, bool truncate, bool hold_fd) + std::size_t default_val_index, bool reset_on_init, bool truncate, bool hold_fd, bool write_only) : Node(std::move(name), std::move(node_path), std::move(req_sorted), default_val_index, reset_on_init), hold_fd_(hold_fd), truncate_(truncate), + write_only_(write_only), warn_timeout_(android::base::GetBoolProperty("ro.debuggable", false) ? 5ms : 50ms) {} std::chrono::milliseconds FileNode::Update(bool log_error) { @@ -110,7 +111,7 @@ bool FileNode::GetTruncate() const { void FileNode::DumpToFd(int fd) const { std::string node_value; - if (!android::base::ReadFileToString(node_path_, &node_value)) { + if (!write_only_ && !android::base::ReadFileToString(node_path_, &node_value)) { LOG(ERROR) << "Failed to read node path: " << node_path_; } node_value = android::base::Trim(node_value); diff --git a/power-libperfmgr/libperfmgr/HintManager.cc b/power-libperfmgr/libperfmgr/HintManager.cc index 8c84c685..dd313ef5 100644 --- a/power-libperfmgr/libperfmgr/HintManager.cc +++ b/power-libperfmgr/libperfmgr/HintManager.cc @@ -495,9 +495,19 @@ std::vector<std::unique_ptr<Node>> HintManager::ParseNodes( LOG(VERBOSE) << "Node[" << i << "]'s HoldFd: " << std::boolalpha << hold_fd << std::noboolalpha; + bool write_only = false; + if (nodes[i]["WriteOnly"].empty() || !nodes[i]["WriteOnly"].isBool()) { + LOG(INFO) << "Failed to read Node[" << i + << "]'s WriteOnly, set to 'false'"; + } else { + write_only = nodes[i]["WriteOnly"].asBool(); + } + LOG(VERBOSE) << "Node[" << i << "]'s WriteOnly: " << std::boolalpha + << write_only << std::noboolalpha; + nodes_parsed.emplace_back(std::make_unique<FileNode>( name, path, values_parsed, static_cast<std::size_t>(default_index), reset, - truncate, hold_fd)); + truncate, hold_fd, write_only)); } else { nodes_parsed.emplace_back(std::make_unique<PropertyNode>( name, path, values_parsed, diff --git a/power-libperfmgr/libperfmgr/include/perfmgr/FileNode.h b/power-libperfmgr/libperfmgr/include/perfmgr/FileNode.h index 5e97d276..bb8a2a79 100644 --- a/power-libperfmgr/libperfmgr/include/perfmgr/FileNode.h +++ b/power-libperfmgr/libperfmgr/include/perfmgr/FileNode.h @@ -33,7 +33,7 @@ class FileNode : public Node { public: FileNode(std::string name, std::string node_path, std::vector<RequestGroup> req_sorted, std::size_t default_val_index, bool reset_on_init, bool truncate, - bool hold_fd = false); + bool hold_fd = false, bool write_only = false); std::chrono::milliseconds Update(bool log_error) override; @@ -48,6 +48,8 @@ class FileNode : public Node { const bool hold_fd_; const bool truncate_; + // node will be read in DumpToFd + const bool write_only_; const std::chrono::milliseconds warn_timeout_; android::base::unique_fd fd_; }; |