universal7885: debug_daemon: Don't check, just log

* Also, cleanup to 1 file

Change-Id: I9c568047a8be7952a85274d4aa8786857ab2f6a6
Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
Change-Id: I534de831a0a501f327fbe630e301832b2c4b79bb
Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
roynatech2544 2022-02-09 10:46:56 +09:00
commit b898b96c3f
No known key found for this signature in database
GPG key ID: 9675C32163D88D30
5 changed files with 17 additions and 84 deletions

View file

@ -18,9 +18,7 @@ cc_binary {
name: "debug_daemon",
vendor: true,
srcs: [
"Kmsg.cpp",
"Logcat.cpp",
"Main.cpp",
"Logger.cpp",
],
init_rc: ["init.debug_daemon.rc"],
}

View file

@ -1,39 +0,0 @@
/*
* Copyright 2021 Soo Hwan Na "Royna"
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define KMSG_PATH "/proc/kmsg"
#define CHECK_KMSG "/data/debug/kmsg"
#define WRITE_KMSG "/data/debug/logs/kmsg.txt"
#include <fstream>
bool check_data_kmsg() {
std::ifstream datafile(CHECK_KMSG);
if (datafile.good()) {
datafile.close();
return true;
} else {
return false;
}
}
void copy_kmsg() {
if (check_data_kmsg()) {
std::ifstream readfile(KMSG_PATH);
std::ofstream writefile(WRITE_KMSG);
writefile << readfile.rdbuf();
}
}

View file

@ -1,37 +0,0 @@
/*
* Copyright 2021 Soo Hwan Na "Royna"
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define CHECK_LOGCAT "/data/debug/logcat"
#define WRITE_LOGCAT "/data/debug/logs/logcat.txt"
#include <fstream>
#include <iostream>
bool check_data_logcat() {
std::ifstream datafile(CHECK_LOGCAT);
if (datafile.good()) {
datafile.close();
return true;
} else {
return false;
}
}
void copy_logcat() {
if (check_data_logcat()) {
system("/system/bin/logcat -f /data/debug/logs/logcat.txt");
}
}

View file

@ -16,8 +16,20 @@
#include <thread>
void copy_kmsg();
void copy_logcat();
#define KMSG_PATH "/proc/kmsg"
#define WRITE_KMSG "/data/debug/kmsg.txt"
#include <fstream>
#include <iostream>
void copy_kmsg() {
std::ifstream readfile(KMSG_PATH);
std::ofstream writefile(WRITE_KMSG);
writefile << readfile.rdbuf();
}
void copy_logcat() {
system("/system/bin/logcat -f /data/debug/logcat.txt");
}
int main() {
std::thread kmsg(copy_kmsg);
std::thread logcat(copy_logcat);

View file

@ -6,9 +6,8 @@ service debug_daemon /vendor/bin/debug_daemon
on post-fs-data
mkdir /data/debug 0755 root system encryption=None
mkdir /data/debug/logs 0755 root system
rm /data/debug/logs/logcat.txt
rm /data/debug/logs/kmsg.txt
rm /data/debug/logcat.txt
rm /data/debug/kmsg.txt
start debug_daemon
on property:sys.boot_completed=1