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
76f81ece
Commit
76f81ece
authored
Apr 27, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix verbose output
parent
495654f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
resetprop.cpp
jni/resetprop/resetprop.cpp
+20
-16
No files found.
jni/resetprop/resetprop.cpp
View file @
76f81ece
...
...
@@ -68,11 +68,15 @@ int resetprop_main(int argc, char *argv[]);
int
main
(
int
argc
,
char
*
argv
[])
{
return
resetprop_main
(
argc
,
argv
);
}
#define
LOG
D(...) if (verbose) printf(__VA_ARGS__)
#define
LOG
E(...) fprintf(stderr, __VA_ARGS__)
#define
PRINT_
D(...) if (verbose) printf(__VA_ARGS__)
#define
PRINT_
E(...) fprintf(stderr, __VA_ARGS__)
#else
#include "magisk.h"
#define PRINT_D(...) { LOGD(__VA_ARGS__); if (verbose) printf(__VA_ARGS__); }
#define PRINT_E(...) { LOGE(__VA_ARGS__); fprintf(stderr, __VA_ARGS__); }
#endif
#include "resetprop.h"
...
...
@@ -117,9 +121,9 @@ static int usage(char* arg0) {
}
int
init_resetprop
()
{
LOG
D
(
"resetprop: Initializing...
\n
"
);
PRINT_
D
(
"resetprop: Initializing...
\n
"
);
if
(
__system_properties_init
())
{
LOG
E
(
"resetprop: Initialize error
\n
"
);
PRINT_
E
(
"resetprop: Initialize error
\n
"
);
return
-
1
;
}
return
0
;
...
...
@@ -133,12 +137,12 @@ static void read_prop_info(void* cookie, const char *name, const char *value, ui
char
*
getprop
(
const
char
*
name
)
{
const
prop_info
*
pi
=
__system_property_find
(
name
);
if
(
pi
==
NULL
)
{
LOG
E
(
"resetprop: prop not found: [%s]
\n
"
,
name
);
PRINT_
E
(
"resetprop: prop not found: [%s]
\n
"
,
name
);
return
NULL
;
}
char
value
[
PROP_VALUE_MAX
];
__system_property_read_callback
(
pi
,
read_prop_info
,
value
);
LOG
D
(
"resetprop: getprop [%s]: [%s]
\n
"
,
name
,
value
);
PRINT_
D
(
"resetprop: getprop [%s]: [%s]
\n
"
,
name
,
value
);
return
strdup
(
value
);
}
...
...
@@ -159,7 +163,7 @@ int setprop2(const char *name, const char *value, int trigger) {
ret
=
__system_property_update
((
prop_info
*
)
__system_property_find
(
name
),
value
,
strlen
(
value
));
}
}
else
{
LOG
D
(
"resetprop: New prop [%s]
\n
"
,
name
);
PRINT_
D
(
"resetprop: New prop [%s]
\n
"
,
name
);
if
(
trigger
)
{
ret
=
__system_property_set
(
name
,
value
);
}
else
{
...
...
@@ -167,29 +171,29 @@ int setprop2(const char *name, const char *value, int trigger) {
}
}
LOG
D
(
"resetprop: setprop [%s]: [%s] by %s
\n
"
,
name
,
value
,
PRINT_
D
(
"resetprop: setprop [%s]: [%s] by %s
\n
"
,
name
,
value
,
trigger
?
"property_service"
:
"modifing prop data structure"
);
if
(
ret
)
LOG
E
(
"resetprop: setprop error
\n
"
);
PRINT_
E
(
"resetprop: setprop error
\n
"
);
return
ret
;
}
int
deleteprop
(
const
char
*
name
)
{
LOG
D
(
"resetprop: deleteprop [%s]
\n
"
,
name
);
PRINT_
D
(
"resetprop: deleteprop [%s]
\n
"
,
name
);
if
(
__system_property_del
(
name
))
{
LOG
E
(
"resetprop: delete prop: [%s] error
\n
"
,
name
);
PRINT_
E
(
"resetprop: delete prop: [%s] error
\n
"
,
name
);
return
-
1
;
}
return
0
;
}
int
read_prop_file
(
const
char
*
filename
)
{
LOG
D
(
"resetprop: Load prop file [%s]
\n
"
,
filename
);
PRINT_
D
(
"resetprop: Load prop file [%s]
\n
"
,
filename
);
FILE
*
fp
=
fopen
(
filename
,
"r"
);
if
(
fp
==
NULL
)
{
LOG
E
(
"Cannot open [%s]
\n
"
,
filename
);
PRINT_
E
(
"Cannot open [%s]
\n
"
,
filename
);
return
1
;
}
char
*
line
=
NULL
,
*
pch
;
...
...
@@ -256,13 +260,13 @@ int resetprop_main(int argc, char *argv[]) {
break
;
}
else
{
if
(
!
is_legal_property_name
(
argv
[
i
],
strlen
(
argv
[
i
])))
{
LOG
E
(
"Illegal property name: [%s]
\n
"
,
argv
[
i
]);
PRINT_
E
(
"Illegal property name: [%s]
\n
"
,
argv
[
i
]);
return
1
;
}
name
=
argv
[
i
];
if
(
exp_arg
>
1
)
{
if
(
strlen
(
argv
[
i
+
1
])
>=
PROP_VALUE_MAX
)
{
LOG
E
(
"Value too long: [%s]
\n
"
,
argv
[
i
+
1
]);
PRINT_
E
(
"Value too long: [%s]
\n
"
,
argv
[
i
+
1
]);
return
1
;
}
value
=
argv
[
i
+
1
];
...
...
@@ -272,7 +276,7 @@ int resetprop_main(int argc, char *argv[]) {
}
}
LOG
D
(
"resetprop by nkk71 & topjohnwu
\n
"
);
PRINT_
D
(
"resetprop by nkk71 & topjohnwu
\n
"
);
if
(
init_resetprop
())
return
-
1
;
...
...
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