blob: d7ece6274860ac94637d3f078b27d8458c2efcdc [file] [log] [blame]
Adam Shihd0f53602023-02-18 15:26:21 +08001/*
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 GPS_LOG_NUMBER_PROPERTY "persist.vendor.gps.aol.log_num"
21#define GPS_LOG_DIRECTORY "/data/vendor/gps/logs"
22#define GPS_TMP_LOG_DIRECTORY "/data/vendor/gps/logs/.tmp"
23#define GPS_LOG_PREFIX "gl-"
24#define GPS_MCU_LOG_PREFIX "esw-"
25
26int main() {
27 if(!::android::base::GetBoolProperty("vendor.gps.aol.enabled", false)) {
28 printf("vendor.gps.aol.enabled is false. gps logging is not running.\n");
29 return 0;
30 }
31 int maxFileNum = ::android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20);
32 std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "gps");
33 if (mkdir(outputDir.c_str(), 0777) == -1) {
34 printf("Unable to create folder: %s\n", outputDir.c_str());
35 return 0;
36 }
37
38 dumpLogs(GPS_TMP_LOG_DIRECTORY, outputDir.c_str(), 1, GPS_LOG_PREFIX);
39 dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 3, GPS_MCU_LOG_PREFIX);
40 dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), maxFileNum, GPS_LOG_PREFIX);
41 return 0;
42}
43