mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Support waiting on non-exist prop
This commit is contained in:
parent
2afcdc64a0
commit
941a363c5a
@ -226,20 +226,23 @@ template<class StringType>
|
|||||||
static StringType wait_prop(const char *name, const char *old_value) {
|
static StringType wait_prop(const char *name, const char *old_value) {
|
||||||
if (!check_legal_property_name(name))
|
if (!check_legal_property_name(name))
|
||||||
return {};
|
return {};
|
||||||
auto pi = system_property_find(name);
|
|
||||||
if (!pi) {
|
const prop_info *pi;
|
||||||
LOGD("resetprop: prop [%s] does not exist\n", name);
|
auto serial = __system_property_area_serial();
|
||||||
return {};
|
while (!(pi = system_property_find(name))) {
|
||||||
|
LOGD("resetprop: waiting for prop [%s] to exist\n", name);
|
||||||
|
system_property_wait(nullptr, serial, &serial, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_to_string<StringType> cb;
|
prop_to_string<StringType> cb;
|
||||||
read_prop_with_cb(pi, &cb);
|
read_prop_with_cb(pi, &cb);
|
||||||
|
|
||||||
if (old_value == nullptr || cb.val == old_value) {
|
while (old_value == nullptr || cb.val == old_value) {
|
||||||
LOGD("resetprop: waiting for prop [%s]\n", name);
|
LOGD("resetprop: waiting for prop [%s]\n", name);
|
||||||
uint32_t new_serial;
|
uint32_t new_serial;
|
||||||
system_property_wait(pi, cb.serial, &new_serial, nullptr);
|
system_property_wait(pi, cb.serial, &new_serial, nullptr);
|
||||||
read_prop_with_cb(pi, &cb);
|
read_prop_with_cb(pi, &cb);
|
||||||
|
if (old_value == nullptr) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGD("resetprop: get prop [%s]: [%s]\n", name, cb.val.c_str());
|
LOGD("resetprop: get prop [%s]: [%s]\n", name, cb.val.c_str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user