diff options
author | Xin Li <delphij@google.com> | 2017-11-14 12:08:38 -0800 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2017-11-14 12:08:38 -0800 |
commit | bb9e38fef95b7bc932ebcad18508e03228f9f7d3 (patch) | |
tree | 29e859e08879c87f591507de0f370abd1ec66fe2 /thermal | |
parent | b86b2d2881d53219c59a5eb85a3d73cb45942661 (diff) | |
parent | 1a06284b24f5eb7bb9c1fea0817da8898b3b1bff (diff) |
Merge commit '1a06284b24f5eb7bb9c1fea0817da8898b3b1bff' from
oc-mr1-dev-plus-aosp into stage-aosp-master
Change-Id: I2a044eb8c9981d0a8198ffe2df55559afbd76341
Merged-In: I4fb9f18884f7ef21162015a0032c4431444f7025
Diffstat (limited to 'thermal')
-rw-r--r-- | thermal/1.1/Android.bp | 71 | ||||
-rw-r--r-- | thermal/1.1/Android.mk | 65 | ||||
-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 | 26 | ||||
-rw-r--r-- | thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp | 106 | ||||
-rw-r--r-- | thermal/Android.bp | 2 |
7 files changed, 334 insertions, 0 deletions
diff --git a/thermal/1.1/Android.bp b/thermal/1.1/Android.bp new file mode 100644 index 0000000000..0985d947b6 --- /dev/null +++ b/thermal/1.1/Android.bp @@ -0,0 +1,71 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. + +filegroup { + name: "android.hardware.thermal@1.1_hal", + srcs: [ + "IThermal.hal", + "IThermalCallback.hal", + ], +} + +genrule { + name: "android.hardware.thermal@1.1_genc++", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.thermal@1.1", + srcs: [ + ":android.hardware.thermal@1.1_hal", + ], + out: [ + "android/hardware/thermal/1.1/ThermalAll.cpp", + "android/hardware/thermal/1.1/ThermalCallbackAll.cpp", + ], +} + +genrule { + name: "android.hardware.thermal@1.1_genc++_headers", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.thermal@1.1", + srcs: [ + ":android.hardware.thermal@1.1_hal", + ], + out: [ + "android/hardware/thermal/1.1/IThermal.h", + "android/hardware/thermal/1.1/IHwThermal.h", + "android/hardware/thermal/1.1/BnHwThermal.h", + "android/hardware/thermal/1.1/BpHwThermal.h", + "android/hardware/thermal/1.1/BsThermal.h", + "android/hardware/thermal/1.1/IThermalCallback.h", + "android/hardware/thermal/1.1/IHwThermalCallback.h", + "android/hardware/thermal/1.1/BnHwThermalCallback.h", + "android/hardware/thermal/1.1/BpHwThermalCallback.h", + "android/hardware/thermal/1.1/BsThermalCallback.h", + ], +} + +cc_library { + name: "android.hardware.thermal@1.1", + defaults: ["hidl-module-defaults"], + generated_sources: ["android.hardware.thermal@1.1_genc++"], + generated_headers: ["android.hardware.thermal@1.1_genc++_headers"], + export_generated_headers: ["android.hardware.thermal@1.1_genc++_headers"], + vendor_available: true, + vndk: { + enabled: true, + }, + shared_libs: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "liblog", + "libutils", + "libcutils", + "android.hardware.thermal@1.0", + ], + export_shared_lib_headers: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "android.hardware.thermal@1.0", + ], +} diff --git a/thermal/1.1/Android.mk b/thermal/1.1/Android.mk new file mode 100644 index 0000000000..059ac8bde7 --- /dev/null +++ b/thermal/1.1/Android.mk @@ -0,0 +1,65 @@ +# This file is autogenerated by hidl-gen. Do not edit manually. + +LOCAL_PATH := $(call my-dir) + +################################################################################ + +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.thermal-V1.1-java +LOCAL_MODULE_CLASS := JAVA_LIBRARIES + +intermediates := $(call local-generated-sources-dir, COMMON) + +HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) + +LOCAL_JAVA_LIBRARIES := \ + android.hardware.thermal-V1.0-java \ + android.hidl.base-V1.0-java \ + +LOCAL_NO_STANDARD_LIBRARIES := true +LOCAL_JAVA_LIBRARIES += core-oj hwbinder + +# +# Build IThermal.hal +# +GEN := $(intermediates)/android/hardware/thermal/V1_1/IThermal.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermal.hal +$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IThermalCallback.hal +$(GEN): $(LOCAL_PATH)/IThermalCallback.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.thermal@1.1::IThermal + +$(GEN): $(LOCAL_PATH)/IThermal.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build IThermalCallback.hal +# +GEN := $(intermediates)/android/hardware/thermal/V1_1/IThermalCallback.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermalCallback.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.thermal@1.1::IThermalCallback + +$(GEN): $(LOCAL_PATH)/IThermalCallback.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) +include $(BUILD_JAVA_LIBRARY) + + + +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 0000000000..14f35baa00 --- /dev/null +++ b/thermal/1.1/IThermal.hal @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.thermal@1.1; + +import android.hardware.thermal@1.0::IThermal; +import IThermalCallback; + +interface IThermal extends @1.0::IThermal { + /** + * Register an IThermalCallback, used by the Thermal HAL + * to send thermal events to the framework thermal service. + * + * @param callback the IThermalCallback to use for sending + * thermal events, or nullptr to set no callback + */ + registerThermalCallback(IThermalCallback callback); +}; diff --git a/thermal/1.1/IThermalCallback.hal b/thermal/1.1/IThermalCallback.hal new file mode 100644 index 0000000000..f418ec3dd4 --- /dev/null +++ b/thermal/1.1/IThermalCallback.hal @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.thermal@1.1; + +import android.hardware.thermal@1.0::Temperature; + +/** + * IThermalCallback connects vendor code to the framework binder ThermalService. + */ +interface IThermalCallback { + /** + * Send a thermal throttling start/stop event to all ThermalService + * thermal event listeners. + * @param isThrottling true if device is currently throttling + * @param temperature The temperature associated with the throttling + * start/stop event + */ + oneway notifyThrottling(bool isThrottling, Temperature temperature); +}; diff --git a/thermal/1.1/vts/functional/Android.bp b/thermal/1.1/vts/functional/Android.bp new file mode 100644 index 0000000000..f5f01faf2c --- /dev/null +++ b/thermal/1.1/vts/functional/Android.bp @@ -0,0 +1,26 @@ +// +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +cc_test { + name: "VtsHalThermalV1_1TargetTest", + defaults: ["VtsHalTargetTestDefaults"], + srcs: ["VtsHalThermalV1_1TargetTest.cpp"], + static_libs: [ + "android.hardware.thermal@1.0", + "android.hardware.thermal@1.1", + ], +} + 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 0000000000..6c1599bdb2 --- /dev/null +++ b/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <android/hardware/thermal/1.1/IThermal.h> +#include <android/hardware/thermal/1.1/IThermalCallback.h> +#include <android/hardware/thermal/1.0/types.h> + +#include <VtsHalHidlTargetCallbackBase.h> +#include <VtsHalHidlTargetTestBase.h> + +using ::android::hardware::thermal::V1_0::Temperature; +using ::android::hardware::thermal::V1_0::TemperatureType; +using ::android::hardware::thermal::V1_1::IThermal; +using ::android::hardware::thermal::V1_1::IThermalCallback; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +constexpr char kCallbackNameNotifyThrottling[] = "notifyThrottling"; +static const Temperature kThrottleTemp = { + .type = TemperatureType::CPU, + .name = "test temperature sensor", + .currentValue = 98.6, + .throttlingThreshold = 58, + .shutdownThreshold = 60, + .vrThrottlingThreshold = 59, +}; + +class ThermalCallbackArgs { + public: + bool isThrottling; + Temperature temperature; +}; + +// Callback class for receiving thermal event notifications from main class +class ThermalCallback + : public ::testing::VtsHalHidlTargetCallbackBase<ThermalCallbackArgs>, + public IThermalCallback { + public: + virtual ~ThermalCallback() = default; + + Return<void> notifyThrottling(bool isThrottling, + const Temperature& temperature) override { + ThermalCallbackArgs args; + args.isThrottling = isThrottling; + args.temperature = temperature; + NotifyFromCallback(kCallbackNameNotifyThrottling, args); + return Void(); + } +}; + +// The main test class for THERMAL HIDL HAL 1.1. +class ThermalHidlTest : public ::testing::VtsHalHidlTargetTestBase { + public: + virtual void SetUp() override { + mThermal = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>(); + ASSERT_NE(mThermal, nullptr); + mThermalCallback = new(std::nothrow) ThermalCallback(); + ASSERT_NE(mThermalCallback, nullptr); + auto ret = mThermal->registerThermalCallback(mThermalCallback); + ASSERT_TRUE(ret.isOk()); + } + + virtual void TearDown() override { + auto ret = mThermal->registerThermalCallback(nullptr); + ASSERT_TRUE(ret.isOk()); + } + + protected: + sp<IThermal> mThermal; + sp<ThermalCallback> mThermalCallback; +}; // class ThermalHidlTest + +// Test ThermalCallback::notifyThrottling(). +// This just calls into and back from our local ThermalCallback impl. +// Note: a real thermal throttling event from the Thermal HAL could be +// inadvertently received here. +TEST_F(ThermalHidlTest, NotifyThrottlingTest) { + auto ret = mThermalCallback->notifyThrottling(true, kThrottleTemp); + ASSERT_TRUE(ret.isOk()); + auto res = mThermalCallback->WaitForCallback(kCallbackNameNotifyThrottling); + EXPECT_TRUE(res.no_timeout); + ASSERT_TRUE(res.args); + EXPECT_EQ(true, res.args->isThrottling); + EXPECT_EQ(kThrottleTemp, res.args->temperature); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + int status = RUN_ALL_TESTS(); + cout << "Test result = " << status << std::endl; + return status; +} diff --git a/thermal/Android.bp b/thermal/Android.bp index ed19a37034..a5415df348 100644 --- a/thermal/Android.bp +++ b/thermal/Android.bp @@ -3,4 +3,6 @@ subdirs = [ "1.0", "1.0/default", "1.0/vts/functional", + "1.1", + "1.1/vts/functional", ] |