From 1f33ddcbce7aba434f707ac3e9065f2b8cf8eed3 Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Wed, 1 Jan 2025 23:18:49 +0800 Subject: [PATCH 1/2] Add resetprop option to avoid triggering system_property_wait() --- native/src/core/resetprop/resetprop.cpp | 9 +++++++++ native/src/external/system_properties | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/native/src/core/resetprop/resetprop.cpp b/native/src/core/resetprop/resetprop.cpp index b39c07e90196..4159e880cf10 100644 --- a/native/src/core/resetprop/resetprop.cpp +++ b/native/src/core/resetprop/resetprop.cpp @@ -36,11 +36,13 @@ struct PropFlags { void setContext() { flags |= (1 << 2); } void setPersistOnly() { flags |= (1 << 3); setPersist(); } void setWait() { flags |= (1 << 4); } + void setSkipWait() { flags |= (1 << 5); } bool isSkipSvc() const { return flags & 1; } bool isPersist() const { return flags & (1 << 1); } bool isContext() const { return flags & (1 << 2); } bool isPersistOnly() const { return flags & (1 << 3); } bool isWait() const { return flags & (1 << 4); } + bool isSkipWait() const { return flags & (1 << 5); } private: uint32_t flags = 0; }; @@ -77,6 +79,8 @@ Read mode flags: Write mode flags: -n set properties bypassing property_service + -s set properties bypassing property_service and avoid triggering + system_property_wait -p always write persistent prop changes to storage )EOF", arg0); @@ -167,6 +171,8 @@ static int set_prop(const char *name, const char *value, PropFlags flags) { if (pi != nullptr) { if (flags.isSkipSvc()) { ret = __system_property_update(pi, value, strlen(value)); + } else if (flags.isSkipWait()) { + ret = __system_property_update(pi, value, strlen(value), true); } else { ret = system_property_set(name, value); } @@ -358,6 +364,9 @@ int resetprop_main(int argc, char *argv[]) { case 'P': flags.setPersistOnly(); continue; + case 's': + flags.setSkipWait(); + continue; case 'v': set_log_level_state(LogLevel::Debug, true); continue; diff --git a/native/src/external/system_properties b/native/src/external/system_properties index cabe129f5472..0db6aae04b47 160000 --- a/native/src/external/system_properties +++ b/native/src/external/system_properties @@ -1 +1 @@ -Subproject commit cabe129f5472ca10af82f3147fd8916d45b7d74e +Subproject commit 0db6aae04b4799d5b7e3cb31e4886e459deb04f8 From a19bf8269ce9fd8a7931b3245a70aeb8d6daac5c Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Thu, 2 Jan 2025 20:16:17 +0800 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 残页 --- native/src/core/resetprop/resetprop.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/src/core/resetprop/resetprop.cpp b/native/src/core/resetprop/resetprop.cpp index 4159e880cf10..f0445311ae1b 100644 --- a/native/src/core/resetprop/resetprop.cpp +++ b/native/src/core/resetprop/resetprop.cpp @@ -169,10 +169,10 @@ static int set_prop(const char *name, const char *value, PropFlags flags) { int ret; if (pi != nullptr) { - if (flags.isSkipSvc()) { - ret = __system_property_update(pi, value, strlen(value)); - } else if (flags.isSkipWait()) { + if (flags.isSkipWait()) { ret = __system_property_update(pi, value, strlen(value), true); + } else if (flags.isSkipSvc()) { + ret = __system_property_update(pi, value, strlen(value)); } else { ret = system_property_set(name, value); }