EGL doesn't have access to the display itself. It gets a window from the Window Manager, which is then composited by SurfaceFlinger with other things. The architecture is described here.
If you don't mind using non-public APIs, and you're running as "shell" or "root" (which, as an ADB command, you will), you can do what some of the test code does and query the display properties from SurfaceFlinger directly. Take a look at WindowSurface. (You can find the classic "San Angeles" demo nearby if you want to see the code in action.) WindowSurface was added in Android 5.0 "Lollipop", replacing an older implementation that tried to bypass SurfaceFlinger (which required shutting down the Android framework). The new implementation just draws on top of whatever is running.
The screenrecord
tool uses the same SurfaceComposerClient APIs to determine how to size the video (see line 540). If all you want is the resolution and don't actually care about EGL, this is a simpler example.