summaryrefslogtreecommitdiff
path: root/libperfmgr/PropertyNode.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libperfmgr/PropertyNode.cc')
-rw-r--r--libperfmgr/PropertyNode.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/libperfmgr/PropertyNode.cc b/libperfmgr/PropertyNode.cc
index 029849d6..c8067117 100644
--- a/libperfmgr/PropertyNode.cc
+++ b/libperfmgr/PropertyNode.cc
@@ -16,14 +16,14 @@
#define LOG_TAG "libperfmgr"
+#include "perfmgr/PropertyNode.h"
+
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include "perfmgr/PropertyNode.h"
-
namespace android {
namespace perfmgr {
@@ -31,11 +31,7 @@ PropertyNode::PropertyNode(std::string name, std::string node_path,
std::vector<RequestGroup> req_sorted,
std::size_t default_val_index, bool reset_on_init)
: Node(std::move(name), std::move(node_path), std::move(req_sorted),
- default_val_index, reset_on_init) {
- if (reset_on_init) {
- Update(false);
- }
-}
+ default_val_index, reset_on_init) {}
std::chrono::milliseconds PropertyNode::Update(bool) {
std::size_t value_index = default_val_index_;
@@ -50,7 +46,7 @@ std::chrono::milliseconds PropertyNode::Update(bool) {
}
// Update node only if request index changes
- if (value_index != current_val_index_) {
+ if (value_index != current_val_index_ || reset_on_init_) {
const std::string& req_value =
req_sorted_[value_index].GetRequestValue();
@@ -60,6 +56,7 @@ std::chrono::milliseconds PropertyNode::Update(bool) {
} else {
// Update current index only when succeed
current_val_index_ = value_index;
+ reset_on_init_ = false;
}
}
return expire_time;
@@ -73,6 +70,10 @@ void PropertyNode::DumpToFd(int fd) const {
if (!android::base::WriteStringToFd(buf, fd)) {
LOG(ERROR) << "Failed to dump fd: " << fd;
}
+ for (std::size_t i = 0; i < req_sorted_.size(); i++) {
+ req_sorted_[i].DumpToFd(
+ fd, android::base::StringPrintf("\t\tReq%zu:\t", i));
+ }
}
} // namespace perfmgr