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