OSDN Git Service

Fix an issue where Vehicle HAL would crash when trying to update a continuous propert...
authorEnrico Granata <egranata@google.com>
Mon, 3 Apr 2017 19:59:00 +0000 (12:59 -0700)
committerEnrico Granata <egranata@google.com>
Mon, 3 Apr 2017 19:59:00 +0000 (12:59 -0700)
Bug: 36858992
Test: build, flash and boot
Change-Id: I9906abbf386cf75e838102299e3e97de3475db63

automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp

index 68f94dc..b7ef896 100644 (file)
@@ -212,7 +212,7 @@ const ConfigDeclaration kVehicleProperties[] {
             .minSampleRate = 1.0f,
             .maxSampleRate = 2.0f,
         },
-        .initialValue = { .int32Values = {25} }
+        .initialValue = { .floatValues = {25.0f} }
     },
 
     {
index d965afe..e174932 100644 (file)
@@ -540,6 +540,12 @@ void DefaultVehicleHal::onContinuousPropertyTimer(const std::vector<int32_t>& pr
             if (VehiclePropertyType::FLOAT == getPropType(property)) {
                 // Just get some randomness to continuous properties to see slightly differnt values
                 // on the other end.
+                if (v->value.floatValues.size() == 0) {
+                    ALOGW("continuous property 0x%x is of type float but does not have a"
+                          " float value. defaulting to zero",
+                          property);
+                    v->value.floatValues = android::hardware::hidl_vec<float>{0.0f};
+                }
                 v->value.floatValues[0] = v->value.floatValues[0] + std::rand() % 5;
             }
         } else {