mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 14:58:29 +00:00
Update to newer functions in resetprop
This commit is contained in:
parent
73802aabac
commit
fe89f9e55e
@ -80,7 +80,6 @@ int main(int argc, char *argv[]) {
|
|||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
|
|
||||||
static bool is_legal_property_name(const char* name, size_t namelen) {
|
static bool is_legal_property_name(const char* name, size_t namelen) {
|
||||||
if (namelen >= PROP_NAME_MAX) return false;
|
|
||||||
if (namelen < 1) return false;
|
if (namelen < 1) return false;
|
||||||
if (name[0] == '.') return false;
|
if (name[0] == '.') return false;
|
||||||
if (name[namelen - 1] == '.') return false;
|
if (name[namelen - 1] == '.') return false;
|
||||||
@ -126,14 +125,20 @@ int init_resetprop() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void read_prop_info(void* cookie, const char *name, const char *value, uint32_t serial) {
|
||||||
|
strcpy((char *) cookie, value);
|
||||||
|
}
|
||||||
|
|
||||||
// Get prop by name, return string (should free manually!)
|
// Get prop by name, return string (should free manually!)
|
||||||
char *getprop(const char *name) {
|
char *getprop(const char *name) {
|
||||||
char value[PROP_VALUE_MAX];
|
const prop_info *pi = __system_property_find(name);
|
||||||
LOGD("restprop: getprop [%s]\n", name);
|
if (pi == NULL) {
|
||||||
if (__system_property_get(name, value) == 0) {
|
|
||||||
LOGE("resetprop: prop not found: [%s]\n", name);
|
LOGE("resetprop: prop not found: [%s]\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
char value[PROP_VALUE_MAX];
|
||||||
|
__system_property_read_callback(pi, read_prop_info, value);
|
||||||
|
LOGD("resetprop: getprop [%s]: [%s]\n", name, value);
|
||||||
return strdup(value);
|
return strdup(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +151,6 @@ int setprop2(const char *name, const char *value, int trigger) {
|
|||||||
|
|
||||||
char *check = getprop(name);
|
char *check = getprop(name);
|
||||||
if (check) {
|
if (check) {
|
||||||
LOGD("resetprop: prop [%s] has existing value [%s]\n", name, value);
|
|
||||||
free(check);
|
free(check);
|
||||||
if (trigger) {
|
if (trigger) {
|
||||||
if (!strncmp(name, "ro.", 3)) deleteprop(name);
|
if (!strncmp(name, "ro.", 3)) deleteprop(name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user