mirror of
https://github.com/topjohnwu/Magisk
synced 2024-11-14 22:28:37 +01:00
Try logging a little harder
This commit is contained in:
parent
f1edc8443c
commit
5be035fd44
@ -468,6 +468,23 @@ void install_apk(const char *apk) {
|
|||||||
unlink(apk);
|
unlink(apk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *start_magisk_hide(void *args) {
|
||||||
|
launch_magiskhide(-1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void auto_start_magiskhide() {
|
||||||
|
if (!check_and_start_logger())
|
||||||
|
return;
|
||||||
|
char *hide_prop = getprop2(MAGISKHIDE_PROP, 1);
|
||||||
|
if (hide_prop == NULL || strcmp(hide_prop, "0") != 0) {
|
||||||
|
pthread_t thread;
|
||||||
|
xpthread_create(&thread, NULL, start_magisk_hide, NULL);
|
||||||
|
pthread_detach(thread);
|
||||||
|
}
|
||||||
|
free(hide_prop);
|
||||||
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Entry points *
|
* Entry points *
|
||||||
****************/
|
****************/
|
||||||
@ -804,6 +821,8 @@ void late_start(int client) {
|
|||||||
if (buf == NULL) buf = xmalloc(PATH_MAX);
|
if (buf == NULL) buf = xmalloc(PATH_MAX);
|
||||||
if (buf2 == NULL) buf2 = xmalloc(PATH_MAX);
|
if (buf2 == NULL) buf2 = xmalloc(PATH_MAX);
|
||||||
|
|
||||||
|
auto_start_magiskhide();
|
||||||
|
|
||||||
if (full_patch_pid > 0) {
|
if (full_patch_pid > 0) {
|
||||||
// Wait till the full patch is done
|
// Wait till the full patch is done
|
||||||
waitpid(full_patch_pid, NULL, 0);
|
waitpid(full_patch_pid, NULL, 0);
|
||||||
|
@ -93,22 +93,6 @@ static void *request_handler(void *args) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *start_magisk_hide(void *args) {
|
|
||||||
launch_magiskhide(-1);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void auto_start_magiskhide() {
|
|
||||||
char *hide_prop = getprop2(MAGISKHIDE_PROP, 1);
|
|
||||||
if (hide_prop == NULL || strcmp(hide_prop, "0") != 0) {
|
|
||||||
pthread_t thread;
|
|
||||||
xpthread_create(&thread, NULL, start_magisk_hide, NULL);
|
|
||||||
pthread_detach(thread);
|
|
||||||
}
|
|
||||||
free(hide_prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main_daemon() {
|
void main_daemon() {
|
||||||
setsid();
|
setsid();
|
||||||
setcon("u:r:"SEPOL_PROC_DOMAIN":s0");
|
setcon("u:r:"SEPOL_PROC_DOMAIN":s0");
|
||||||
@ -121,13 +105,7 @@ void main_daemon() {
|
|||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
// Start the log monitor
|
// Start the log monitor
|
||||||
loggable = exec_command_sync("/system/bin/logcat", "-d", "-f", "/dev/null", NULL) == 0;
|
check_and_start_logger();
|
||||||
chmod("/dev/null", 0666);
|
|
||||||
if (loggable) {
|
|
||||||
connect_daemon2(LOG_DAEMON, &fd);
|
|
||||||
write_int(fd, HANDSHAKE);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
fd = setup_socket(&sun, MAIN_DAEMON);
|
fd = setup_socket(&sun, MAIN_DAEMON);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|
||||||
int loggable = 1;
|
static int loggable = 0;
|
||||||
static struct vector log_cmd, clear_cmd;
|
static struct vector log_cmd, clear_cmd;
|
||||||
static int sockfd;
|
static int sockfd;
|
||||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
@ -106,6 +106,20 @@ static void *logcat_thread(void *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int check_and_start_logger() {
|
||||||
|
if (!loggable) {
|
||||||
|
int fd;
|
||||||
|
loggable = exec_command_sync("/system/bin/logcat", "-d", "-f", "/dev/null", NULL) == 0;
|
||||||
|
chmod("/dev/null", 0666);
|
||||||
|
if (loggable) {
|
||||||
|
connect_daemon2(LOG_DAEMON, &fd);
|
||||||
|
write_int(fd, HANDSHAKE);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return loggable;
|
||||||
|
}
|
||||||
|
|
||||||
void log_daemon() {
|
void log_daemon() {
|
||||||
setsid();
|
setsid();
|
||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
|
@ -51,12 +51,11 @@ typedef enum {
|
|||||||
void main_daemon();
|
void main_daemon();
|
||||||
int connect_daemon();
|
int connect_daemon();
|
||||||
int connect_daemon2(daemon_t d, int *sockfd);
|
int connect_daemon2(daemon_t d, int *sockfd);
|
||||||
void auto_start_magiskhide();
|
|
||||||
|
|
||||||
// log_monitor.c
|
// log_monitor.c
|
||||||
|
|
||||||
extern int loggable;
|
|
||||||
void log_daemon();
|
void log_daemon();
|
||||||
|
int check_and_start_logger();
|
||||||
|
|
||||||
// socket.c
|
// socket.c
|
||||||
|
|
||||||
|
@ -5,11 +5,8 @@ const char magiskrc[] =
|
|||||||
|
|
||||||
// Triggers
|
// Triggers
|
||||||
|
|
||||||
"on post-fs\n"
|
|
||||||
" start logd\n"
|
|
||||||
"\n"
|
|
||||||
|
|
||||||
"on post-fs-data\n"
|
"on post-fs-data\n"
|
||||||
|
" start logd\n"
|
||||||
" load_persist_props\n"
|
" load_persist_props\n"
|
||||||
" rm "UNBLOCKFILE"\n"
|
" rm "UNBLOCKFILE"\n"
|
||||||
" start magisk_startup\n"
|
" start magisk_startup\n"
|
||||||
|
@ -45,7 +45,7 @@ void launch_magiskhide(int client) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loggable) {
|
if (!check_and_start_logger()) {
|
||||||
if (client > 0) {
|
if (client > 0) {
|
||||||
write_int(client, LOGCAT_DISABLED);
|
write_int(client, LOGCAT_DISABLED);
|
||||||
close(client);
|
close(client);
|
||||||
|
Loading…
Reference in New Issue
Block a user