@@ -29,9 +29,11 @@ struct PropFlags {
2929 void setSkipSvc () { flags |= 1 ; }
3030 void setPersist () { flags |= (1 << 1 ); }
3131 void setContext () { flags |= (1 << 2 ); }
32+ void setPersistOnly () { flags |= (1 << 3 ); setPersist (); }
3233 bool isSkipSvc () const { return flags & 1 ; }
3334 bool isPersist () const { return flags & (1 << 1 ); }
3435 bool isContext () const { return flags & (1 << 2 ); }
36+ bool isPersistOnly () const { return flags & (1 << 3 ); }
3537private:
3638 uint32_t flags = 0 ;
3739};
@@ -56,12 +58,13 @@ General flags:
5658 -v print verbose output to stderr
5759
5860Read mode flags:
59- -Z get property context instead of value
6061 -p also read persistent props from storage
62+ -P only read persistent props from storage
63+ -Z get property context instead of value
6164
6265Write mode flags:
6366 -n set properties bypassing property_service
64- -p always write persistent props changes to storage
67+ -p always write persistent prop changes to storage
6568
6669)EOF" , arg0);
6770 exit (1 );
@@ -178,10 +181,12 @@ static string get_prop(const char *name, PropFlags flags) {
178181 }
179182
180183 string val;
181- if (auto pi = system_property_find (name)) {
182- prop_to_string cb (val);
183- read_prop_with_cb (pi, &cb);
184- LOGD (" resetprop: get prop [%s]: [%s]\n " , name, val.data ());
184+ if (!flags.isPersistOnly ()) {
185+ if (auto pi = system_property_find (name)) {
186+ prop_to_string cb (val);
187+ read_prop_with_cb (pi, &cb);
188+ LOGD (" resetprop: get prop [%s]: [%s]\n " , name, val.data ());
189+ }
185190 }
186191
187192 if (val.empty () && flags.isPersist () && str_starts (name, " persist." ))
@@ -195,7 +200,8 @@ static string get_prop(const char *name, PropFlags flags) {
195200static void print_props (PropFlags flags) {
196201 prop_list list;
197202 prop_collector collector (list);
198- system_property_foreach (read_prop_with_cb, &collector);
203+ if (!flags.isPersistOnly ())
204+ system_property_foreach (read_prop_with_cb, &collector);
199205 if (flags.isPersist ())
200206 persist_get_props (&collector);
201207 for (auto &[key, val] : list) {
@@ -291,6 +297,9 @@ int resetprop_main(int argc, char *argv[]) {
291297 case ' p' :
292298 flags.setPersist ();
293299 continue ;
300+ case ' P' :
301+ flags.setPersistOnly ();
302+ continue ;
294303 case ' v' :
295304 set_log_level_state (LogLevel::Debug, true );
296305 continue ;
0 commit comments