diff --git a/device.mk b/device.mk index 31727c3d..2ea35376 100755 --- a/device.mk +++ b/device.mk @@ -353,7 +353,7 @@ PRODUCT_PACKAGES += \ # Thermal packages PRODUCT_PACKAGES += \ - android.hardware.thermal@1.0-impl-wahoo + android.hardware.thermal@1.1-impl-wahoo #GNSS HAL PRODUCT_PACKAGES += \ diff --git a/manifest.xml b/manifest.xml index 3703fbd1..b4d1c71d 100644 --- a/manifest.xml +++ b/manifest.xml @@ -295,7 +295,7 @@ android.hardware.thermal hwbinder - 1.0 + 1.1 IThermal default diff --git a/thermal/Android.bp b/thermal/Android.bp index fae9616d..fcd227e1 100644 --- a/thermal/Android.bp +++ b/thermal/Android.bp @@ -1,5 +1,5 @@ cc_library_shared { - name: "android.hardware.thermal@1.0-wahoo", + name: "android.hardware.thermal@1.1-wahoo", defaults: ["hidl_defaults"], owner: "qcom", vendor: true, @@ -15,5 +15,6 @@ cc_library_shared { "libhidltransport", "libutils", "android.hardware.thermal@1.0", + "android.hardware.thermal@1.1", ], } diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp index 5bedddee..d397901b 100644 --- a/thermal/Thermal.cpp +++ b/thermal/Thermal.cpp @@ -25,11 +25,29 @@ namespace android { namespace hardware { namespace thermal { -namespace V1_0 { +namespace V1_1 { namespace implementation { Thermal::Thermal() : enabled(initThermal()) {} +namespace { + +// Saves the IThermalCallback client object registered from the +// framework for sending thermal events to the framework thermal event bus. +sp gThermalCallback; + +struct ThermalDeathRecipient : hidl_death_recipient { + virtual void serviceDied( + uint64_t cookie __unused, const wp& who __unused) { + gThermalCallback = nullptr; + LOG(ERROR) << "IThermalCallback HIDL service died"; + } +}; + +sp gThermalCallbackDied = nullptr; + +} // anonymous namespace + // Methods from ::android::hardware::thermal::V1_0::IThermal follow. Return Thermal::getTemperatures(getTemperatures_cb _hidl_cb) { ThermalStatus status; @@ -112,8 +130,28 @@ Return Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb) { return Void(); } +// Methods from ::android::hardware::thermal::V1_1::IThermal follow. + +Return Thermal::registerThermalCallback( + const sp& callback) { + gThermalCallback = callback; + + if (gThermalCallback != nullptr) { + if (gThermalCallbackDied == nullptr) + gThermalCallbackDied = new ThermalDeathRecipient(); + + if (gThermalCallbackDied != nullptr) + gThermalCallback->linkToDeath( + gThermalCallbackDied, 0x451F /* cookie, unused */); + LOG(INFO) << "ThermalCallback registered"; + } else { + LOG(INFO) << "ThermalCallback unregistered"; + } + return Void(); +} + } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace thermal } // namespace hardware } // namespace android diff --git a/thermal/Thermal.h b/thermal/Thermal.h index f9ce7ed8..5a75c258 100644 --- a/thermal/Thermal.h +++ b/thermal/Thermal.h @@ -13,28 +13,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef ANDROID_HARDWARE_THERMAL_V1_0_WAHOO_THERMAL_H -#define ANDROID_HARDWARE_THERMAL_V1_0_WAHOO_THERMAL_H +#ifndef ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H +#define ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H -#include +#include +#include #include #include namespace android { namespace hardware { namespace thermal { -namespace V1_0 { +namespace V1_1 { 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::thermal::V1_0::ThermalStatusCode; +using ::android::hardware::thermal::V1_1::IThermal; +using ::android::hardware::thermal::V1_1::IThermalCallback; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::hidl_vec; using ::android::hardware::hidl_string; +using ::android::hardware::hidl_death_recipient; +using ::android::hidl::base::V1_0::IBase; using ::android::sp; struct Thermal : public IThermal { @@ -43,15 +48,18 @@ struct Thermal : public IThermal { Return getTemperatures(getTemperatures_cb _hidl_cb) override; Return getCpuUsages(getCpuUsages_cb _hidl_cb) override; Return getCoolingDevices(getCoolingDevices_cb _hidl_cb) override; + // Methods from ::android::hardware::thermal::V1_1::IThermal follow. + Return registerThermalCallback( + const sp& callback) override; private: bool enabled; }; } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace thermal } // namespace hardware } // namespace android -#endif // ANDROID_HARDWARE_THERMAL_V1_0_WAHOO_THERMAL_H +#endif // ANDROID_HARDWARE_THERMAL_V1_1_WAHOO_THERMAL_H diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp index f5f146cf..6f61a989 100644 --- a/thermal/thermal-helper.cpp +++ b/thermal/thermal-helper.cpp @@ -30,9 +30,11 @@ namespace android { namespace hardware { namespace thermal { -namespace V1_0 { +namespace V1_1 { namespace implementation { +using ::android::hardware::thermal::V1_0::TemperatureType; + static unsigned int gSkinSensorNum; static unsigned int gTsensOffset; static unsigned int gSkinThrottlingThreshold; @@ -287,7 +289,7 @@ ssize_t fillCpuUsages(hidl_vec *cpuUsages) { } } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace thermal } // namespace hardware } // namespace android diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h index e08d4e72..9fd013b4 100644 --- a/thermal/thermal-helper.h +++ b/thermal/thermal-helper.h @@ -30,12 +30,12 @@ #ifndef __THERMAL_HELPER_H__ #define __THERMAL_HELPER_H__ -#include +#include namespace android { namespace hardware { namespace thermal { -namespace V1_0 { +namespace V1_1 { namespace implementation { using ::android::hardware::thermal::V1_0::CpuUsage; @@ -92,7 +92,7 @@ ssize_t fillTemperatures(hidl_vec *temperatures); ssize_t fillCpuUsages(hidl_vec *cpuUsages); } // namespace implementation -} // namespace V1_0 +} // namespace V1_1 } // namespace thermal } // namespace hardware } // namespace android