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 | */ |
Adam Shih | 1a62bec | 2023-03-06 10:02:00 +0800 | [diff] [blame] | 16 | #include <android-base/file.h> |
Owen Kim | 559ad99 | 2023-05-11 23:29:50 +0000 | [diff] [blame^] | 17 | #include <android-base/properties.h> |
| 18 | #include <dump/pixel_dump.h> |
| 19 | |
| 20 | namespace { |
| 21 | |
| 22 | constexpr std::string_view kCameraLogDir = "/data/vendor/camera/profiler"; |
| 23 | constexpr std::string_view kGraphStateDumpDir = "/data/vendor/camera"; |
| 24 | |
| 25 | } // namespace |
Adam Shih | 1a62bec | 2023-03-06 10:02:00 +0800 | [diff] [blame] | 26 | |
| 27 | int main() { |
Owen Kim | 559ad99 | 2023-05-11 23:29:50 +0000 | [diff] [blame^] | 28 | if (!::android::base::GetBoolProperty( |
| 29 | "vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport", |
| 30 | true)) { |
Adam Shih | 1a62bec | 2023-03-06 10:02:00 +0800 | [diff] [blame] | 31 | return 0; |
Owen Kim | 559ad99 | 2023-05-11 23:29:50 +0000 | [diff] [blame^] | 32 | } |
Adam Shih | 1a62bec | 2023-03-06 10:02:00 +0800 | [diff] [blame] | 33 | |
Owen Kim | 559ad99 | 2023-05-11 23:29:50 +0000 | [diff] [blame^] | 34 | const std::string cameraDestDir = |
| 35 | concatenatePath(BUGREPORT_PACKING_DIR, "camera"); |
| 36 | |
| 37 | if (mkdir(cameraDestDir.c_str(), 0777) == -1) { |
| 38 | printf("Unable to create folder: %s\n", cameraDestDir.c_str()); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | // Attach multiple latest sessions (in case the user is running concurrent |
| 43 | // sessions or starts a new session after the one with performance issues). |
| 44 | dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 10, "session-ended-"); |
| 45 | dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "high-drop-rate-"); |
| 46 | dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "watchdog-"); |
| 47 | dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "camera-ended-"); |
| 48 | dumpLogs(kGraphStateDumpDir.data(), cameraDestDir.c_str(), 5, |
| 49 | "hal_graph_state_"); |
| 50 | |
| 51 | return 0; |
| 52 | } |