Only test data injection for vec3 sensors

Injecting vec3 data to scalar sensor type could break sensor HAL.

Bug: 400115679
Test: atest VtsAidlHalSensorsTargetTest
Change-Id: I0eb59564ec74658e9ca6b0034f2a838625e88acd
diff --git a/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp b/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp
index b1590f9..77e2916 100644
--- a/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp
+++ b/sensors/aidl/vts/VtsAidlHalSensorsTargetTest.cpp
@@ -616,8 +616,18 @@
 }
 
 TEST_P(SensorsAidlTest, InjectSensorEventData) {
-    std::vector<SensorInfo> sensors = getInjectEventSensors();
-    if (sensors.size() == 0) {
+    std::vector<SensorInfo> sensorsAll = getInjectEventSensors();
+    std::vector<SensorInfo> sensors3d;
+
+    for (const auto& s : sensorsAll) {
+        if ((s.type == SensorType::ACCELEROMETER) || (s.type == SensorType::GYROSCOPE) ||
+            (s.type == SensorType::MAGNETIC_FIELD)) {
+            sensors3d.push_back(s);
+        }
+    }
+
+    // Here we only test for the sensors with vec3 data type
+    if (sensors3d.size() == 0) {
         return;
     }
 
@@ -645,7 +655,7 @@
     Event::EventPayload::Vec3 data = {1, 2, 3, SensorStatus::ACCURACY_HIGH};
     injectedEvent.payload.set<Event::EventPayload::Tag::vec3>(data);
 
-    for (const auto& s : sensors) {
+    for (const auto& s : sensors3d) {
         additionalInfoEvent.sensorHandle = s.sensorHandle;
         ASSERT_TRUE(getSensors()->injectSensorData(additionalInfoEvent).isOk());
 
@@ -655,10 +665,10 @@
     }
 
     // Wait for events to be written back to the Event FMQ
-    callback.waitForEvents(sensors, std::chrono::milliseconds(1000) /* timeout */);
+    callback.waitForEvents(sensors3d, std::chrono::milliseconds(1000) /* timeout */);
     getEnvironment()->unregisterCallback();
 
-    for (const auto& s : sensors) {
+    for (const auto& s : sensors3d) {
         auto events = callback.getEvents(s.sensorHandle);
         if (events.empty()) {
             FAIL() << "Received no events";