Return a copy of InputDeviceLightInfo instead of pointer

Refactor InputReaderInterface to return a copy instead of pointer. This
will ensure that we don't read from memory that's been freed.

Also, refactor InputDevice api's to return a list of infos instead of
having to query each individually. In all usages so far, there's no need
to get a specific info by type.

Bug: 190126442
Test: atest inputflinger_tests libinput_tests
Change-Id: I7f993a14259bb802e2631663c1c8bb65cc9b6702
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 61d72ad..30c42a3 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -247,36 +247,22 @@
     mLights.insert_or_assign(info.id, info);
 }
 
-const std::vector<InputDeviceSensorType> InputDeviceInfo::getSensorTypes() {
-    std::vector<InputDeviceSensorType> types;
+std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() {
+    std::vector<InputDeviceSensorInfo> infos;
+    infos.reserve(mSensors.size());
     for (const auto& [type, info] : mSensors) {
-        types.push_back(type);
+        infos.push_back(info);
     }
-    return types;
+    return infos;
 }
 
-const InputDeviceSensorInfo* InputDeviceInfo::getSensorInfo(InputDeviceSensorType type) {
-    auto it = mSensors.find(type);
-    if (it == mSensors.end()) {
-        return nullptr;
-    }
-    return &it->second;
-}
-
-const std::vector<int32_t> InputDeviceInfo::getLightIds() {
-    std::vector<int32_t> ids;
+std::vector<InputDeviceLightInfo> InputDeviceInfo::getLights() {
+    std::vector<InputDeviceLightInfo> infos;
+    infos.reserve(mLights.size());
     for (const auto& [id, info] : mLights) {
-        ids.push_back(id);
+        infos.push_back(info);
     }
-    return ids;
-}
-
-const InputDeviceLightInfo* InputDeviceInfo::getLightInfo(int32_t id) {
-    auto it = mLights.find(id);
-    if (it == mLights.end()) {
-        return nullptr;
-    }
-    return &it->second;
+    return infos;
 }
 
 } // namespace android