Adam Shih | 2470b45 | 2023-03-08 12:47:26 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include <dump/pixel_dump.h> |
| 17 | #include <android-base/properties.h> |
| 18 | #include <android-base/file.h> |
| 19 | |
| 20 | #define RIL_LOG_DIRECTORY "/data/vendor/radio" |
| 21 | #define RIL_LOG_DIRECTORY_PROPERTY "persist.vendor.ril.log.base_dir" |
| 22 | #define RIL_LOG_NUMBER_PROPERTY "persist.vendor.ril.log.num_file" |
| 23 | #define RIL_LOG_PREFIX "rild.log." |
| 24 | |
Adam Shih | 54a87e5 | 2023-03-10 13:57:52 +0800 | [diff] [blame^] | 25 | #define TCPDUMP_LOG_DIRECTORY "/data/vendor/tcpdump_logger/logs" |
| 26 | #define TCPDUMP_NUMBER_BUGREPORT "persist.vendor.tcpdump.log.br_num" |
| 27 | #define TCPDUMP_PERSIST_PROPERTY "persist.vendor.tcpdump.log.alwayson" |
| 28 | #define TCPDUMP_LOG_PREFIX "tcpdump" |
| 29 | |
Adam Shih | 2470b45 | 2023-03-08 12:47:26 +0800 | [diff] [blame] | 30 | int main() { |
Adam Shih | 54a87e5 | 2023-03-10 13:57:52 +0800 | [diff] [blame^] | 31 | // netmgr |
| 32 | bool tcpdumpEnabled = ::android::base::GetBoolProperty(TCPDUMP_PERSIST_PROPERTY, false); |
| 33 | |
| 34 | if (tcpdumpEnabled) { |
| 35 | dumpLogs(TCPDUMP_LOG_DIRECTORY, BUGREPORT_PACKING_DIR, ::android::base::GetIntProperty(TCPDUMP_NUMBER_BUGREPORT, 5), TCPDUMP_LOG_PREFIX); |
| 36 | } |
| 37 | copyFile("/data/vendor/radio/metrics_data", "/data/vendor/radio/logs/always-on/all_logs/metrics_data"); |
| 38 | copyFile("/data/vendor/radio/omadm_logs.txt", "/data/vendor/radio/logs/always-on/all_logs/omadm_logs.txt"); |
| 39 | copyFile("/data/vendor/radio/power_anomaly_data.txt", "/data/vendor/radio/logs/always-on/all_logs/power_anomaly_data.txt"); |
| 40 | |
| 41 | // RIL dump |
Adam Shih | 2470b45 | 2023-03-08 12:47:26 +0800 | [diff] [blame] | 42 | std::string rilLogDir = ::android::base::GetProperty(RIL_LOG_DIRECTORY_PROPERTY, RIL_LOG_DIRECTORY); |
| 43 | |
| 44 | int maxFileNum = ::android::base::GetIntProperty(RIL_LOG_NUMBER_PROPERTY, 50); |
| 45 | |
| 46 | const std::string currentLogDir = concatenatePath(rilLogDir.c_str(), "/cur"); |
| 47 | const std::string previousLogDir = concatenatePath(rilLogDir.c_str(), "/prev"); |
| 48 | const std::string currentDestDir = concatenatePath(BUGREPORT_PACKING_DIR, "cur"); |
| 49 | const std::string previousDestDir = concatenatePath(BUGREPORT_PACKING_DIR, "prev"); |
| 50 | if (mkdir(currentDestDir.c_str(), 0777) == -1) { |
| 51 | printf("Unable to create folder: %s\n", currentDestDir.c_str()); |
| 52 | return 0; |
| 53 | } |
| 54 | if (mkdir(previousDestDir.c_str(), 0777) == -1) { |
| 55 | printf("Unable to create folder: %s\n", previousDestDir.c_str()); |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | dumpLogs(currentLogDir.c_str(), currentDestDir.c_str(), maxFileNum, RIL_LOG_PREFIX); |
| 60 | dumpLogs(previousLogDir.c_str(), previousDestDir.c_str(), maxFileNum, RIL_LOG_PREFIX); |
| 61 | return 0; |
| 62 | } |