OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef ThermalManager_DEFINED | |
9 #define ThermalManager_DEFINED | |
10 | |
11 #include "SkString.h" | |
12 #include "SkTArray.h" | |
13 | |
14 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX) | |
15 # define THERMAL_MANAGER_SUPPORTED | |
16 #endif | |
17 | |
18 #ifdef THERMAL_MANAGER_SUPPORTED | |
19 | |
20 /* | |
21 * This simple class monitors the thermal part of sysfs to ensure we don't trigg er thermal events | |
22 */ | |
23 | |
24 class ThermalManager { | |
25 public: | |
26 ThermalManager(int32_t threshold = 1); | |
djsollen
2016/02/08 20:59:33
don't provide defaults if the code will never use
joshualitt
2016/02/09 13:51:54
Acknowledged.
| |
27 | |
28 bool coolOffIfNecessary(uint32_t sleepIntervalMs = 10, uint32_t timeoutMs = 1000); | |
djsollen
2016/02/08 20:59:33
since these never change why not pass them in the
joshualitt
2016/02/09 13:51:54
Acknowledged.
| |
29 | |
30 private: | |
31 static int32_t OpenFileAndReadInt32(const char* path); | |
32 | |
33 // current temperature can be read from /thermalZonePath/temp | |
34 static int32_t GetTemp(SkString thermalZonePath) { | |
35 SkString temperatureFilePath(thermalZonePath); | |
36 temperatureFilePath.appendf("/temp"); | |
37 return OpenFileAndReadInt32(temperatureFilePath.c_str()); | |
38 } | |
39 | |
40 struct TripPoint { | |
41 TripPoint(SkString thermalZoneRoot, SkString pointName, int32_t threshol d); | |
42 | |
43 bool willTrip(); | |
44 | |
45 SkString fThermalZoneRoot; | |
46 SkString fPointName; | |
47 int32_t fBase; | |
48 int32_t fPoint; | |
49 int32_t fThreshold; | |
50 | |
51 // Certain trip points seem to start tripped. For example, I have seen trip points of 0 or | |
52 // negative numbers. | |
53 bool fDisabled; | |
54 }; | |
55 | |
56 SkTArray<TripPoint> fTripPoints; | |
57 }; | |
58 #endif | |
59 #endif | |
OLD | NEW |