gralloc: add IAllocator/IMapper 4.0 to frameworks/native

Add support for gralloc 4.0 to the framework.

Bug: 136016160
Test: Compiles and boots

Change-Id: I26408e984308fa557e102efabb60302907310308
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index 25b7247..4d087d1 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -35,6 +35,7 @@
 #include <ui/Gralloc.h>
 #include <ui/Gralloc2.h>
 #include <ui/Gralloc3.h>
+#include <ui/Gralloc4.h>
 #include <ui/GraphicBuffer.h>
 
 #include <system/graphics.h>
@@ -47,20 +48,27 @@
 void GraphicBufferMapper::preloadHal() {
     Gralloc2Mapper::preload();
     Gralloc3Mapper::preload();
+    Gralloc4Mapper::preload();
 }
 
 GraphicBufferMapper::GraphicBufferMapper() {
+    mMapper = std::make_unique<const Gralloc4Mapper>();
+    if (mMapper->isLoaded()) {
+        mMapperVersion = Version::GRALLOC_4;
+        return;
+    }
     mMapper = std::make_unique<const Gralloc3Mapper>();
-    if (!mMapper->isLoaded()) {
-        mMapper = std::make_unique<const Gralloc2Mapper>();
-        mMapperVersion = Version::GRALLOC_2;
-    } else {
+    if (mMapper->isLoaded()) {
         mMapperVersion = Version::GRALLOC_3;
+        return;
+    }
+    mMapper = std::make_unique<const Gralloc2Mapper>();
+    if (mMapper->isLoaded()) {
+        mMapperVersion = Version::GRALLOC_2;
+        return;
     }
 
-    if (!mMapper->isLoaded()) {
-        LOG_ALWAYS_FATAL("gralloc-mapper is missing");
-    }
+    LOG_ALWAYS_FATAL("gralloc-mapper is missing");
 }
 
 status_t GraphicBufferMapper::importBuffer(buffer_handle_t rawHandle,