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
42284c5e
Commit
42284c5e
authored
Apr 07, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test logcat instead of checking logd
parent
7d7686da
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
23 deletions
+24
-23
log_monitor.c
native/jni/core/log_monitor.c
+16
-15
daemon.h
native/jni/include/daemon.h
+1
-1
logging.h
native/jni/include/logging.h
+1
-1
magiskhide.c
native/jni/magiskhide/magiskhide.c
+6
-6
No files found.
native/jni/core/log_monitor.c
View file @
42284c5e
...
...
@@ -15,7 +15,7 @@
#include "resetprop.h"
extern
int
is_daemon_init
;
int
log
d
=
0
;
int
log
gable
=
1
;
static
int
am_proc_start_filter
(
const
char
*
log
)
{
return
strstr
(
log
,
"am_proc_start"
)
!=
NULL
;
...
...
@@ -49,15 +49,16 @@ struct log_listener log_events[] = {
static
int
debug_log_pid
=
-
1
,
debug_log_fd
=
-
1
;
#endif
static
void
check_logd
()
{
char
*
prop
=
getprop
(
"init.svc.logd"
);
if
(
prop
!=
NULL
)
{
free
(
prop
);
logd
=
1
;
}
else
{
LOGD
(
"log_monitor: logd not started, disable logging"
);
logd
=
0
;
static
void
test_logcat
()
{
int
log_fd
=
-
1
,
log_pid
;
char
buf
[
1
];
log_pid
=
exec_command
(
0
,
&
log_fd
,
NULL
,
"logcat"
,
NULL
);
if
(
read
(
log_fd
,
buf
,
sizeof
(
buf
))
!=
sizeof
(
buf
))
{
loggable
=
0
;
LOGD
(
"log_monitor: cannot read from logcat, disable logging"
);
}
kill
(
log_pid
,
SIGTERM
);
waitpid
(
log_pid
,
NULL
,
0
);
}
static
void
*
logger_thread
(
void
*
args
)
{
...
...
@@ -67,7 +68,7 @@ static void *logger_thread(void *args) {
LOGD
(
"log_monitor: logger start"
);
while
(
1
)
{
if
(
!
log
d
)
{
if
(
!
log
gable
)
{
// Disable all services
for
(
int
i
=
0
;
i
<
(
sizeof
(
log_events
)
/
sizeof
(
struct
log_listener
));
++
i
)
{
close
(
log_events
[
i
].
fd
);
...
...
@@ -98,7 +99,7 @@ static void *logger_thread(void *args) {
// Clear buffer before restart
exec_command_sync
(
"logcat"
,
"-b"
,
"events"
,
"-b"
,
"main"
,
"-c"
,
NULL
);
check_logd
();
test_logcat
();
}
// Should never be here, but well...
...
...
@@ -163,9 +164,9 @@ static void *debug_magisk_log_thread(void *args) {
void
monitor_logs
()
{
pthread_t
thread
;
check_logd
();
test_logcat
();
if
(
log
d
)
{
if
(
log
gable
)
{
// Start log file dumper before monitor
xpthread_create
(
&
thread
,
NULL
,
magisk_log_thread
,
NULL
);
pthread_detach
(
thread
);
...
...
@@ -178,7 +179,7 @@ void monitor_logs() {
void
start_debug_full_log
()
{
#ifdef MAGISK_DEBUG
if
(
log
d
)
{
if
(
log
gable
)
{
// Log everything initially
debug_log_fd
=
xopen
(
DEBUG_LOG
,
O_WRONLY
|
O_CREAT
|
O_CLOEXEC
|
O_TRUNC
,
0644
);
debug_log_pid
=
exec_command
(
0
,
&
debug_log_fd
,
NULL
,
"logcat"
,
"-v"
,
"threadtime"
,
NULL
);
...
...
@@ -201,7 +202,7 @@ void stop_debug_full_log() {
void
start_debug_log
()
{
#ifdef MAGISK_DEBUG
if
(
log
d
)
{
if
(
log
gable
)
{
pthread_t
thread
;
// Start debug thread
xpthread_create
(
&
thread
,
NULL
,
debug_magisk_log_thread
,
NULL
);
...
...
native/jni/include/daemon.h
View file @
42284c5e
...
...
@@ -31,7 +31,7 @@ enum {
DAEMON_ERROR
=
-
1
,
DAEMON_SUCCESS
=
0
,
ROOT_REQUIRED
,
LOG
D
_DISABLED
,
LOG
CAT
_DISABLED
,
HIDE_IS_ENABLED
,
HIDE_NOT_ENABLED
,
HIDE_ITEM_EXIST
,
...
...
native/jni/include/logging.h
View file @
42284c5e
...
...
@@ -58,7 +58,7 @@ struct log_listener {
};
extern
struct
log_listener
log_events
[];
extern
int
log
d
;
extern
int
log
gable
;
void
monitor_logs
();
void
start_debug_full_log
();
...
...
native/jni/magiskhide/magiskhide.c
View file @
42284c5e
...
...
@@ -49,9 +49,9 @@ void launch_magiskhide(int client) {
return
;
}
if
(
!
log
d
)
{
if
(
!
log
gable
)
{
if
(
client
>
0
)
{
write_int
(
client
,
LOG
D
_DISABLED
);
write_int
(
client
,
LOG
CAT
_DISABLED
);
close
(
client
);
}
setprop
(
MAGISKHIDE_PROP
,
"0"
);
...
...
@@ -147,14 +147,14 @@ int magiskhide_main(int argc, char *argv[]) {
case
ROOT_REQUIRED
:
fprintf
(
stderr
,
"Root is required for this operation
\n
"
);
return
code
;
case
LOG
D
_DISABLED
:
fprintf
(
stderr
,
"Log
d is not running, cannot run logcat
\n
"
);
case
LOG
CAT
_DISABLED
:
fprintf
(
stderr
,
"Log
cat is disabled, cannot start MagiskHide
\n
"
);
return
(
code
);
case
HIDE_NOT_ENABLED
:
fprintf
(
stderr
,
"Magisk
h
ide is not enabled yet
\n
"
);
fprintf
(
stderr
,
"Magisk
H
ide is not enabled yet
\n
"
);
return
code
;
case
HIDE_IS_ENABLED
:
fprintf
(
stderr
,
"Magisk
h
ide is already enabled
\n
"
);
fprintf
(
stderr
,
"Magisk
H
ide is already enabled
\n
"
);
return
code
;
case
HIDE_ITEM_EXIST
:
fprintf
(
stderr
,
"Process [%s] already exists in hide list
\n
"
,
argv
[
2
]);
...
...
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