Merge "Return jobject when getting android Java Surface" into oc-dev
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index f898b90..cba8f36 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -112,6 +112,7 @@
// Must be hardcoded because dumpstate HAL implementation need SELinux access to it
static const std::string kDumpstateBoardPath = "/bugreports/dumpstate_board.txt";
+static const std::string kLsHalDebugPath = "/bugreports/dumpstate_lshal.txt";
static constexpr char PROPERTY_EXTRA_OPTIONS[] = "dumpstate.options";
static constexpr char PROPERTY_LAST_ID[] = "dumpstate.last_id";
@@ -962,7 +963,19 @@
{"ps", "-A", "-T", "-Z", "-O", "pri,nice,rtprio,sched,pcy"});
RunCommand("LIBRANK", {"librank"}, CommandOptions::AS_ROOT);
- RunCommand("HARDWARE HALS", {"lshal"}, CommandOptions::AS_ROOT);
+ if (ds.IsZipping()) {
+ RunCommand(
+ "HARDWARE HALS",
+ {"lshal", std::string("--debug=") + kLsHalDebugPath},
+ CommandOptions::AS_ROOT);
+
+ ds.AddZipEntry("lshal-debug.txt", kLsHalDebugPath);
+
+ unlink(kLsHalDebugPath.c_str());
+ } else {
+ RunCommand(
+ "HARDWARE HALS", {"lshal", "--debug"}, CommandOptions::AS_ROOT);
+ }
RunCommand("PRINTENV", {"printenv"});
RunCommand("NETSTAT", {"netstat", "-nW"});
@@ -980,8 +993,13 @@
for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)");
- /* Dump Bluetooth HCI logs */
- ds.AddDir("/data/misc/bluetooth/logs", true);
+ if (true) {
+ // TODO: temporary disabled because /data/misc/bluetooth/logs/btsnoop_hci.log can be huge
+ MYLOGD("Skipping /data/misc/bluetooth/logs");
+ } else {
+ /* Dump Bluetooth HCI logs */
+ ds.AddDir("/data/misc/bluetooth/logs", true);
+ }
if (!ds.do_early_screenshot_) {
MYLOGI("taking late screenshot\n");
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) {
diff --git a/libs/nativewindow/Android.bp b/libs/nativewindow/Android.bp
index 2668927..90fb4b6 100644
--- a/libs/nativewindow/Android.bp
+++ b/libs/nativewindow/Android.bp
@@ -53,6 +53,7 @@
static_libs: [
"libarect",
+ "libgrallocusage",
],
// headers we include in our public headers
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index d1bfa18..80fb064 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -78,6 +78,7 @@
static_libs: [
"libarect",
+ "libgrallocusage",
"libmath",
],
diff --git a/libs/ui/Gralloc1On0Adapter.cpp b/libs/ui/Gralloc1On0Adapter.cpp
index b8bc6c4..bd7c6a1 100644
--- a/libs/ui/Gralloc1On0Adapter.cpp
+++ b/libs/ui/Gralloc1On0Adapter.cpp
@@ -20,6 +20,7 @@
#include <ui/Gralloc1On0Adapter.h>
+#include <grallocusage/GrallocUsageConversion.h>
#include <hardware/gralloc.h>
@@ -248,8 +249,8 @@
// pointer, which only occurs when mDevice has been loaded successfully and
// we are permitted to allocate
- int usage = static_cast<int>(descriptor->producerUsage) |
- static_cast<int>(descriptor->consumerUsage);
+ int usage = android_convertGralloc1To0Usage(descriptor->producerUsage,
+ descriptor->consumerUsage);
buffer_handle_t handle = nullptr;
int stride = 0;
ALOGV("Calling alloc(%p, %u, %u, %i, %u)", mDevice, descriptor->width,
@@ -374,7 +375,7 @@
{
if (mMinorVersion >= 3) {
int result = mModule->lockAsync(mModule, buffer->getHandle(),
- static_cast<int32_t>(producerUsage | consumerUsage),
+ android_convertGralloc1To0Usage(producerUsage, consumerUsage),
accessRegion.left, accessRegion.top, accessRegion.width,
accessRegion.height, outData, acquireFence->dup());
if (result != 0) {
@@ -383,7 +384,7 @@
} else {
acquireFence->waitForever("Gralloc1On0Adapter::lock");
int result = mModule->lock(mModule, buffer->getHandle(),
- static_cast<int32_t>(producerUsage | consumerUsage),
+ android_convertGralloc1To0Usage(producerUsage, consumerUsage),
accessRegion.left, accessRegion.top, accessRegion.width,
accessRegion.height, outData);
ALOGV("gralloc0 lock returned %d", result);
@@ -415,7 +416,7 @@
{
if (mMinorVersion >= 3 && mModule->lockAsync_ycbcr) {
int result = mModule->lockAsync_ycbcr(mModule, buffer->getHandle(),
- static_cast<int>(producerUsage | consumerUsage),
+ android_convertGralloc1To0Usage(producerUsage, consumerUsage),
accessRegion.left, accessRegion.top, accessRegion.width,
accessRegion.height, outData, acquireFence->dup());
if (result != 0) {
@@ -424,7 +425,7 @@
} else if (mModule->lock_ycbcr) {
acquireFence->waitForever("Gralloc1On0Adapter::lockYCbCr");
int result = mModule->lock_ycbcr(mModule, buffer->getHandle(),
- static_cast<int>(producerUsage | consumerUsage),
+ android_convertGralloc1To0Usage(producerUsage, consumerUsage),
accessRegion.left, accessRegion.top, accessRegion.width,
accessRegion.height, outData);
ALOGV("gralloc0 lockYCbCr returned %d", result);
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 9006178..6e84730 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -16,12 +16,12 @@
#define LOG_TAG "GraphicBuffer"
-#include <cutils/atomic.h>
-
#include <ui/GraphicBuffer.h>
#include <cutils/atomic.h>
+#include <grallocusage/GrallocUsageConversion.h>
+
#include <ui/GrallocMapper.h>
#include <ui/GraphicBufferAllocator.h>
#include <ui/GraphicBufferMapper.h>
@@ -114,7 +114,7 @@
stride = static_cast<int>(inStride);
format = inFormat;
layerCount = inLayerCount;
- usage = static_cast<int>(inConsumerUsage | inProducerUsage);
+ usage = android_convertGralloc1To0Usage(inProducerUsage, inConsumerUsage);
handle = inHandle;
}
@@ -221,7 +221,7 @@
height = static_cast<int>(inHeight);
format = inFormat;
layerCount = inLayerCount;
- usage = static_cast<int>(inProducerUsage | inConsumerUsage);
+ usage = android_convertGralloc1To0Usage(inProducerUsage, inConsumerUsage);
stride = static_cast<int>(outStride);
}
return err;
diff --git a/vulkan/libvulkan/Android.bp b/vulkan/libvulkan/Android.bp
index 2fe880a..9444da5 100644
--- a/vulkan/libvulkan/Android.bp
+++ b/vulkan/libvulkan/Android.bp
@@ -79,4 +79,5 @@
"libcutils",
"libz",
],
+ static_libs: ["libgrallocusage"],
}
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index dbb217d..5fbf5f5 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -34,6 +34,9 @@
#include "driver.h"
#include "stubhal.h"
+// Set to true to enable exposing unratified extensions for development
+static const bool kEnableUnratifiedExtensions = false;
+
// #define ENABLE_ALLOC_CALLSTACKS 1
#if ENABLE_ALLOC_CALLSTACKS
#include <utils/CallStack.h>
@@ -675,16 +678,24 @@
const char* pLayerName,
uint32_t* pPropertyCount,
VkExtensionProperties* pProperties) {
- static const std::array<VkExtensionProperties, 4> loader_extensions = {{
- // WSI extensions
- {VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION},
- {VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
- VK_KHR_ANDROID_SURFACE_SPEC_VERSION},
- {VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME,
- VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION},
- {VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME,
- VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION},
- }};
+
+ android::Vector<VkExtensionProperties> loader_extensions;
+ loader_extensions.push_back({
+ VK_KHR_SURFACE_EXTENSION_NAME,
+ VK_KHR_SURFACE_SPEC_VERSION});
+ loader_extensions.push_back({
+ VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
+ VK_KHR_ANDROID_SURFACE_SPEC_VERSION});
+ loader_extensions.push_back({
+ VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME,
+ VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION});
+
+ if (kEnableUnratifiedExtensions) {
+ loader_extensions.push_back({
+ VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME,
+ VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION});
+ }
+
static const VkExtensionProperties loader_debug_report_extension = {
VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION,
};
@@ -782,13 +793,15 @@
VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME,
VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION});
- // conditionally add shared_presentable_image if supportable
- VkPhysicalDevicePresentationPropertiesANDROID presentation_properties;
- if (QueryPresentationProperties(physicalDevice, &presentation_properties) &&
- presentation_properties.sharedImage) {
- loader_extensions.push_back({
- VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME,
- VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION});
+ if (kEnableUnratifiedExtensions) {
+ // conditionally add shared_presentable_image if supportable
+ VkPhysicalDevicePresentationPropertiesANDROID presentation_properties;
+ if (QueryPresentationProperties(physicalDevice, &presentation_properties) &&
+ presentation_properties.sharedImage) {
+ loader_extensions.push_back({
+ VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME,
+ VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION});
+ }
}
// enumerate our extensions first
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 5017e14..5574da2 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -16,6 +16,7 @@
#include <algorithm>
+#include <grallocusage/GrallocUsageConversion.h>
#include <log/log.h>
#include <ui/BufferQueueDefs.h>
#include <sync/sync.h>
@@ -995,11 +996,8 @@
ALOGE("vkGetSwapchainGrallocUsage2ANDROID failed: %d", result);
return VK_ERROR_SURFACE_LOST_KHR;
}
- // TODO: This is the same translation done by Gralloc1On0Adapter.
- // Remove it once ANativeWindow has been updated to take gralloc1-style
- // usages.
gralloc_usage =
- static_cast<int>(consumer_usage) | static_cast<int>(producer_usage);
+ android_convertGralloc1To0Usage(producer_usage, consumer_usage);
} else if (dispatch.GetSwapchainGrallocUsageANDROID) {
result = dispatch.GetSwapchainGrallocUsageANDROID(
device, create_info->imageFormat, create_info->imageUsage,