blob: 5a0229b336080e4f0422578fb0ed411139b6b812 [file] [log] [blame]
Adam Shih1a62bec2023-03-06 10:02:00 +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 */
Adam Shih1a62bec2023-03-06 10:02:00 +080016#include <android-base/file.h>
Owen Kim559ad992023-05-11 23:29:50 +000017#include <android-base/properties.h>
18#include <dump/pixel_dump.h>
19
20namespace {
21
22constexpr std::string_view kCameraLogDir = "/data/vendor/camera/profiler";
23constexpr std::string_view kGraphStateDumpDir = "/data/vendor/camera";
24
25} // namespace
Adam Shih1a62bec2023-03-06 10:02:00 +080026
27int main() {
Owen Kim559ad992023-05-11 23:29:50 +000028 if (!::android::base::GetBoolProperty(
29 "vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport",
30 true)) {
Adam Shih1a62bec2023-03-06 10:02:00 +080031 return 0;
Owen Kim559ad992023-05-11 23:29:50 +000032 }
Adam Shih1a62bec2023-03-06 10:02:00 +080033
Owen Kim559ad992023-05-11 23:29:50 +000034 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-");
Dana Simard9e2b4ef2024-01-24 01:48:24 +000048 dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "fatal-error-");
Owen Kim559ad992023-05-11 23:29:50 +000049 dumpLogs(kGraphStateDumpDir.data(), cameraDestDir.c_str(), 5,
50 "hal_graph_state_");
51
52 return 0;
53}