Merge "RTT: Add OuiKeyedData List in ranging APIs" into main
diff --git a/automotive/remoteaccess/test_grpc_server/impl/include/TestWakeupClientServiceImpl.h b/automotive/remoteaccess/test_grpc_server/impl/include/TestWakeupClientServiceImpl.h
index a7f47c2..41cc5d0 100644
--- a/automotive/remoteaccess/test_grpc_server/impl/include/TestWakeupClientServiceImpl.h
+++ b/automotive/remoteaccess/test_grpc_server/impl/include/TestWakeupClientServiceImpl.h
@@ -78,6 +78,7 @@
     void waitForTask();
     void stopWait();
     bool isEmpty();
+    bool isStopped();
 
   private:
     friend class TaskTimeoutMessageHandler;
@@ -87,7 +88,7 @@
             GUARDED_BY(mLock);
     // A variable to notify mTasks is not empty.
     std::condition_variable mTasksNotEmptyCv;
-    std::atomic<bool> mStopped;
+    std::atomic<bool> mStopped = false;
     android::sp<Looper> mLooper;
     android::sp<TaskTimeoutMessageHandler> mTaskTimeoutMessageHandler;
     std::atomic<int> mTaskIdCounter = 0;
@@ -214,7 +215,7 @@
     std::atomic<bool> mRemoteTaskConnectionAlive = false;
     std::mutex mLock;
     bool mGeneratingFakeTask GUARDED_BY(mLock);
-    std::atomic<bool> mServerStopped;
+    std::atomic<bool> mServerStopped = false;
     std::unordered_map<std::string, std::unordered_map<std::string, ScheduleInfo>>
             mInfoByScheduleIdByClientId GUARDED_BY(mLock);
 
diff --git a/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp b/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp
index d223353..eed3495 100644
--- a/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp
+++ b/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp
@@ -105,6 +105,10 @@
     });
 }
 
+bool TaskQueue::isStopped() {
+    return mStopped;
+}
+
 void TaskQueue::stopWait() {
     mStopped = true;
     {
@@ -241,7 +245,7 @@
     while (true) {
         mTaskQueue->waitForTask();
 
-        if (mServerStopped) {
+        if (mTaskQueue->isStopped()) {
             // Server stopped, exit the loop.
             printf("Server stopped exit loop\n");
             break;
@@ -250,11 +254,13 @@
         while (true) {
             auto maybeTask = mTaskQueue->maybePopOne();
             if (!maybeTask.has_value()) {
+                printf("no task left\n");
                 // No task left, loop again and wait for another task(s).
                 break;
             }
             // Loop through all the task in the queue but obtain lock for each element so we don't
             // hold lock while writing the response.
+            printf("Sending one remote task\n");
             const GetRemoteTasksResponse& response = maybeTask.value();
             if (!writer->Write(response)) {
                 // Broken stream, maybe the client is shutting down.
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));