From 5e119598fa65287c1186000501823d5ea080112e Mon Sep 17 00:00:00 2001 From: Aaqib Ismail Date: Thu, 30 Nov 2023 17:43:22 -0800 Subject: [PATCH] Change temp approximations to be accurate We need to use a more accurate ratio of celsius to fahrenheit along with better min/max temperature conversions so if a client sets the value using standard conversion or using this table, they will produce the same result. Also, we need to round to the closest increment instead of truncating. Bug: 305274504 Bug: 313720524 Test: atest CtsCarTestCases:CarPropertyManagerTest Test: atest FakeVehicleHardwareTest Change-Id: Ia4d53e1a904fb2b40f5ec428ab548895c8f307ed --- .../impl/default_config/config/DefaultProperties.json | 8 ++++---- .../impl/fake_impl/hardware/src/FakeVehicleHardware.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json b/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json index d3bb60c7ae..2f4da62764 100644 --- a/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json +++ b/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json @@ -2368,9 +2368,9 @@ 160, 280, 5, - 600, - 840, - 10 + 608, + 824, + 9 ] }, { @@ -2380,7 +2380,7 @@ 66.19999694824219, "VehicleUnit::FAHRENHEIT", 19.0, - 66.0 + 66.2 ] } }, diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp index acee9b327b..dcc1e38ff0 100644 --- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp @@ -434,7 +434,7 @@ int FakeVehicleHardware::getHvacTempNumIncrements(int requestedTemp, int minTemp int increment) { requestedTemp = std::max(requestedTemp, minTemp); requestedTemp = std::min(requestedTemp, maxTemp); - int numIncrements = (requestedTemp - minTemp) / increment; + int numIncrements = std::round((requestedTemp - minTemp) / static_cast(increment)); return numIncrements; }