John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <string> |
| 20 | |
| 21 | #include "JankTracker.h" |
| 22 | #include "utils/Macros.h" |
Stan Iliev | c904381 | 2020-02-03 16:57:09 -0500 | [diff] [blame] | 23 | #include <stats_pull_atom_callback.h> |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 24 | |
| 25 | namespace android { |
Kweku Adams | 228b6d2 | 2018-04-12 13:09:04 -0700 | [diff] [blame] | 26 | namespace uirenderer { |
| 27 | namespace protos { |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 28 | class GraphicsStatsProto; |
| 29 | } |
| 30 | |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 31 | /* |
| 32 | * The exported entry points used by GraphicsStatsService.java in f/b/services/core |
| 33 | * |
| 34 | * NOTE: Avoid exporting a requirement on the protobuf itself. Keep the usage |
| 35 | * of the generated protobuf classes internal to libhwui.so to minimize library |
| 36 | * bloat. |
| 37 | */ |
| 38 | class GraphicsStatsService { |
| 39 | public: |
| 40 | class Dump; |
| 41 | enum class DumpType { |
| 42 | Text, |
| 43 | Protobuf, |
Stan Iliev | 637ba5e | 2019-08-16 13:43:08 -0400 | [diff] [blame] | 44 | ProtobufStatsd, |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 45 | }; |
| 46 | |
Alec Mouri | 04b0d81 | 2024-09-20 16:15:55 +0000 | [diff] [blame] | 47 | static void saveBuffer(const std::string& path, uid_t uid, const std::string& package, |
| 48 | int64_t versionCode, int64_t startTime, int64_t endTime, |
| 49 | const ProfileData* data); |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 50 | |
Derek Sollenberger | 3fedf5a | 2020-02-21 13:07:28 -0500 | [diff] [blame] | 51 | static Dump* createDump(int outFd, DumpType type); |
Alec Mouri | 04b0d81 | 2024-09-20 16:15:55 +0000 | [diff] [blame] | 52 | static void addToDump(Dump* dump, const std::string& path, uid_t uid, |
| 53 | const std::string& package, int64_t versionCode, int64_t startTime, |
| 54 | int64_t endTime, const ProfileData* data); |
Derek Sollenberger | 3fedf5a | 2020-02-21 13:07:28 -0500 | [diff] [blame] | 55 | static void addToDump(Dump* dump, const std::string& path); |
| 56 | static void finishDump(Dump* dump); |
| 57 | static void finishDumpInMemory(Dump* dump, AStatsEventList* data, bool lastFullDay); |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 58 | |
| 59 | // Visible for testing |
Kweku Adams | 228b6d2 | 2018-04-12 13:09:04 -0700 | [diff] [blame] | 60 | static bool parseFromFile(const std::string& path, protos::GraphicsStatsProto* output); |
John Reck | df1742e | 2017-01-19 15:56:21 -0800 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } /* namespace uirenderer */ |
Kweku Adams | 228b6d2 | 2018-04-12 13:09:04 -0700 | [diff] [blame] | 64 | } /* namespace android */ |