From fb065fe01a7813e6356e0dbd4b54d102d3536072 Mon Sep 17 00:00:00 2001
From: Yahan Zhou <yahan@google.com>
Date: Wed, 22 May 2019 12:42:50 -0700
Subject: [PATCH] Fix eglQueryString

BUG: 131917822
Test: cts-tradefed run cts -m CtsDeqpTestCases -t dEQP-EGL.functional.choose_config.simple*
Change-Id: Idc82f469c606009eb0ace6f33ad9524b4a70877d
---
 system/egl/egl.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
 
 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);
 }
-- 
GitLab