Use the latest temperature read as base for headroom calculation

It was unexpectedly using the oldest temperature which can be 30s old
and not accurately reflect the current device's temperature

The unit test used to add new temperatures to the front of ring
buffer, which was inconsistent with the implementation which add
to the back instead, which is now fixed

Bug: 343809405
Test: atest ThermalManagerServiceTest
Change-Id: I706933e7f4bbd1b9abd6591255a605d7643ad7ee
2 files changed