Skip to content

Commit ecc4e1b

Browse files
committed
Update resetprop to support --compact
1 parent 1d4fbd9 commit ecc4e1b

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

native/src/core/resetprop/cli.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct ResetProp {
2727
context: bool,
2828
#[argh(switch, short = 'n', long = none)]
2929
skip_svc: bool,
30+
#[argh(switch, short = 'c', long = "compact")]
31+
compact: bool,
3032
#[argh(option, short = 'f')]
3133
file: Option<Utf8CString>,
3234
#[argh(option, short = 'd', long = "delete")]
@@ -59,6 +61,7 @@ General flags:
5961
-h,--help show this message
6062
-v,--verbose print verbose output to stderr
6163
-w switch to wait mode
64+
-c,--compact compact property area
6265
6366
Read mode flags:
6467
-p also read persistent properties from storage
@@ -177,6 +180,11 @@ impl ResetProp {
177180
ret
178181
}
179182

183+
fn compact(&self) -> bool {
184+
debug!("resetprop: compact property area");
185+
SYS_PROP.compact()
186+
}
187+
180188
fn wait(&self) {
181189
let key = &self.args[0];
182190
let val = self.args.get(1).map(|s| &**s);
@@ -227,7 +235,11 @@ impl ResetProp {
227235
}
228236

229237
fn run(self) -> LoggedResult<()> {
230-
if self.wait_mode {
238+
if self.compact {
239+
if !self.compact() {
240+
return log_err!();
241+
}
242+
} else if self.wait_mode {
231243
self.wait();
232244
} else if let Some(file) = &self.file {
233245
self.load_file(file)?;
@@ -269,6 +281,9 @@ pub fn resetprop_main(argc: i32, argv: *mut *mut c_char) -> i32 {
269281
}
270282
special_mode += 1;
271283
}
284+
if cli.compact {
285+
special_mode += 1;
286+
}
272287
if cli.file.is_some() {
273288
special_mode += 1;
274289
}

native/src/core/resetprop/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ unsafe extern "C" {
8282
fn sys_prop_delete(key: CharPtr, prune: bool) -> i32;
8383
#[link_name = "__system_property_get_context"]
8484
fn sys_prop_get_context(key: CharPtr) -> CharPtr;
85+
#[link_name = "__system_property_compact"]
86+
fn sys_prop_compact() -> bool;
8587
#[link_name = "__system_property_area_serial2"]
8688
fn sys_prop_area_serial() -> u32;
8789
}
@@ -175,6 +177,10 @@ impl SysProp {
175177
unsafe { Utf8CStr::from_ptr_unchecked(sys_prop_get_context(key.as_ptr())) }
176178
}
177179

180+
fn compact(&self) -> bool {
181+
unsafe { sys_prop_compact() }
182+
}
183+
178184
fn area_serial(&self) -> u32 {
179185
unsafe { sys_prop_area_serial() }
180186
}

0 commit comments

Comments
 (0)