Return error code directly in allocateHelper()

libs/ui/GraphicBufferAllocator falsely maps error != NO_ERROR to
NO_MEMORY upon allocation failure. However, from the driver
implementation point of view, we need to distinguish unsupported
v.s. oom, which is quite natural if the error code is returned
directly.

Bug: b/189221081
Test: Presubmit
Change-Id: I75ce2d0d4c723c0d58ba8c27b9b68404be424ac8
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 91d2d58..3f958ba 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -128,8 +128,9 @@
     }
 
     // Ensure that layerCount is valid.
-    if (layerCount < 1)
+    if (layerCount < 1) {
         layerCount = 1;
+    }
 
     // TODO(b/72323293, b/72703005): Remove these invalid bits from callers
     usage &= ~static_cast<uint64_t>((1 << 10) | (1 << 13));
@@ -140,7 +141,7 @@
         ALOGE("Failed to allocate (%u x %u) layerCount %u format %d "
               "usage %" PRIx64 ": %d",
               width, height, layerCount, format, usage, error);
-        return NO_MEMORY;
+        return error;
     }
 
     if (!importBuffer) {