thermal: substitute undefined temperature by NAN.

Bug: 34107726
Test: vts, cts

Change-Id: Ia6e9e83691e8b6b5e2760579e1131a5994a48572
diff --git a/thermal/1.0/default/Thermal.cpp b/thermal/1.0/default/Thermal.cpp
index 8a8ad0a..2dd0090 100644
--- a/thermal/1.0/default/Thermal.cpp
+++ b/thermal/1.0/default/Thermal.cpp
@@ -17,6 +17,7 @@
 #define LOG_TAG "android.hardware.thermal@1.0-impl"
 
 #include <errno.h>
+#include <math.h>
 
 #include <vector>
 
@@ -33,6 +34,14 @@
 namespace V1_0 {
 namespace implementation {
 
+namespace {
+
+float finalizeTemperature(float temperature) {
+    return temperature == UNKNOWN_TEMPERATURE ? NAN : temperature;
+}
+
+}
+
 Thermal::Thermal(thermal_module_t* module) : mModule(module) {}
 
 // Methods from ::android::hardware::thermal::V1_0::IThermal follow.
@@ -76,10 +85,11 @@
             ;
         }
         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;
+        temperatures[i].currentValue = finalizeTemperature(list[i].current_value);
+        temperatures[i].throttlingThreshold = finalizeTemperature(list[i].throttling_threshold);
+        temperatures[i].shutdownThreshold = finalizeTemperature(list[i].shutdown_threshold);
+        temperatures[i].vrThrottlingThreshold =
+                finalizeTemperature(list[i].vr_throttling_threshold);
       }
     }
   }