libui: Allow extension of valid gralloc 1.0 buffer usage bits

* Change I7f4174581e24e361577640b9263514a168ed482d implemented
  validation of the buffer description info prior to creating
  the descriptor. Some of our legacy devices need to whitelist
  additional usage bits to support various functionality.

libui: Extend adb95ae to Gralloc3
libui: Extend adb95ae to Gralloc4

This commit squashes:
  libui: Convert lineage product variables to soong config variables
  Change-Id: Ib687c966d4eafcc1128611b95ebed00fd0a8bfaf

Change-Id: Ie369e78f78e9ac0b18ab3dfea520d4f123005d92
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index 12230f9..4664d04 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -153,6 +153,7 @@
         "android.hardware.graphics.allocator-ndk_shared",
         "android.hardware.graphics.common-ndk_shared",
         "libui-defaults",
+        "gralloc_10_usage_bits_defaults",
         // Uncomment the following line to enable VALIDATE_REGIONS traces
         //defaults: ["libui-validate-regions-defaults"],
     ],
diff --git a/libs/ui/Gralloc2.cpp b/libs/ui/Gralloc2.cpp
index a5aca99..ed6984d 100644
--- a/libs/ui/Gralloc2.cpp
+++ b/libs/ui/Gralloc2.cpp
@@ -48,6 +48,13 @@
         for (const auto bit : hardware::hidl_enum_range<BufferUsage>()) {
             bits = bits | bit;
         }
+
+#ifdef ADDNL_GRALLOC_10_USAGE_BITS
+        uint64_t addnl_bits = static_cast<uint64_t>(ADDNL_GRALLOC_10_USAGE_BITS);
+        ALOGI("Adding additional valid usage bits: 0x%" PRIx64, addnl_bits);
+        bits = bits | addnl_bits;
+#endif
+
         return bits;
     }();
     return valid10UsageBits;
diff --git a/libs/ui/Gralloc3.cpp b/libs/ui/Gralloc3.cpp
index 152b35a..27d0c60 100644
--- a/libs/ui/Gralloc3.cpp
+++ b/libs/ui/Gralloc3.cpp
@@ -47,6 +47,13 @@
              hardware::hidl_enum_range<hardware::graphics::common::V1_2::BufferUsage>()) {
             bits = bits | bit;
         }
+
+#ifdef ADDNL_GRALLOC_10_USAGE_BITS
+        uint64_t addnl_bits = static_cast<uint64_t>(ADDNL_GRALLOC_10_USAGE_BITS);
+        ALOGI("Adding additional valid usage bits: 0x%" PRIx64, addnl_bits);
+        bits = bits | addnl_bits;
+#endif
+
         return bits;
     }();
     return validUsageBits;
diff --git a/libs/ui/Gralloc4.cpp b/libs/ui/Gralloc4.cpp
index 2a60730..7289ab5 100644
--- a/libs/ui/Gralloc4.cpp
+++ b/libs/ui/Gralloc4.cpp
@@ -75,6 +75,13 @@
              hardware::hidl_enum_range<hardware::graphics::common::V1_2::BufferUsage>()) {
             bits = bits | bit;
         }
+
+#ifdef ADDNL_GRALLOC_10_USAGE_BITS
+        uint64_t addnl_bits = static_cast<uint64_t>(ADDNL_GRALLOC_10_USAGE_BITS);
+        ALOGI("Adding additional valid usage bits: 0x%" PRIx64, addnl_bits);
+        bits = bits | addnl_bits;
+#endif
+
         return bits;
     }();
     return validUsageBits | kRemovedUsageBits;
diff --git a/libs/ui/Gralloc5.cpp b/libs/ui/Gralloc5.cpp
index f14a5cf..f5bf7f6 100644
--- a/libs/ui/Gralloc5.cpp
+++ b/libs/ui/Gralloc5.cpp
@@ -191,6 +191,13 @@
         for (const auto bit : ndk::enum_range<BufferUsage>{}) {
             bits |= static_cast<int64_t>(bit);
         }
+
+        #ifdef ADDNL_GRALLOC_10_USAGE_BITS
+            uint64_t addnl_bits = static_cast<uint64_t>(ADDNL_GRALLOC_10_USAGE_BITS);
+            ALOGI("Adding additional valid usage bits: 0x%" PRIx64, addnl_bits);
+            bits = bits | addnl_bits;
+        #endif
+
         return bits;
     }();
     return validUsageBits | kRemovedUsageBits;