From dd2bb2b2fb04c8be32b83236bc211db63571a542 Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Sat, 14 Mar 2026 19:23:19 +0800 Subject: [PATCH] Update resetprop to support --compact --- native/src/core/resetprop/cli.rs | 22 +++++++++++++++++++++- native/src/core/resetprop/mod.rs | 12 ++++++++++++ native/src/external/system_properties | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/native/src/core/resetprop/cli.rs b/native/src/core/resetprop/cli.rs index 1e241ba8b..f8f0a8aa1 100644 --- a/native/src/core/resetprop/cli.rs +++ b/native/src/core/resetprop/cli.rs @@ -27,6 +27,8 @@ struct ResetProp { context: bool, #[argh(switch, short = 'n', long = none)] skip_svc: bool, + #[argh(switch, short = 'c', long = "compact")] + compact: bool, #[argh(option, short = 'f')] file: Option, #[argh(option, short = 'd', long = "delete")] @@ -59,6 +61,7 @@ General flags: -h,--help show this message -v,--verbose print verbose output to stderr -w switch to wait mode + -c,--compact compact property area (optional: context label) Read mode flags: -p also read persistent properties from storage @@ -177,6 +180,16 @@ impl ResetProp { ret } + fn compact(&self) -> bool { + if let Some(context) = self.args.first() { + debug!("resetprop: compact property area [{context}]"); + SYS_PROP.compact_context(context) + } else { + debug!("resetprop: compact property area"); + SYS_PROP.compact() + } + } + fn wait(&self) { let key = &self.args[0]; let val = self.args.get(1).map(|s| &**s); @@ -227,7 +240,11 @@ impl ResetProp { } fn run(self) -> LoggedResult<()> { - if self.wait_mode { + if self.compact { + if !self.compact() { + return log_err!(); + } + } else if self.wait_mode { self.wait(); } else if let Some(file) = &self.file { self.load_file(file)?; @@ -269,6 +286,9 @@ pub fn resetprop_main(argc: i32, argv: *mut *mut c_char) -> i32 { } special_mode += 1; } + if cli.compact { + special_mode += 1; + } if cli.file.is_some() { special_mode += 1; } diff --git a/native/src/core/resetprop/mod.rs b/native/src/core/resetprop/mod.rs index 3380951b2..efda02999 100644 --- a/native/src/core/resetprop/mod.rs +++ b/native/src/core/resetprop/mod.rs @@ -82,6 +82,10 @@ unsafe extern "C" { fn sys_prop_delete(key: CharPtr, prune: bool) -> i32; #[link_name = "__system_property_get_context"] fn sys_prop_get_context(key: CharPtr) -> CharPtr; + #[link_name = "__system_property_compact"] + fn sys_prop_compact() -> bool; + #[link_name = "__system_property_compact_context"] + fn sys_prop_compact_context(context: CharPtr) -> bool; #[link_name = "__system_property_area_serial2"] fn sys_prop_area_serial() -> u32; } @@ -175,6 +179,14 @@ impl SysProp { unsafe { Utf8CStr::from_ptr_unchecked(sys_prop_get_context(key.as_ptr())) } } + fn compact(&self) -> bool { + unsafe { sys_prop_compact() } + } + + fn compact_context(&self, context: &Utf8CStr) -> bool { + unsafe { sys_prop_compact_context(context.as_ptr()) } + } + fn area_serial(&self) -> u32 { unsafe { sys_prop_area_serial() } } diff --git a/native/src/external/system_properties b/native/src/external/system_properties index b7c208856..47eb97d6a 160000 --- a/native/src/external/system_properties +++ b/native/src/external/system_properties @@ -1 +1 @@ -Subproject commit b7c2088565fbe13d22fe074960332e89615bb4aa +Subproject commit 47eb97d6aedf20bf4656f75f98bb01482ab729b0