mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 19:37:39 +00:00
Support only read properties from storage
This commit is contained in:
parent
dc61033b2c
commit
91773c3311
@ -29,9 +29,11 @@ struct PropFlags {
|
||||
void setSkipSvc() { flags |= 1; }
|
||||
void setPersist() { flags |= (1 << 1); }
|
||||
void setContext() { flags |= (1 << 2); }
|
||||
void setPersistOnly() { flags |= (1 << 3); setPersist(); }
|
||||
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); }
|
||||
private:
|
||||
uint32_t flags = 0;
|
||||
};
|
||||
@ -56,12 +58,13 @@ General flags:
|
||||
-v print verbose output to stderr
|
||||
|
||||
Read mode flags:
|
||||
-Z get property context instead of value
|
||||
-p also read persistent props from storage
|
||||
-P only read persistent props from storage
|
||||
-Z get property context instead of value
|
||||
|
||||
Write mode flags:
|
||||
-n set properties bypassing property_service
|
||||
-p always write persistent props changes to storage
|
||||
-p always write persistent prop changes to storage
|
||||
|
||||
)EOF", arg0);
|
||||
exit(1);
|
||||
@ -178,11 +181,13 @@ static string get_prop(const char *name, PropFlags flags) {
|
||||
}
|
||||
|
||||
string val;
|
||||
if (!flags.isPersistOnly()) {
|
||||
if (auto pi = system_property_find(name)) {
|
||||
prop_to_string cb(val);
|
||||
read_prop_with_cb(pi, &cb);
|
||||
LOGD("resetprop: get prop [%s]: [%s]\n", name, val.data());
|
||||
}
|
||||
}
|
||||
|
||||
if (val.empty() && flags.isPersist() && str_starts(name, "persist."))
|
||||
val = persist_get_prop(name);
|
||||
@ -195,6 +200,7 @@ static string get_prop(const char *name, PropFlags flags) {
|
||||
static void print_props(PropFlags flags) {
|
||||
prop_list list;
|
||||
prop_collector collector(list);
|
||||
if (!flags.isPersistOnly())
|
||||
system_property_foreach(read_prop_with_cb, &collector);
|
||||
if (flags.isPersist())
|
||||
persist_get_props(&collector);
|
||||
@ -291,6 +297,9 @@ int resetprop_main(int argc, char *argv[]) {
|
||||
case 'p':
|
||||
flags.setPersist();
|
||||
continue;
|
||||
case 'P':
|
||||
flags.setPersistOnly();
|
||||
continue;
|
||||
case 'v':
|
||||
set_log_level_state(LogLevel::Debug, true);
|
||||
continue;
|
||||
|
@ -15,7 +15,7 @@ using prop_list = std::map<std::string, std::string>;
|
||||
struct prop_collector : prop_cb {
|
||||
explicit prop_collector(prop_list &list) : list(list) {}
|
||||
void exec(const char *name, const char *value) override {
|
||||
list.insert_or_assign(name, value);
|
||||
list.insert({name, value});
|
||||
}
|
||||
private:
|
||||
prop_list &list;
|
||||
|
Loading…
x
Reference in New Issue
Block a user