Adam Shih | d0f5360 | 2023-02-18 15:26:21 +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 | */ |
Cheng Chang | 498c4cb | 2023-06-26 03:49:09 +0000 | [diff] [blame] | 16 | #include <unistd.h> |
Adam Shih | d0f5360 | 2023-02-18 15:26:21 +0800 | [diff] [blame] | 17 | #include <dump/pixel_dump.h> |
| 18 | #include <android-base/properties.h> |
| 19 | #include <android-base/file.h> |
| 20 | |
| 21 | #define GPS_LOG_NUMBER_PROPERTY "persist.vendor.gps.aol.log_num" |
| 22 | #define GPS_LOG_DIRECTORY "/data/vendor/gps/logs" |
| 23 | #define GPS_TMP_LOG_DIRECTORY "/data/vendor/gps/logs/.tmp" |
| 24 | #define GPS_LOG_PREFIX "gl-" |
| 25 | #define GPS_MCU_LOG_PREFIX "esw-" |
Cheng Chang | 0e67f94 | 2023-03-28 05:00:40 +0000 | [diff] [blame] | 26 | #define GPS_MALLOC_LOG_DIRECTORY "/data/vendor/gps" |
| 27 | #define GPS_MALLOC_LOG_PREFIX "malloc_" |
Cheng Chang | 498c4cb | 2023-06-26 03:49:09 +0000 | [diff] [blame] | 28 | #define GPS_VENDOR_CHIP_INFO "/data/vendor/gps/chip.info" |
Edwin Tung | 42f1c4d | 2023-07-12 17:02:08 +0800 | [diff] [blame^] | 29 | #define GPS_RAWLOG_PREFIX "rawbin" |
| 30 | #define GPS_MEMDUMP_LOG_PREFIX "memdump_" |
Adam Shih | d0f5360 | 2023-02-18 15:26:21 +0800 | [diff] [blame] | 31 | |
| 32 | int main() { |
| 33 | if(!::android::base::GetBoolProperty("vendor.gps.aol.enabled", false)) { |
| 34 | printf("vendor.gps.aol.enabled is false. gps logging is not running.\n"); |
| 35 | return 0; |
| 36 | } |
| 37 | int maxFileNum = ::android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20); |
| 38 | std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "gps"); |
| 39 | if (mkdir(outputDir.c_str(), 0777) == -1) { |
| 40 | printf("Unable to create folder: %s\n", outputDir.c_str()); |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | dumpLogs(GPS_TMP_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_LOG_PREFIX); |
| 45 | dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 3, GPS_MCU_LOG_PREFIX); |
| 46 | dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), maxFileNum, GPS_LOG_PREFIX); |
Cheng Chang | 0e67f94 | 2023-03-28 05:00:40 +0000 | [diff] [blame] | 47 | dumpLogs(GPS_MALLOC_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_MALLOC_LOG_PREFIX); |
Cheng Chang | 498c4cb | 2023-06-26 03:49:09 +0000 | [diff] [blame] | 48 | if (access(GPS_VENDOR_CHIP_INFO, F_OK) == 0) { |
| 49 | copyFile(GPS_VENDOR_CHIP_INFO, concatenatePath(outputDir.c_str(), "chip.info").c_str()); |
| 50 | } |
Edwin Tung | 42f1c4d | 2023-07-12 17:02:08 +0800 | [diff] [blame^] | 51 | dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), maxFileNum, GPS_RAWLOG_PREFIX); |
| 52 | dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 18, GPS_MEMDUMP_LOG_PREFIX); |
Adam Shih | d0f5360 | 2023-02-18 15:26:21 +0800 | [diff] [blame] | 53 | return 0; |
| 54 | } |
| 55 | |