Add resetprop -w for waiting property change

It's very easy to wait for property change both in Java and C++,
but it's not the case in shell script. With this patch, developers
can now easily to wait for property change, just like what we have
in `.rc` files, and to wait for boot complete.
This commit is contained in:
LoveSy
2023-12-22 01:49:25 +08:00
committed by John Wu
parent 27ece3c7df
commit e94d65b4b2
5 changed files with 45 additions and 18 deletions

View File

@@ -5,14 +5,14 @@
#include <cxx.h>
struct prop_cb {
virtual void exec(const char *name, const char *value) = 0;
virtual void exec(const char *name, const char *value, uint32_t serial) = 0;
};
using prop_list = std::map<std::string, std::string>;
struct prop_collector : prop_cb {
explicit prop_collector(prop_list &list) : list(list) {}
void exec(const char *name, const char *value) override {
void exec(const char *name, const char *value, uint32_t) override {
list.insert({name, value});
}
private:
@@ -26,6 +26,6 @@ int delete_prop(const char *name, bool persist = false);
int set_prop(const char *name, const char *value, bool skip_svc = false);
void load_prop_file(const char *filename, bool skip_svc = false);
static inline void prop_cb_exec(prop_cb &cb, const char *name, const char *value) {
cb.exec(name, value);
static inline void prop_cb_exec(prop_cb &cb, const char *name, const char *value, uint32_t serial) {
cb.exec(name, value, serial);
}