As we know, device initialization is done in the open method defined in the hw_module_methods_t data structure. Let's look at the implementation of the open method in GLES emulation. It is implemented in the gralloc_device_open function, as we can see in the following snippet:
static int gralloc_device_open(const hw_module_t* module, const char* name, hw_device_t** device) { int status = -EINVAL; D("gralloc_device_open %s\n", name); pthread_once( &sFallbackOnce, fallback_init ); if (sFallback != NULL) { return sFallback->common.methods->open(&sFallback->common, name, device); } if (!strcmp(name, GRALLOC_HARDWARE_GPU0)) { // Create host connection and keep it in the TLS. // return error ...