Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
309b99ea
Commit
309b99ea
authored
Jun 11, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always init for resetprop
parent
a5aa1b39
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
resetprop.cpp
jni/resetprop/resetprop.cpp
+14
-9
resetprop.h
jni/resetprop/resetprop.h
+1
-1
system_properties.cpp
jni/resetprop/system_properties.cpp
+1
-3
No files found.
jni/resetprop/resetprop.cpp
View file @
309b99ea
...
@@ -121,8 +121,7 @@ static int usage(char* arg0) {
...
@@ -121,8 +121,7 @@ static int usage(char* arg0) {
return
1
;
return
1
;
}
}
int
init_resetprop
()
{
static
int
init_resetprop
()
{
PRINT_D
(
"resetprop: Initializing...
\n
"
);
if
(
__system_properties_init2
())
{
if
(
__system_properties_init2
())
{
PRINT_E
(
"resetprop: Initialize error
\n
"
);
PRINT_E
(
"resetprop: Initialize error
\n
"
);
return
-
1
;
return
-
1
;
...
@@ -130,15 +129,21 @@ int init_resetprop() {
...
@@ -130,15 +129,21 @@ int init_resetprop() {
return
0
;
return
0
;
}
}
int
prop_exist
(
const
char
*
name
)
{
if
(
init_resetprop
())
return
0
;
return
__system_property_find2
(
name
)
!=
NULL
;
}
static
void
read_prop_info
(
void
*
cookie
,
const
char
*
name
,
const
char
*
value
,
uint32_t
serial
)
{
static
void
read_prop_info
(
void
*
cookie
,
const
char
*
name
,
const
char
*
value
,
uint32_t
serial
)
{
strcpy
((
char
*
)
cookie
,
value
);
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
)
{
if
(
init_resetprop
())
return
NULL
;
const
prop_info
*
pi
=
__system_property_find2
(
name
);
const
prop_info
*
pi
=
__system_property_find2
(
name
);
if
(
pi
==
NULL
)
{
if
(
pi
==
NULL
)
{
PRINT_D
(
"resetprop:
failed to get [%s]
\n
"
,
name
);
PRINT_D
(
"resetprop:
prop [%s] does not exist
\n
"
,
name
);
return
NULL
;
return
NULL
;
}
}
char
value
[
PROP_VALUE_MAX
];
char
value
[
PROP_VALUE_MAX
];
...
@@ -152,16 +157,16 @@ int setprop(const char *name, const char *value) {
...
@@ -152,16 +157,16 @@ int setprop(const char *name, const char *value) {
}
}
int
setprop2
(
const
char
*
name
,
const
char
*
value
,
const
int
trigger
)
{
int
setprop2
(
const
char
*
name
,
const
char
*
value
,
const
int
trigger
)
{
if
(
init_resetprop
())
return
-
1
;
int
ret
;
int
ret
;
char
*
check
=
getprop
(
name
);
prop_info
*
pi
=
(
prop_info
*
)
__system_property_find2
(
name
);
if
(
check
)
{
if
(
pi
!=
NULL
)
{
free
(
check
);
if
(
trigger
)
{
if
(
trigger
)
{
if
(
!
strncmp
(
name
,
"ro."
,
3
))
deleteprop
(
name
);
if
(
!
strncmp
(
name
,
"ro."
,
3
))
deleteprop
(
name
);
ret
=
__system_property_set2
(
name
,
value
);
ret
=
__system_property_set2
(
name
,
value
);
}
else
{
}
else
{
ret
=
__system_property_update2
(
(
prop_info
*
)
__system_property_find2
(
name
)
,
value
,
strlen
(
value
));
ret
=
__system_property_update2
(
pi
,
value
,
strlen
(
value
));
}
}
}
else
{
}
else
{
PRINT_D
(
"resetprop: New prop [%s]
\n
"
,
name
);
PRINT_D
(
"resetprop: New prop [%s]
\n
"
,
name
);
...
@@ -182,6 +187,7 @@ int setprop2(const char *name, const char *value, const int trigger) {
...
@@ -182,6 +187,7 @@ int setprop2(const char *name, const char *value, const int trigger) {
}
}
int
deleteprop
(
const
char
*
name
)
{
int
deleteprop
(
const
char
*
name
)
{
if
(
init_resetprop
())
return
-
1
;
PRINT_D
(
"resetprop: deleteprop [%s]
\n
"
,
name
);
PRINT_D
(
"resetprop: deleteprop [%s]
\n
"
,
name
);
if
(
__system_property_del
(
name
))
{
if
(
__system_property_del
(
name
))
{
PRINT_E
(
"resetprop: delete prop: [%s] error
\n
"
,
name
);
PRINT_E
(
"resetprop: delete prop: [%s] error
\n
"
,
name
);
...
@@ -191,6 +197,7 @@ int deleteprop(const char *name) {
...
@@ -191,6 +197,7 @@ int deleteprop(const char *name) {
}
}
int
read_prop_file
(
const
char
*
filename
,
const
int
trigger
)
{
int
read_prop_file
(
const
char
*
filename
,
const
int
trigger
)
{
if
(
init_resetprop
())
return
-
1
;
PRINT_D
(
"resetprop: Load prop file [%s]
\n
"
,
filename
);
PRINT_D
(
"resetprop: Load prop file [%s]
\n
"
,
filename
);
FILE
*
fp
=
fopen
(
filename
,
"r"
);
FILE
*
fp
=
fopen
(
filename
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
...
@@ -277,8 +284,6 @@ int resetprop_main(int argc, char *argv[]) {
...
@@ -277,8 +284,6 @@ int resetprop_main(int argc, char *argv[]) {
}
}
}
}
init_resetprop
();
if
(
file
)
{
if
(
file
)
{
return
read_prop_file
(
filename
,
trigger
);
return
read_prop_file
(
filename
,
trigger
);
}
else
if
(
del
)
{
}
else
if
(
del
)
{
...
...
jni/resetprop/resetprop.h
View file @
309b99ea
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int
init_resetprop
(
);
int
prop_exist
(
const
char
*
name
);
int
setprop
(
const
char
*
name
,
const
char
*
value
);
int
setprop
(
const
char
*
name
,
const
char
*
value
);
int
setprop2
(
const
char
*
name
,
const
char
*
value
,
const
int
trigger
);
int
setprop2
(
const
char
*
name
,
const
char
*
value
,
const
int
trigger
);
char
*
getprop
(
const
char
*
name
);
char
*
getprop
(
const
char
*
name
);
...
...
jni/resetprop/system_properties.cpp
View file @
309b99ea
...
@@ -1149,9 +1149,7 @@ int __system_properties_init2() {
...
@@ -1149,9 +1149,7 @@ int __system_properties_init2() {
if
(
initialized
)
{
if
(
initialized
)
{
// list_foreach(contexts, [](context_node* l) { l->reset_access(); }); // resetprop remove
// list_foreach(contexts, [](context_node* l) { l->reset_access(); }); // resetprop remove
// return 0; // resetprop remove
return
0
;
free_and_unmap_contexts
();
// resetprop add
initialized
=
false
;
// resetprop add
}
}
if
(
is_dir
(
property_filename
))
{
if
(
is_dir
(
property_filename
))
{
if
(
!
initialize_properties
())
{
if
(
!
initialize_properties
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment