summaryrefslogtreecommitdiff
path: root/libs/nativewindow/AHardwareBuffer.cpp
diff options
context:
space:
mode:
author Yiwei Zhang <zzyiwei@google.com> 2020-08-11 16:12:50 -0700
committer Yiwei Zhang <zzyiwei@google.com> 2020-11-16 23:36:28 +0000
commitead3d6eef3238f95a795603d9490e18492f3b37b (patch)
tree695951ab41f94d87689428ac6299c8b8258eabe6 /libs/nativewindow/AHardwareBuffer.cpp
parent9058b8fe8c00609768a828e3e1476d7f24754fed (diff)
AHB: add AHardwareBuffer_getId API in ndk
Add this api to ndk so that there's a reliable system-wide unique id for caching. libui is not linkable from sphal so vendors cannot convert an AHB into GraphicBuffer to call getId(). This change solves the problem. This change has been forced to refactor the existing docs and annotations due to -Wnullability-completeness. Bug: 162425097 Bug: 163615119 Test: atest libnativewindow_test:AHardwareBufferTest#GetIdTest Change-Id: I91043b96b83bc9a896c361385581e9620fe373c3
Diffstat (limited to 'libs/nativewindow/AHardwareBuffer.cpp')
-rw-r--r--libs/nativewindow/AHardwareBuffer.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp
index 1ec73ce961..a375d43a43 100644
--- a/libs/nativewindow/AHardwareBuffer.cpp
+++ b/libs/nativewindow/AHardwareBuffer.cpp
@@ -397,6 +397,16 @@ int AHardwareBuffer_isSupported(const AHardwareBuffer_Desc* desc) {
return 0;
}
+int AHardwareBuffer_getId(const AHardwareBuffer* buffer, uint64_t* outId) {
+ if (!buffer || !outId) return BAD_VALUE;
+
+ const GraphicBuffer* gb = AHardwareBuffer_to_GraphicBuffer(buffer);
+ if (!gb) return BAD_VALUE;
+
+ *outId = gb->getId();
+
+ return OK;
+}
// ----------------------------------------------------------------------------
// VNDK functions