drm_hwcomposer: Check if the display is valid in setAutoLowLatencyMode

It's checked by the GraphicsComposerAidlTest#SetAutoLowLatencyMode_BadDisplay
VTS test.

Fixes: f74b7318b375 ("drm_hwcomposer: Move trivial frontend functions out of HwcDisplay class")
Change-Id: Ie0ffb4f0f94ab1ea629041930c672bb7e4958ba2
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index ca89706..50d8ce6 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -1283,9 +1283,15 @@
   return ToBinderStatus(hwc3::Error::kUnsupported);
 }
 
-ndk::ScopedAStatus ComposerClient::setAutoLowLatencyMode(int64_t /*display_id*/,
+ndk::ScopedAStatus ComposerClient::setAutoLowLatencyMode(int64_t display_id,
                                                          bool /*on*/) {
   DEBUG_FUNC();
+  const std::unique_lock lock(hwc_->GetResMan().GetMainLock());
+  HwcDisplay* display = GetDisplay(display_id);
+  if (display == nullptr) {
+    return ToBinderStatus(hwc3::Error::kBadDisplay);
+  }
+
   return ToBinderStatus(hwc3::Error::kUnsupported);
 }