Return INVALID_ARG if cont prop rate is 0.

Return INVALID_ARG if subscribe to a continuous property with
sample rate 0.

Test: atest FakeVehicleHardwareTest
Bug: 316208952
Change-Id: I2a37ad6c2244d0bed088c700bd0a3ccb98fd4675
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
index 8cd92b3..96eff0e 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
@@ -294,7 +294,7 @@
     void registerRefreshLocked(PropIdAreaId propIdAreaId, VehiclePropertyStore::EventMode eventMode,
                                float sampleRateHz) REQUIRES(mLock);
     void unregisterRefreshLocked(PropIdAreaId propIdAreaId) REQUIRES(mLock);
-    void refreshTimeStampForInterval(int64_t intervalInNanos) EXCLUDES(mLock);
+    void refreshTimestampForInterval(int64_t intervalInNanos) EXCLUDES(mLock);
 
     static aidl::android::hardware::automotive::vehicle::VehiclePropValue createHwInputKeyProp(
             aidl::android::hardware::automotive::vehicle::VehicleHwKeyInputAction action,
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 385f616..d95ffd6 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
@@ -2109,7 +2109,7 @@
     return false;
 }
 
-void FakeVehicleHardware::refreshTimeStampForInterval(int64_t intervalInNanos) {
+void FakeVehicleHardware::refreshTimestampForInterval(int64_t intervalInNanos) {
     std::unordered_map<PropIdAreaId, VehiclePropertyStore::EventMode, PropIdAreaIdHash>
             eventModeByPropIdAreaId;
 
@@ -2159,7 +2159,7 @@
 
     // This is the first action for the interval, register a timer callback for that interval.
     auto action = std::make_shared<RecurrentTimer::Callback>(
-            [this, intervalInNanos] { refreshTimeStampForInterval(intervalInNanos); });
+            [this, intervalInNanos] { refreshTimestampForInterval(intervalInNanos); });
     mActionByIntervalInNanos[intervalInNanos] = ActionForInterval{
             .propIdAreaIdsToRefresh = {propIdAreaId},
             .recurrentAction = action,
@@ -2201,7 +2201,7 @@
         case VehiclePropertyChangeMode::CONTINUOUS:
             if (sampleRateHz == 0.f) {
                 ALOGE("Must not use sample rate 0 for a continuous property");
-                return StatusCode::INTERNAL_ERROR;
+                return StatusCode::INVALID_ARG;
             }
             // For continuous properties, we must generate a new onPropertyChange event
             // periodically according to the sample rate.
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
index 6d2efd5..909c89d 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
@@ -3444,6 +3444,14 @@
             << "must not receive on change events if the propId, areaId is unsubscribed";
 }
 
+TEST_F(FakeVehicleHardwareTest, testSubscribeContinuous_rate0_mustReturnInvalidArg) {
+    int32_t propSpeed = toInt(VehicleProperty::PERF_VEHICLE_SPEED);
+    int32_t areaId = 0;
+    auto status = getHardware()->subscribe(newSubscribeOptions(propSpeed, areaId, 0));
+
+    ASSERT_EQ(status, StatusCode::INVALID_ARG);
+}
+
 TEST_F(FakeVehicleHardwareTest, testSetHvacTemperatureValueSuggestion) {
     float CELSIUS = static_cast<float>(toInt(VehicleUnit::CELSIUS));
     float FAHRENHEIT = static_cast<float>(toInt(VehicleUnit::FAHRENHEIT));