Fix eglQueryString

BUG: 131917822
Test: cts-tradefed run cts -m CtsDeqpTestCases -t dEQP-EGL.functional.choose_config.simple*
Change-Id: Idc82f469c606009eb0ace6f33ad9524b4a70877d
diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp
index b0b510b..60d17e5 100644
--- a/system/egl/egl.cpp
+++ b/system/egl/egl.cpp
@@ -920,7 +920,11 @@
 
 const char* eglQueryString(EGLDisplay dpy, EGLint name)
 {
-    VALIDATE_DISPLAY_INIT(dpy, NULL);
+    // EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is
+    // EGL_NO_DISPLAY and name is EGL_EXTENSIONS.
+    if (dpy || name != EGL_EXTENSIONS) {
+        VALIDATE_DISPLAY_INIT(dpy, NULL);
+    }
 
     return s_display.queryString(name);
 }