Expose persist prop API

This commit is contained in:
topjohnwu 2018-11-03 00:15:21 -04:00
parent 1eb7d7b7a8
commit a7824af5a8
3 changed files with 11 additions and 18 deletions

View File

@ -16,7 +16,7 @@ char *getprop2(const char *name, int persist);
int deleteprop(const char *name);
int deleteprop2(const char *name, const int persist);
int read_prop_file(const char* filename, const int trigger);
void getprop_all(void (*callback)(const char *, const char *, void *), void *cookie);
void getprop_all(void (*callback)(const char *, const char *, void *), void *cookie, int persist);
#ifdef __cplusplus
}

View File

@ -133,11 +133,10 @@ static void kill_process(const char *name) {
void clean_magisk_props() {
LOGD("hide_utils: Cleaning magisk props\n");
getprop_all([] (const char *name, auto, auto) -> void
{
if (strstr(name, "magisk"))
deleteprop2(name, 0);
}, nullptr);
getprop_all([](const char *name, auto, auto) -> void {
if (strstr(name, "magisk"))
deleteprop2(name, 0);
}, nullptr, 0);
}
static int add_list(sqlite3 *db, char *proc) {

View File

@ -1,9 +1,3 @@
/* resetprop.cpp - Manipulate any system props
*
* Copyright 2016 nkk71 <nkk71x@gmail.com>
* Copyright 2016 topjohnwu <topjohnwu@gmail.com>
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -120,11 +114,7 @@ static int init_resetprop() {
static void print_props(int persist) {
auto prop_list = Array<prop_t>();
getprop_all(collect_props, &prop_list);
if (persist) {
read_cb_t read_cb(collect_unique_props, &prop_list);
persist_getprop_all(&read_cb);
}
getprop_all(collect_props, &prop_list, persist);
prop_list.sort();
for (auto &prop : prop_list)
printf("[%s]: [%s]\n", prop.name, prop.value);
@ -167,10 +157,14 @@ char *getprop2(const char *name, int persist) {
}
}
void getprop_all(void (*callback)(const char *, const char *, void *), void *cookie) {
void getprop_all(void (*callback)(const char *, const char *, void *), void *cookie, int persist) {
if (init_resetprop()) return;
read_cb_t read_cb(callback, cookie);
__system_property_foreach(read_props, &read_cb);
if (persist) {
read_cb.cb = collect_unique_props;
persist_getprop_all(&read_cb);
}
}
int setprop(const char *name, const char *value) {