thermal: add hal objects.

Converted thermal HAL to HIDL,
Added default implementation.

Bug:32022261
Test: Compiles
Change-Id: I92d164b58464f2dee9d8d17affe57fb6af4c1c08
diff --git a/Android.bp b/Android.bp
index 2ef4e4c..013ae5b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -24,6 +24,8 @@
     "tests/libhwbinder/1.0",
     "tests/msgq/1.0",
     "tests/pointer/1.0",
+    "thermal/1.0",
+    "thermal/1.0/default",
     "vehicle/2.0",
     "vibrator/1.0",
     "wifi/1.0",
diff --git a/thermal/1.0/Android.bp b/thermal/1.0/Android.bp
new file mode 100644
index 0000000..0c5dd19
--- /dev/null
+++ b/thermal/1.0/Android.bp
@@ -0,0 +1,46 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.thermal@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.thermal@1.0",
+    srcs: [
+        "types.hal",
+        "IThermal.hal",
+    ],
+    out: [
+        "android/hardware/thermal/1.0/types.cpp",
+        "android/hardware/thermal/1.0/ThermalAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.thermal@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.thermal@1.0",
+    srcs: [
+        "types.hal",
+        "IThermal.hal",
+    ],
+    out: [
+        "android/hardware/thermal/1.0/types.h",
+        "android/hardware/thermal/1.0/IThermal.h",
+        "android/hardware/thermal/1.0/IHwThermal.h",
+        "android/hardware/thermal/1.0/BnThermal.h",
+        "android/hardware/thermal/1.0/BpThermal.h",
+        "android/hardware/thermal/1.0/BsThermal.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.thermal@1.0",
+    generated_sources: ["android.hardware.thermal@1.0_genc++"],
+    generated_headers: ["android.hardware.thermal@1.0_genc++_headers"],
+    export_generated_headers: ["android.hardware.thermal@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+}
diff --git a/thermal/1.0/Android.mk b/thermal/1.0/Android.mk
new file mode 100644
index 0000000..47a4d61
--- /dev/null
+++ b/thermal/1.0/Android.mk
@@ -0,0 +1,306 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.thermal@1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (CoolingDevice)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingDevice.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.CoolingDevice
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CoolingType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingType.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.CoolingType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CpuUsage)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CpuUsage.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.CpuUsage
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Temperature)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/Temperature.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.Temperature
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (TemperatureType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/TemperatureType.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.TemperatureType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatus)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.ThermalStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatusCode)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatusCode.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.ThermalStatusCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IThermal.hal
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/IThermal.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermal.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::IThermal
+
+$(GEN): $(LOCAL_PATH)/IThermal.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.thermal@1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (CoolingDevice)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingDevice.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.CoolingDevice
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CoolingType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CoolingType.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.CoolingType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (CpuUsage)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/CpuUsage.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.CpuUsage
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Temperature)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/Temperature.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.Temperature
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (TemperatureType)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/TemperatureType.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.TemperatureType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatus)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatus.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.ThermalStatus
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (ThermalStatusCode)
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/ThermalStatusCode.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::types.ThermalStatusCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IThermal.hal
+#
+GEN := $(intermediates)/android/hardware/thermal/1.0/IThermal.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IThermal.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.thermal@1.0::IThermal
+
+$(GEN): $(LOCAL_PATH)/IThermal.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/thermal/1.0/IThermal.hal b/thermal/1.0/IThermal.hal
new file mode 100644
index 0000000..4697f32
--- /dev/null
+++ b/thermal/1.0/IThermal.hal
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 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.0;
+
+interface IThermal {
+
+    /*
+     * Retrieves temperatures in Celsius.
+     *
+     * @return status Status of the operation. If status code is FAILURE,
+     *         the status.debugMessage must be populated with the human-readable
+     *         error message.
+     * @return temperatures If status code is SUCCESS, it's filled with the
+     *         current temperatures. The order of temperatures of built-in
+     *         devices (such as CPUs, GPUs and etc.) in the list must be kept
+     *         the same regardless the number of calls to this method even if
+     *         they go offline, if these devices exist on boot. The method
+     *         always returns and never removes such temperatures.
+     *
+     */
+    getTemperatures()
+        generates (ThermalStatus status, vec<Temperature> temperatures);
+
+    /*
+     * Retrieves CPU usage information of each core: active and total times
+     * in ms since first boot.
+     *
+     * @return status Status of the operation. If status code is FAILURE,
+     *         the status.debugMessage must be populated with the human-readable
+     *         error message.
+     * @return cpuUsages If status code is SUCCESS, it's filled with the current
+     *         CPU usages. The order and number of CPUs in the list must be kept
+     *         the same regardless the number of calls to this method.
+     *
+     */
+    getCpuUsages() generates (ThermalStatus status, vec<CpuUsage> cpuUsages);
+
+    /*
+     * Retrieves the cooling devices information.
+     *
+     * @return status Status of the operation. If status code is FAILURE,
+     *         the status.debugMessage must be populated with the human-readable
+     *         error message.
+     * @return devices If status code is SUCCESS, it's filled with the current
+     *         cooling device information. The order of built-in coolling
+     *         devices in the list must be kept the same regardless the number
+     *         of calls to this method even if they go offline, if these devices
+     *         exist on boot. The method always returns and never removes from
+     *         the list such coolling devices.
+     *
+     */
+    getCoolingDevices()
+        generates (ThermalStatus status, vec<CoolingDevice> devices);
+
+};
diff --git a/thermal/1.0/default/Android.bp b/thermal/1.0/default/Android.bp
new file mode 100644
index 0000000..626dcaf
--- /dev/null
+++ b/thermal/1.0/default/Android.bp
@@ -0,0 +1,16 @@
+cc_library_shared {
+    name: "android.hardware.thermal@1.0-impl",
+    relative_install_path: "hw",
+    srcs: ["Thermal.cpp"],
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libhardware",
+        "libhwbinder",
+        "libbase",
+        "libcutils",
+        "libutils",
+        "libhidl",
+        "android.hardware.thermal@1.0",
+    ],
+}
diff --git a/thermal/1.0/default/Android.mk b/thermal/1.0/default/Android.mk
new file mode 100644
index 0000000..fa7414e
--- /dev/null
+++ b/thermal/1.0/default/Android.mk
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2016 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE := android.hardware.thermal@1.0-service
+LOCAL_INIT_RC := android.hardware.thermal@1.0-service.rc
+LOCAL_SRC_FILES := \
+        service.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+        liblog \
+        libcutils \
+        libdl \
+        libbase \
+        libutils \
+        libhardware_legacy \
+        libhardware \
+
+LOCAL_SHARED_LIBRARIES += \
+        libhwbinder \
+        libhidl \
+        android.hardware.thermal@1.0 \
+
+include $(BUILD_EXECUTABLE)
diff --git a/thermal/1.0/default/Thermal.cpp b/thermal/1.0/default/Thermal.cpp
new file mode 100644
index 0000000..1b91687
--- /dev/null
+++ b/thermal/1.0/default/Thermal.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#define LOG_TAG "android.hardware.thermal@1.0-impl"
+#include <utils/Log.h>
+
+#include <errno.h>
+#include <hardware/hardware.h>
+#include <hardware/thermal.h>
+
+#include "Thermal.h"
+
+namespace android {
+namespace hardware {
+namespace thermal {
+namespace V1_0 {
+namespace implementation {
+
+Thermal::Thermal(thermal_module_t* module) : mModule(module) {
+}
+
+// Methods from ::android::hardware::thermal::V1_0::IThermal follow.
+Return<void> Thermal::getTemperatures(getTemperatures_cb _hidl_cb)  {
+    ThermalStatus status;
+    status.code = ThermalStatusCode::SUCCESS;
+    hidl_vec<Temperature> temperatures;
+
+    if (!mModule || !mModule->getTemperatures) {
+        ALOGI("getTemperatures is not implemented in Thermal HAL.");
+        _hidl_cb(status, temperatures);
+        return Void();
+    }
+
+    ssize_t list_size = mModule->getTemperatures(mModule, nullptr, 0);
+    if (list_size >= 0) {
+       temperature_t *list = new temperature_t[list_size];
+       ssize_t size = mModule->getTemperatures(mModule, list, list_size);
+       if (size >= 0) {
+           if (list_size > size) {
+               list_size = size;
+           }
+
+           temperatures.resize(list_size);
+           for (ssize_t i = 0; i < list_size; ++i) {
+               switch (list[i].type) {
+                   case DEVICE_TEMPERATURE_UNKNOWN:
+                       temperatures[i].type = TemperatureType::UNKNOWN;
+                       break;
+                   case DEVICE_TEMPERATURE_CPU:
+                       temperatures[i].type = TemperatureType::CPU;
+                       break;
+                   case DEVICE_TEMPERATURE_GPU:
+                       temperatures[i].type = TemperatureType::GPU;
+                       break;
+                   case DEVICE_TEMPERATURE_BATTERY:
+                       temperatures[i].type = TemperatureType::BATTERY;
+                       break;
+                   case DEVICE_TEMPERATURE_SKIN:
+                       temperatures[i].type = TemperatureType::SKIN;
+                       break;
+                   default:
+                       ALOGE("Unknown temperature %s type", list[i].name);;
+               }
+               temperatures[i].name = list[i].name;
+               temperatures[i].currentValue = list[i].current_value;
+               temperatures[i].throttlingThreshold = list[i].throttling_threshold;
+               temperatures[i].shutdownThreshold = list[i].shutdown_threshold;
+               temperatures[i].vrThrottlingThreshold = list[i].vr_throttling_threshold;
+           }
+       } else {
+           status.code = ThermalStatusCode::FAILURE;
+           status.debugMessage = strerror(-size);
+       }
+       delete[] list;
+    } else {
+        status.code = ThermalStatusCode::FAILURE;
+        status.debugMessage = strerror(-list_size);
+    }
+    _hidl_cb(status, temperatures);
+    return Void();
+}
+
+Return<void> Thermal::getCpuUsages(getCpuUsages_cb _hidl_cb)  {
+    ThermalStatus status;
+    hidl_vec<CpuUsage> cpuUsages;
+    status.code = ThermalStatusCode::SUCCESS;
+
+    if (!mModule || !mModule->getCpuUsages) {
+        ALOGI("getCpuUsages is not implemented in Thermal HAL");
+        _hidl_cb(status, cpuUsages);
+        return Void();
+    }
+
+    ssize_t size = mModule->getCpuUsages(mModule, nullptr);
+    if (size >= 0) {
+        cpu_usage_t *list = new cpu_usage_t[size];
+        size = mModule->getCpuUsages(mModule, list);
+        if (size >= 0) {
+            cpuUsages.resize(size);
+            for (ssize_t i = 0; i < size; ++i) {
+                cpuUsages[i].name = list[i].name;
+                cpuUsages[i].active = list[i].active;
+                cpuUsages[i].total = list[i].total;
+                cpuUsages[i].isOnline = list[i].is_online;
+            }
+        } else {
+            status.code = ThermalStatusCode::FAILURE;
+            status.debugMessage = strerror(-size);
+        }
+        delete[] list;
+    } else {
+        status.code = ThermalStatusCode::FAILURE;
+        status.debugMessage = strerror(-size);
+    }
+    _hidl_cb(status, cpuUsages);
+    return Void();
+}
+
+Return<void> Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb)  {
+    ThermalStatus status;
+    status.code = ThermalStatusCode::SUCCESS;
+    hidl_vec<CoolingDevice> coolingDevices;
+
+    if (!mModule || !mModule->getCoolingDevices) {
+        ALOGI("getCoolingDevices is not implemented in Thermal HAL.");
+        _hidl_cb(status, coolingDevices);
+        return Void();
+    }
+
+    ssize_t list_size = mModule->getCoolingDevices(mModule, nullptr, 0);
+    if (list_size >= 0) {
+        cooling_device_t *list = new cooling_device_t[list_size];
+        ssize_t size = mModule->getCoolingDevices(mModule, list, list_size);
+        if (size >= 0) {
+            if (list_size > size) {
+                list_size = size;
+            }
+            coolingDevices.resize(list_size);
+            for (ssize_t i = 0; i < list_size; ++i) {
+                switch (list[i].type) {
+                    case FAN_RPM:
+                        coolingDevices[i].type = CoolingType::FAN_RPM;
+                        break;
+                    default:
+                        ALOGE("Unknown cooling device %s type", list[i].name);
+                }
+                coolingDevices[i].name = list[i].name;
+                coolingDevices[i].currentValue = list[i].current_value;
+            }
+
+        } else {
+            status.code = ThermalStatusCode::FAILURE;
+            status.debugMessage = strerror(-size);
+        }
+        delete[] list;
+    } else {
+        status.code = ThermalStatusCode::FAILURE;
+        status.debugMessage = strerror(-list_size);
+    }
+    _hidl_cb(status, coolingDevices);
+    return Void();
+}
+
+IThermal* HIDL_FETCH_IThermal(const char* /* name */) {
+    thermal_module_t* module;
+    status_t err = hw_get_module(THERMAL_HARDWARE_MODULE_ID,
+            const_cast<hw_module_t const**>(reinterpret_cast<hw_module_t**>(&module)));
+    if (err || !module) {
+        ALOGE("Couldn't load %s module (%s)", THERMAL_HARDWARE_MODULE_ID,
+              strerror(-err));
+    }
+
+    if (err == 0 && module->common.methods->open) {
+        struct hw_device_t* device;
+        err = module->common.methods->open(&module->common, THERMAL_HARDWARE_MODULE_ID, &device);
+        if (err) {
+            ALOGE("Couldn't open %s module (%s)", THERMAL_HARDWARE_MODULE_ID, strerror(-err));
+        } else {
+            return new Thermal(reinterpret_cast<thermal_module_t*>(device));
+        }
+    }
+    return new Thermal(module);
+}
+
+} // namespace implementation
+}  // namespace V1_0
+}  // namespace thermal
+}  // namespace hardware
+}  // namespace android
diff --git a/thermal/1.0/default/Thermal.h b/thermal/1.0/default/Thermal.h
new file mode 100644
index 0000000..8212ab9
--- /dev/null
+++ b/thermal/1.0/default/Thermal.h
@@ -0,0 +1,45 @@
+#ifndef HIDL_GENERATED_android_hardware_thermal_V1_0_Thermal_H_
+#define HIDL_GENERATED_android_hardware_thermal_V1_0_Thermal_H_
+
+#include <android/hardware/thermal/1.0/IThermal.h>
+#include <hidl/Status.h>
+#include <hardware/thermal.h>
+
+#include <hidl/MQDescriptor.h>
+
+namespace android {
+namespace hardware {
+namespace thermal {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::thermal::V1_0::CoolingDevice;
+using ::android::hardware::thermal::V1_0::CpuUsage;
+using ::android::hardware::thermal::V1_0::IThermal;
+using ::android::hardware::thermal::V1_0::Temperature;
+using ::android::hardware::thermal::V1_0::ThermalStatus;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+struct Thermal : public IThermal {
+    Thermal(thermal_module_t* module);
+    // Methods from ::android::hardware::thermal::V1_0::IThermal follow.
+    Return<void> getTemperatures(getTemperatures_cb _hidl_cb)  override;
+    Return<void> getCpuUsages(getCpuUsages_cb _hidl_cb)  override;
+    Return<void> getCoolingDevices(getCoolingDevices_cb _hidl_cb)  override;
+    private:
+        thermal_module_t* mModule;
+};
+
+extern "C" IThermal* HIDL_FETCH_IThermal(const char* name);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace thermal
+}  // namespace hardware
+}  // namespace android
+
+#endif  // HIDL_GENERATED_android_hardware_thermal_V1_0_Thermal_H_
diff --git a/thermal/1.0/default/android.hardware.thermal@1.0-service.rc b/thermal/1.0/default/android.hardware.thermal@1.0-service.rc
new file mode 100644
index 0000000..cc7ba6a
--- /dev/null
+++ b/thermal/1.0/default/android.hardware.thermal@1.0-service.rc
@@ -0,0 +1,4 @@
+service thermal-hal-1-0 /system/bin/hw/android.hardware.thermal@1.0-service
+    class hal
+    user system
+    group system readproc
diff --git a/thermal/1.0/default/service.cpp b/thermal/1.0/default/service.cpp
new file mode 100644
index 0000000..b09b5ec
--- /dev/null
+++ b/thermal/1.0/default/service.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 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 <iostream>
+#include <unistd.h>
+
+#include <android/hardware/thermal/1.0/IThermal.h>
+
+#include <hidl/IServiceManager.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Errors.h>
+
+#define LOG_TAG "android.hardware.thermal@1.0-service"
+#include <utils/Log.h>
+#include <utils/StrongPointer.h>
+
+using android::sp;
+
+// libhwbinder:
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+
+// Generated HIDL files
+using android::hardware::thermal::V1_0::IThermal;
+
+int main() {
+    const char instance[] = "thermal";
+    sp<IThermal> service = IThermal::getService(instance, true /* getStub */);
+    if (service.get() == nullptr) {
+        ALOGE("IThermal::getService returned NULL, exiting");
+        return EXIT_FAILURE;
+    }
+    LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
+    service->registerAsService(instance);
+
+    ProcessState::self()->setThreadPoolMaxThreadCount(0);
+    ProcessState::self()->startThreadPool();
+    IPCThreadState::self()->joinThreadPool();
+}
diff --git a/thermal/1.0/types.hal b/thermal/1.0/types.hal
new file mode 100644
index 0000000..b3dcc7d
--- /dev/null
+++ b/thermal/1.0/types.hal
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2016 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.0;
+
+/** Device temperature types */
+enum TemperatureType : int32_t {
+    UNKNOWN = -1,
+    CPU = 0,
+    GPU = 1,
+    BATTERY = 2,
+    SKIN = 3,
+};
+
+enum CoolingType : int32_t {
+    /** Fan cooling device speed in RPM. */
+    FAN_RPM = 0,
+};
+
+struct Temperature {
+    /**
+     * This temperature's type.
+     */
+    TemperatureType type;
+
+    /**
+     * Name of this temperature.
+     * All temperatures of the same "type" must have a different "name",
+     * e.g., cpu0, battery.
+     */
+    string name;
+
+    /**
+     * Current temperature in Celsius. If not available set by HAL to
+     * UNKNOWN_TEMPERATURE.
+     * Current temperature can be in any units if type=UNKNOWN.
+     */
+    float currentValue;
+
+    /**
+     * Throttling temperature constant for this temperature.
+     * If not available, set by HAL to UNKNOWN_TEMPERATURE.
+     */
+    float throttlingThreshold;
+
+    /**
+     * Shutdown temperature constant for this temperature.
+     * If not available, set by HAL to UNKNOWN_TEMPERATURE.
+     */
+    float shutdownThreshold;
+
+    /**
+     * Threshold temperature above which the VR mode clockrate minimums cannot
+     * be maintained for this device.
+     * If not available, set by HAL to UNKNOWN_TEMPERATURE.
+     */
+    float vrThrottlingThreshold;
+
+};
+
+struct CoolingDevice {
+    /**
+     * This cooling device type.
+     */
+    CoolingType type;
+
+    /**
+     * Name of this cooling device.
+     * All cooling devices of the same "type" must have a different "name".
+     */
+    string name;
+
+    /**
+     * Current cooling device value. Units depend on cooling device "type".
+     */
+    float currentValue;
+
+};
+
+struct CpuUsage {
+    /**
+     * Name of this CPU.
+     * All CPUs must have a different "name".
+     */
+    string name;
+
+    /**
+     * Active time since the last boot in ms.
+     */
+    uint64_t active;
+
+    /**
+     * Total time since the last boot in ms.
+     */
+    uint64_t total;
+
+    /**
+     * Is set to true when a core is online.
+     * If the core is offline, all other members except |name| should be ignored.
+     */
+    bool isOnline;
+
+};
+
+enum ThermalStatusCode : uint32_t {
+    /** No errors. */
+    SUCCESS,
+    /** Unknown failure occured. */
+    FAILURE
+};
+
+/**
+ * Generic structure to return the status of any thermal operation.
+ */
+struct ThermalStatus {
+    ThermalStatusCode code;
+
+    /**
+     * A specific error message to provide more information.
+     * This can be used for debugging purposes only.
+     */
+    string debugMessage;
+};
+
+/**
+ * TODO(pbond): add float constant UNDEFINED_TEMPERATURE.
+ */