libui: support GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE

Honor GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE in
GraphicBufferMapper and advertise the cap in the adapter.

Bug: 36355756
Test: boots on gralloc0 and gralloc1 devices
Change-Id: I54a4855883904255fba9a0821ff9d866d265d25a
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index 2f4d5fb..87519bf 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -122,8 +122,10 @@
         error = GRALLOC1_ERROR_NONE;
     } else {
         error = mDevice->release(handle);
-        native_handle_close(handle);
-        native_handle_delete(const_cast<native_handle_t*>(handle));
+        if (!mDevice->hasCapability(GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE)) {
+            native_handle_close(handle);
+            native_handle_delete(const_cast<native_handle_t*>(handle));
+        }
     }
 
     ALOGW_IF(error != GRALLOC1_ERROR_NONE, "freeBuffer(%p): failed %d",