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 | |
| 25 | int main() { |
| 26 | std::string rilLogDir = ::android::base::GetProperty(RIL_LOG_DIRECTORY_PROPERTY, RIL_LOG_DIRECTORY); |
| 27 | |
| 28 | int maxFileNum = ::android::base::GetIntProperty(RIL_LOG_NUMBER_PROPERTY, 50); |
| 29 | |
| 30 | const std::string currentLogDir = concatenatePath(rilLogDir.c_str(), "/cur"); |
| 31 | const std::string previousLogDir = concatenatePath(rilLogDir.c_str(), "/prev"); |
| 32 | const std::string currentDestDir = concatenatePath(BUGREPORT_PACKING_DIR, "cur"); |
| 33 | const std::string previousDestDir = concatenatePath(BUGREPORT_PACKING_DIR, "prev"); |
| 34 | if (mkdir(currentDestDir.c_str(), 0777) == -1) { |
| 35 | printf("Unable to create folder: %s\n", currentDestDir.c_str()); |
| 36 | return 0; |
| 37 | } |
| 38 | if (mkdir(previousDestDir.c_str(), 0777) == -1) { |
| 39 | printf("Unable to create folder: %s\n", previousDestDir.c_str()); |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | dumpLogs(currentLogDir.c_str(), currentDestDir.c_str(), maxFileNum, RIL_LOG_PREFIX); |
| 44 | dumpLogs(previousLogDir.c_str(), previousDestDir.c_str(), maxFileNum, RIL_LOG_PREFIX); |
| 45 | return 0; |
| 46 | } |