Fix thermalservice crash on ThermalHAL 1.1
Test: Build
Change-Id: I187d4b20fef72f0f40e0f3c857d75f338e55de68
diff --git a/services/thermalservice/thermalserviced.cpp b/services/thermalservice/thermalserviced.cpp
index b3da76b..7826a76 100644
--- a/services/thermalservice/thermalserviced.cpp
+++ b/services/thermalservice/thermalserviced.cpp
@@ -109,28 +109,30 @@
SLOGE("registerThermalCallback failed, status: %s", ret.description().c_str());
}
}
- }
+ } else {
+ if (gThermalHalDied != nullptr) {
+ gThermalHal2_0->linkToDeath(gThermalHalDied, 0x451F /* cookie */);
+ }
- if (gThermalHalDied != nullptr) {
- gThermalHal2_0->linkToDeath(gThermalHalDied, 0x451F /* cookie */);
- }
-
- if (mThermalCallback != nullptr) {
- Return<void> ret =
- gThermalHal2_0
- ->registerThermalChangedCallback(
- mThermalChangedCallback,
- false,
- TemperatureType::SKIN, // not used
- [](ThermalStatus status) {
- if (ThermalStatusCode::SUCCESS !=
- status.code) {
- SLOGE("registerThermalChangedCallback failed, status: %s",
- status.debugMessage.c_str());
- }
- });
- if (!ret.isOk()) {
- SLOGE("registerThermalChangedCallback failed, status: %s", ret.description().c_str());
+ if (mThermalCallback != nullptr) {
+ Return<void> ret =
+ gThermalHal2_0
+ ->registerThermalChangedCallback(mThermalChangedCallback, false,
+ TemperatureType::SKIN, // not used
+ [](ThermalStatus status) {
+ if (ThermalStatusCode::SUCCESS !=
+ status.code) {
+ SLOGE("registerThermalChangedC"
+ "allback failed, "
+ "status: %s",
+ status.debugMessage
+ .c_str());
+ }
+ });
+ if (!ret.isOk()) {
+ SLOGE("registerThermalChangedCallback failed, status: %s",
+ ret.description().c_str());
+ }
}
}
}