3 ** Copyright 2015, The Android Open Source Project
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
18 #ifndef SYSTEM_EXTRAS_PERFPROFD_PERFPROFDCORE_H_
19 #define SYSTEM_EXTRAS_PERFPROFD_PERFPROFDCORE_H_
23 // Semaphore file that indicates that the user is opting in
24 #define SEMAPHORE_FILENAME "perf_profile_collection_enabled.txt"
26 // File containing a list of sequence numbers corresponding to profiles
27 // that have been processed/uploaded. Written by the GmsCore uploader,
28 // within the GmsCore files directory.
29 #define PROCESSED_FILENAME "perfprofd_processed.txt"
31 // File containing a list of sequence numbers corresponding to profiles
32 // that have been created by the perfprofd but not yet uploaded. Written
33 // by perfprofd within the destination directory; consumed by GmsCore.
34 #define PRODUCED_FILENAME "perfprofd_produced.txt"
36 // Main routine for perfprofd daemon
37 extern int perfprofd_main(int argc, char **argv);
40 // This enumeration holds the results of what happened when on an
41 // attempted perf profiling run.
46 OK_PROFILE_COLLECTION,
48 // Fork system call failed (lo mem?)
51 // Perf ran but crashed or returned a bad exit status
52 ERR_PERF_RECORD_FAILED,
54 // The perf.data encoding process failed somehow
55 ERR_PERF_ENCODE_FAILED,
57 // We tried to open the output file perf.data.encoded but the open failed
58 ERR_OPEN_ENCODED_FILE_FAILED,
60 // Error while writing perf.data.encoded
61 ERR_WRITE_ENCODED_FILE_FAILED
65 // Given a full path to a perf.data file specified by "data_file_path",
66 // read/summarize/encode the contents into a new file specified
67 // by "encoded_file_path". Return status indicates whether the operation
68 // was successful (either OK_PROFILE_COLLECTION or an error of some sort).
70 PROFILE_RESULT encode_to_proto(const std::string &data_file_path,
71 const char *encoded_file_path,
72 const ConfigReader &config,
73 unsigned cpu_utilization);
76 // Exposed for unit testing
78 extern unsigned collect_cpu_utilization();
79 extern bool get_booting();
80 extern bool get_charging();
81 extern bool get_camera_active();