Adam Shih | 1a62bec | 2023-03-06 10:02:00 +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 | int main() { |
| 21 | if (!::android::base::GetBoolProperty("vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport", true)) { |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | static const std::string kCameraLogDir = "/data/vendor/camera/profiler"; |
| 26 | const std::string cameraDestDir = concatenatePath(BUGREPORT_PACKING_DIR, "camera"); |
| 27 | |
| 28 | if (mkdir(cameraDestDir.c_str(), 0777) == -1) { |
| 29 | printf("Unable to create folder: %s\n", cameraDestDir.c_str()); |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | // Attach multiple latest sessions (in case the user is running concurrent |
| 34 | // sessions or starts a new session after the one with performance issues). |
| 35 | dumpLogs(kCameraLogDir.c_str(), cameraDestDir.c_str(), 10, "session-ended-"); |
| 36 | dumpLogs(kCameraLogDir.c_str(), cameraDestDir.c_str(), 5, "high-drop-rate-"); |
| 37 | dumpLogs(kCameraLogDir.c_str(), cameraDestDir.c_str(), 5, "watchdog-"); |
| 38 | dumpLogs(kCameraLogDir.c_str(), cameraDestDir.c_str(), 5, "camera-ended-"); |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |