diff --git a/universal7885-common/debug/Android.bp b/universal7885-common/debug/Android.bp index 0a4c5de..8725c96 100644 --- a/universal7885-common/debug/Android.bp +++ b/universal7885-common/debug/Android.bp @@ -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"], } diff --git a/universal7885-common/debug/Kmsg.cpp b/universal7885-common/debug/Kmsg.cpp deleted file mode 100644 index 72cefa4..0000000 --- a/universal7885-common/debug/Kmsg.cpp +++ /dev/null @@ -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 - -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(); - } -} diff --git a/universal7885-common/debug/Logcat.cpp b/universal7885-common/debug/Logcat.cpp deleted file mode 100644 index d777280..0000000 --- a/universal7885-common/debug/Logcat.cpp +++ /dev/null @@ -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 -#include - -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"); - } -} diff --git a/universal7885-common/debug/Main.cpp b/universal7885-common/debug/Logger.cpp similarity index 69% rename from universal7885-common/debug/Main.cpp rename to universal7885-common/debug/Logger.cpp index 3ac5b57..4ea7e25 100644 --- a/universal7885-common/debug/Main.cpp +++ b/universal7885-common/debug/Logger.cpp @@ -16,8 +16,20 @@ #include -void copy_kmsg(); -void copy_logcat(); +#define KMSG_PATH "/proc/kmsg" +#define WRITE_KMSG "/data/debug/kmsg.txt" + +#include +#include + +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); diff --git a/universal7885-common/debug/init.debug_daemon.rc b/universal7885-common/debug/init.debug_daemon.rc index eaa19c7..8faf66f 100644 --- a/universal7885-common/debug/init.debug_daemon.rc +++ b/universal7885-common/debug/init.debug_daemon.rc @@ -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