Add a sysprop to delay merge by fix duration
Merge is a power consuming process, some products might want to delay
merge after boot by some amount of time. Add a sysprop to configure how
many seconds the merge should be delayed. To prevent the device from
delaying merge indefinitely, this sysprop is capped at 10 minutes.
Bug: 311515963
Test: set ro.virtual_ab.merge_delay_seconds by PRODUCT_PROPERTY_OVERRIDES in mk files and run OTA
Change-Id: I2361dd47221552dbc774c00412c65a22f40bc11d
diff --git a/common/scoped_task_id.h b/common/scoped_task_id.h
index 91a2986..8127d37 100644
--- a/common/scoped_task_id.h
+++ b/common/scoped_task_id.h
@@ -17,6 +17,7 @@
#ifndef UPDATE_ENGINE_SCOPED_TASK_ID_H_
#define UPDATE_ENGINE_SCOPED_TASK_ID_H_
+#include <ostream>
#include <type_traits>
#include <utility>
@@ -35,6 +36,11 @@
ScopedTaskId(const ScopedTaskId&) = delete;
ScopedTaskId& operator=(const ScopedTaskId&) = delete;
+ friend std::ostream& operator<<(std::ostream& out, const ScopedTaskId& task) {
+ out << task.task_id_;
+ return out;
+ }
+
constexpr ScopedTaskId() = default;
constexpr ScopedTaskId(ScopedTaskId&& other) noexcept {
@@ -89,7 +95,6 @@
return task_id_ < other.task_id_;
}
- private:
template <typename Callable>
[[nodiscard]] bool PostTask(const base::Location& from_here,
Callable&& callback,
@@ -107,11 +112,16 @@
delay);
return task_id_ != MessageLoop::kTaskIdNull;
}
+
+ private:
template <typename Callable>
void ExecuteTask(Callable&& callback) {
task_id_ = MessageLoop::kTaskIdNull;
if constexpr (std::is_same_v<Callable&&, base::OnceClosure&&>) {
std::move(callback).Run();
+ } else if constexpr (std::is_same_v<Callable&&,
+ base::RepeatingCallback<void()>&&>) {
+ std::move(callback).Run();
} else {
std::move(callback)();
}