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 <android-base/file.h>
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
26
main()27 int main() {
28 if (!::android::base::GetBoolProperty(
29 "vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport",
30 true)) {
31 return 0;
32 }
33
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(), 10, "multicam-");
46 dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "high-drop-rate-");
47 dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "watchdog-");
48 dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "camera-ended-");
49 dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 5, "fatal-error-");
50 dumpLogs(kGraphStateDumpDir.data(), cameraDestDir.c_str(), 5,
51 "hal_graph_state_");
52 dumpLogs(kCameraLogDir.data(), cameraDestDir.c_str(), 10,
53 "fd_state_tracker-");
54
55 return 0;
56 }
57