diff options
author | Todd Poynor | 2017-05-23 22:28:15 -0500 |
---|---|---|
committer | Todd Poynor | 2017-08-07 18:11:48 -0500 |
commit | 8d95f2e6315010d560ffe1060765e0c0c404eb0f (patch) | |
tree | 69fb972397018efc36bced397b5ecf98284114b1 /thermal/1.1 | |
parent | 85e93f0a3b6f6dd974e1a15de0a76cd324bf3d7d (diff) | |
download | platform-hardware-interfaces-8d95f2e6315010d560ffe1060765e0c0c404eb0f.tar.gz platform-hardware-interfaces-8d95f2e6315010d560ffe1060765e0c0c404eb0f.tar.xz platform-hardware-interfaces-8d95f2e6315010d560ffe1060765e0c0c404eb0f.zip |
thermal: IThermal V1.1, add methods to send thermal throttling events
Add IThermalCallback and IThermal::registerThermalCallback() method.
Frameworks code calls this method to register a callback used by the
IThermal HAL implementation to send thermal events to the framework
ThermalService.
Bug: 30982366
Test: VtsHalThermalV1_1Target on marlin
manual test on marlin using marlin 1.1 HAL with modified
thermal-engine.conf and temporary debug code for notification
Change-Id: Ib49ad93a9495e3af515fced4e46f20186661fe07
(cherry picked from commit cf964d79c1d41bba999e58cb476af099191a6634)
Diffstat (limited to 'thermal/1.1')
-rw-r--r-- | thermal/1.1/Android.bp | 68 | ||||
-rw-r--r-- | thermal/1.1/Android.mk | 120 | ||||
-rw-r--r-- | thermal/1.1/IThermal.hal | 31 | ||||
-rw-r--r-- | thermal/1.1/IThermalCallback.hal | 33 | ||||
-rw-r--r-- | thermal/1.1/vts/functional/Android.bp | 35 | ||||
-rw-r--r-- | thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp | 106 |
6 files changed, 393 insertions, 0 deletions
diff --git a/thermal/1.1/Android.bp b/thermal/1.1/Android.bp new file mode 100644 index 00000000..833f219e --- /dev/null +++ b/thermal/1.1/Android.bp | |||
@@ -0,0 +1,68 @@ | |||
1 | // This file is autogenerated by hidl-gen. Do not edit manually. | ||
2 | |||
3 | filegroup { | ||
4 | name: "android.hardware.thermal@1.1_hal", | ||
5 | srcs: [ | ||
6 | "IThermal.hal", | ||
7 | "IThermalCallback.hal", | ||
8 | ], | ||
9 | } | ||
10 | |||
11 | genrule { | ||
12 | name: "android.hardware.thermal@1.1_genc++", | ||
13 | tools: ["hidl-gen"], | ||
14 | cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.thermal@1.1", | ||
15 | srcs: [ | ||
16 | ":android.hardware.thermal@1.1_hal", | ||
17 | ], | ||
18 | out: [ | ||
19 | "android/hardware/thermal/1.1/ThermalAll.cpp", | ||
20 | "android/hardware/thermal/1.1/ThermalCallbackAll.cpp", | ||
21 | ], | ||
22 | } | ||
23 | |||
24 | genrule { | ||
25 | name: "android.hardware.thermal@1.1_genc++_headers", | ||
26 | tools: ["hidl-gen"], | ||
27 | cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.thermal@1.1", | ||
28 | srcs: [ | ||
29 | ":android.hardware.thermal@1.1_hal", | ||
30 | ], | ||
31 | out: [ | ||
32 | "android/hardware/thermal/1.1/IThermal.h", | ||
33 | "android/hardware/thermal/1.1/IHwThermal.h", | ||
34 | "android/hardware/thermal/1.1/BnHwThermal.h", | ||
35 | "android/hardware/thermal/1.1/BpHwThermal.h", | ||
36 | "android/hardware/thermal/1.1/BsThermal.h", | ||
37 | "android/hardware/thermal/1.1/IThermalCallback.h", | ||
38 | "android/hardware/thermal/1.1/IHwThermalCallback.h", | ||
39 | "android/hardware/thermal/1.1/BnHwThermalCallback.h", | ||
40 | "android/hardware/thermal/1.1/BpHwThermalCallback.h", | ||
41 | "android/hardware/thermal/1.1/BsThermalCallback.h", | ||
42 | ], | ||
43 | } | ||
44 | |||
45 | cc_library_shared { | ||
46 | name: "android.hardware.thermal@1.1", | ||
47 | defaults: ["hidl-module-defaults"], | ||
48 | generated_sources: ["android.hardware.thermal@1.1_genc++"], | ||
49 | generated_headers: ["android.hardware.thermal@1.1_genc++_headers"], | ||
50 | export_generated_headers: ["android.hardware.thermal@1.1_genc++_headers"], | ||
51 | vendor_available: true, | ||
52 | shared_libs: [ | ||
53 | "libhidlbase", | ||
54 | "libhidltransport", | ||
55 | "libhwbinder", | ||
56 | "liblog", | ||
57 | "libutils", | ||
58 | "libcutils", | ||
59 | "android.hardware.thermal@1.0", | ||
60 | ], | ||
61 | export_shared_lib_headers: [ | ||
62 | "libhidlbase", | ||
63 | "libhidltransport", | ||
64 | "libhwbinder", | ||
65 | "libutils", | ||
66 | "android.hardware.thermal@1.0", | ||
67 | ], | ||
68 | } | ||
diff --git a/thermal/1.1/Android.mk b/thermal/1.1/Android.mk new file mode 100644 index 00000000..082d65b8 --- /dev/null +++ b/thermal/1.1/Android.mk | |||
@@ -0,0 +1,120 @@ | |||
1 | # This file is autogenerated by hidl-gen. Do not edit manually. | ||
2 | |||
3 | LOCAL_PATH := $(call my-dir) | ||
4 | |||
5 | ################################################################################ | ||
6 | |||
7 | include $(CLEAR_VARS) | ||
8 | LOCAL_MODULE := android.hardware.thermal-V1.1-java | ||
9 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES | ||
10 | |||
11 | intermediates := $(call local-generated-sources-dir, COMMON) | ||
12 | |||
13 | HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) | ||
14 | |||
15 | LOCAL_JAVA_LIBRARIES := \ | ||
16 | android.hardware.thermal-V1.0-java \ | ||
17 | android.hidl.base-V1.0-java \ | ||
18 | |||
19 | |||
20 | # | ||
21 | # Build IThermal.hal | ||
22 | # | ||
23 | GEN := $(intermediates)/android/hardware/thermal/V1_1/IThermal.java | ||
24 | $(GEN): $(HIDL) | ||
25 | $(GEN): PRIVATE_HIDL := $(HIDL) | ||
26 | $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermal.hal | ||
27 | $(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IThermalCallback.hal | ||
28 | $(GEN): $(LOCAL_PATH)/IThermalCallback.hal | ||
29 | $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) | ||
30 | $(GEN): PRIVATE_CUSTOM_TOOL = \ | ||
31 | $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ | ||
32 | -Ljava \ | ||
33 | -randroid.hardware:hardware/interfaces \ | ||
34 | -randroid.hidl:system/libhidl/transport \ | ||
35 | android.hardware.thermal@1.1::IThermal | ||
36 | |||
37 | $(GEN): $(LOCAL_PATH)/IThermal.hal | ||
38 | $(transform-generated-source) | ||
39 | LOCAL_GENERATED_SOURCES += $(GEN) | ||
40 | |||
41 | # | ||
42 | # Build IThermalCallback.hal | ||
43 | # | ||
44 | GEN := $(intermediates)/android/hardware/thermal/V1_1/IThermalCallback.java | ||
45 | $(GEN): $(HIDL) | ||
46 | $(GEN): PRIVATE_HIDL := $(HIDL) | ||
47 | $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermalCallback.hal | ||
48 | $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) | ||
49 | $(GEN): PRIVATE_CUSTOM_TOOL = \ | ||
50 | $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ | ||
51 | -Ljava \ | ||
52 | -randroid.hardware:hardware/interfaces \ | ||
53 | -randroid.hidl:system/libhidl/transport \ | ||
54 | android.hardware.thermal@1.1::IThermalCallback | ||
55 | |||
56 | $(GEN): $(LOCAL_PATH)/IThermalCallback.hal | ||
57 | $(transform-generated-source) | ||
58 | LOCAL_GENERATED_SOURCES += $(GEN) | ||
59 | include $(BUILD_JAVA_LIBRARY) | ||
60 | |||
61 | |||
62 | ################################################################################ | ||
63 | |||
64 | include $(CLEAR_VARS) | ||
65 | LOCAL_MODULE := android.hardware.thermal-V1.1-java-static | ||
66 | LOCAL_MODULE_CLASS := JAVA_LIBRARIES | ||
67 | |||
68 | intermediates := $(call local-generated-sources-dir, COMMON) | ||
69 | |||
70 | HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) | ||
71 | |||
72 | LOCAL_STATIC_JAVA_LIBRARIES := \ | ||
73 | android.hardware.thermal-V1.0-java-static \ | ||
74 | android.hidl.base-V1.0-java-static \ | ||
75 | |||
76 | |||
77 | # | ||
78 | # Build IThermal.hal | ||
79 | # | ||
80 | GEN := $(intermediates)/android/hardware/thermal/V1_1/IThermal.java | ||
81 | $(GEN): $(HIDL) | ||
82 | $(GEN): PRIVATE_HIDL := $(HIDL) | ||
83 | $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermal.hal | ||
84 | $(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IThermalCallback.hal | ||
85 | $(GEN): $(LOCAL_PATH)/IThermalCallback.hal | ||
86 | $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) | ||
87 | $(GEN): PRIVATE_CUSTOM_TOOL = \ | ||
88 | $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ | ||
89 | -Ljava \ | ||
90 | -randroid.hardware:hardware/interfaces \ | ||
91 | -randroid.hidl:system/libhidl/transport \ | ||
92 | android.hardware.thermal@1.1::IThermal | ||
93 | |||
94 | $(GEN): $(LOCAL_PATH)/IThermal.hal | ||
95 | $(transform-generated-source) | ||
96 | LOCAL_GENERATED_SOURCES += $(GEN) | ||
97 | |||
98 | # | ||
99 | # Build IThermalCallback.hal | ||
100 | # | ||
101 | GEN := $(intermediates)/android/hardware/thermal/V1_1/IThermalCallback.java | ||
102 | $(GEN): $(HIDL) | ||
103 | $(GEN): PRIVATE_HIDL := $(HIDL) | ||
104 | $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermalCallback.hal | ||
105 | $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) | ||
106 | $(GEN): PRIVATE_CUSTOM_TOOL = \ | ||
107 | $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ | ||
108 | -Ljava \ | ||
109 | -randroid.hardware:hardware/interfaces \ | ||
110 | -randroid.hidl:system/libhidl/transport \ | ||
111 | android.hardware.thermal@1.1::IThermalCallback | ||
112 | |||
113 | $(GEN): $(LOCAL_PATH)/IThermalCallback.hal | ||
114 | $(transform-generated-source) | ||
115 | LOCAL_GENERATED_SOURCES += $(GEN) | ||
116 | include $(BUILD_STATIC_JAVA_LIBRARY) | ||
117 | |||
118 | |||
119 | |||
120 | include $(call all-makefiles-under,$(LOCAL_PATH)) | ||
diff --git a/thermal/1.1/IThermal.hal b/thermal/1.1/IThermal.hal new file mode 100644 index 00000000..14f35baa --- /dev/null +++ b/thermal/1.1/IThermal.hal | |||
@@ -0,0 +1,31 @@ | |||
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 | package android.hardware.thermal@1.1; | ||
18 | |||
19 | import android.hardware.thermal@1.0::IThermal; | ||
20 | import IThermalCallback; | ||
21 | |||
22 | interface IThermal extends @1.0::IThermal { | ||
23 | /** | ||
24 | * Register an IThermalCallback, used by the Thermal HAL | ||
25 | * to send thermal events to the framework thermal service. | ||
26 | * | ||
27 | * @param callback the IThermalCallback to use for sending | ||
28 | * thermal events, or nullptr to set no callback | ||
29 | */ | ||
30 | registerThermalCallback(IThermalCallback callback); | ||
31 | }; | ||
diff --git a/thermal/1.1/IThermalCallback.hal b/thermal/1.1/IThermalCallback.hal new file mode 100644 index 00000000..f418ec3d --- /dev/null +++ b/thermal/1.1/IThermalCallback.hal | |||
@@ -0,0 +1,33 @@ | |||
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 | package android.hardware.thermal@1.1; | ||
18 | |||
19 | import android.hardware.thermal@1.0::Temperature; | ||
20 | |||
21 | /** | ||
22 | * IThermalCallback connects vendor code to the framework binder ThermalService. | ||
23 | */ | ||
24 | interface IThermalCallback { | ||
25 | /** | ||
26 | * Send a thermal throttling start/stop event to all ThermalService | ||
27 | * thermal event listeners. | ||
28 | * @param isThrottling true if device is currently throttling | ||
29 | * @param temperature The temperature associated with the throttling | ||
30 | * start/stop event | ||
31 | */ | ||
32 | oneway notifyThrottling(bool isThrottling, Temperature temperature); | ||
33 | }; | ||
diff --git a/thermal/1.1/vts/functional/Android.bp b/thermal/1.1/vts/functional/Android.bp new file mode 100644 index 00000000..cea5bf84 --- /dev/null +++ b/thermal/1.1/vts/functional/Android.bp | |||
@@ -0,0 +1,35 @@ | |||
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 | cc_test { | ||
18 | name: "VtsHalThermalV1_1TargetTest", | ||
19 | defaults: ["hidl_defaults"], | ||
20 | srcs: ["VtsHalThermalV1_1TargetTest.cpp"], | ||
21 | shared_libs: [ | ||
22 | "liblog", | ||
23 | "libhidlbase", | ||
24 | "libhidltransport", | ||
25 | "libutils", | ||
26 | "android.hardware.thermal@1.0", | ||
27 | "android.hardware.thermal@1.1", | ||
28 | ], | ||
29 | static_libs: ["VtsHalHidlTargetTestBase"], | ||
30 | cflags: [ | ||
31 | "-O0", | ||
32 | "-g", | ||
33 | ], | ||
34 | } | ||
35 | |||
diff --git a/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp b/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp new file mode 100644 index 00000000..6c1599bd --- /dev/null +++ b/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp | |||
@@ -0,0 +1,106 @@ | |||
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 | #include <android/hardware/thermal/1.1/IThermal.h> | ||
18 | #include <android/hardware/thermal/1.1/IThermalCallback.h> | ||
19 | #include <android/hardware/thermal/1.0/types.h> | ||
20 | |||
21 | #include <VtsHalHidlTargetCallbackBase.h> | ||
22 | #include <VtsHalHidlTargetTestBase.h> | ||
23 | |||
24 | using ::android::hardware::thermal::V1_0::Temperature; | ||
25 | using ::android::hardware::thermal::V1_0::TemperatureType; | ||
26 | using ::android::hardware::thermal::V1_1::IThermal; | ||
27 | using ::android::hardware::thermal::V1_1::IThermalCallback; | ||
28 | using ::android::hardware::Return; | ||
29 | using ::android::hardware::Void; | ||
30 | using ::android::sp; | ||
31 | |||
32 | constexpr char kCallbackNameNotifyThrottling[] = "notifyThrottling"; | ||
33 | static const Temperature kThrottleTemp = { | ||
34 | .type = TemperatureType::CPU, | ||
35 | .name = "test temperature sensor", | ||
36 | .currentValue = 98.6, | ||
37 | .throttlingThreshold = 58, | ||
38 | .shutdownThreshold = 60, | ||
39 | .vrThrottlingThreshold = 59, | ||
40 | }; | ||
41 | |||
42 | class ThermalCallbackArgs { | ||
43 | public: | ||
44 | bool isThrottling; | ||
45 | Temperature temperature; | ||
46 | }; | ||
47 | |||
48 | // Callback class for receiving thermal event notifications from main class | ||
49 | class ThermalCallback | ||
50 | : public ::testing::VtsHalHidlTargetCallbackBase<ThermalCallbackArgs>, | ||
51 | public IThermalCallback { | ||
52 | public: | ||
53 | virtual ~ThermalCallback() = default; | ||
54 | |||
55 | Return<void> notifyThrottling(bool isThrottling, | ||
56 | const Temperature& temperature) override { | ||
57 | ThermalCallbackArgs args; | ||
58 | args.isThrottling = isThrottling; | ||
59 | args.temperature = temperature; | ||
60 | NotifyFromCallback(kCallbackNameNotifyThrottling, args); | ||
61 | return Void(); | ||
62 | } | ||
63 | }; | ||
64 | |||
65 | // The main test class for THERMAL HIDL HAL 1.1. | ||
66 | class ThermalHidlTest : public ::testing::VtsHalHidlTargetTestBase { | ||
67 | public: | ||
68 | virtual void SetUp() override { | ||
69 | mThermal = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>(); | ||
70 | ASSERT_NE(mThermal, nullptr); | ||
71 | mThermalCallback = new(std::nothrow) ThermalCallback(); | ||
72 | ASSERT_NE(mThermalCallback, nullptr); | ||
73 | auto ret = mThermal->registerThermalCallback(mThermalCallback); | ||
74 | ASSERT_TRUE(ret.isOk()); | ||
75 | } | ||
76 | |||
77 | virtual void TearDown() override { | ||
78 | auto ret = mThermal->registerThermalCallback(nullptr); | ||
79 | ASSERT_TRUE(ret.isOk()); | ||
80 | } | ||
81 | |||
82 | protected: | ||
83 | sp<IThermal> mThermal; | ||
84 | sp<ThermalCallback> mThermalCallback; | ||
85 | }; // class ThermalHidlTest | ||
86 | |||
87 | // Test ThermalCallback::notifyThrottling(). | ||
88 | // This just calls into and back from our local ThermalCallback impl. | ||
89 | // Note: a real thermal throttling event from the Thermal HAL could be | ||
90 | // inadvertently received here. | ||
91 | TEST_F(ThermalHidlTest, NotifyThrottlingTest) { | ||
92 | auto ret = mThermalCallback->notifyThrottling(true, kThrottleTemp); | ||
93 | ASSERT_TRUE(ret.isOk()); | ||
94 | auto res = mThermalCallback->WaitForCallback(kCallbackNameNotifyThrottling); | ||
95 | EXPECT_TRUE(res.no_timeout); | ||
96 | ASSERT_TRUE(res.args); | ||
97 | EXPECT_EQ(true, res.args->isThrottling); | ||
98 | EXPECT_EQ(kThrottleTemp, res.args->temperature); | ||
99 | } | ||
100 | |||
101 | int main(int argc, char** argv) { | ||
102 | ::testing::InitGoogleTest(&argc, argv); | ||
103 | int status = RUN_ALL_TESTS(); | ||
104 | cout << "Test result = " << status << std::endl; | ||
105 | return status; | ||
106 | } | ||