Use gralloc usage conversion library

Converting from ..graphics.allocator@2.0 usage to gralloc0 usage isn't
quite as simple as ORing and truncating, which is what the default
implementation was doing. Switch to using library functions that do it
correctly.

Test: boot bullhead
Change-Id: Ibe644b53655e191b9bca9d619825a8918e8fc365
diff --git a/libs/nativewindow/ANativeWindow.cpp b/libs/nativewindow/ANativeWindow.cpp
index a956122..c0c4ac0 100644
--- a/libs/nativewindow/ANativeWindow.cpp
+++ b/libs/nativewindow/ANativeWindow.cpp
@@ -18,6 +18,7 @@
 
 #include <android/native_window.h>
 
+#include <grallocusage/GrallocUsageConversion.h>
 // from nativewindow/includes/system/window.h
 // (not to be confused with the compatibility-only window.h from system/core/includes)
 #include <system/window.h>
@@ -187,8 +188,7 @@
 int ANativeWindow_setUsage(ANativeWindow* window, uint64_t usage0, uint64_t usage1) {
     uint64_t pUsage, cUsage;
     AHardwareBuffer_convertToGrallocUsageBits(&pUsage, &cUsage, usage0, usage1);
-    uint32_t gralloc_usage = uint32_t(pUsage | cUsage);
-    return native_window_set_usage(window, gralloc_usage);
+    return native_window_set_usage(window, android_convertGralloc1To0Usage(pUsage, cUsage));
 }
 
 int ANativeWindow_setBufferCount(ANativeWindow* window, size_t bufferCount) {