summaryrefslogtreecommitdiff
path: root/libs/gui/BufferQueueCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/gui/BufferQueueCore.cpp')
-rw-r--r--libs/gui/BufferQueueCore.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp
index 851a396155..0f8ec7f6e5 100644
--- a/libs/gui/BufferQueueCore.cpp
+++ b/libs/gui/BufferQueueCore.cpp
@@ -22,8 +22,11 @@
#include <inttypes.h>
+#include <cutils/properties.h>
+
#include <gui/BufferItem.h>
#include <gui/BufferQueueCore.h>
+#include <gui/GraphicBufferAlloc.h>
#include <gui/IConsumerListener.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/IProducerListener.h>
@@ -75,8 +78,24 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
mGenerationNumber(0)
{
if (allocator == NULL) {
- sp<ISurfaceComposer> composer(ComposerService::getComposerService());
- mAllocator = composer->createGraphicBufferAlloc();
+
+#ifdef HAVE_NO_SURFACE_FLINGER
+ // Without a SurfaceFlinger, allocate in-process. This only makes
+ // sense in systems with static SELinux configurations and no
+ // applications (since applications need dynamic SELinux policy).
+ mAllocator = new GraphicBufferAlloc();
+#else
+ // Run time check for headless, where we also allocate in-process.
+ char value[PROPERTY_VALUE_MAX];
+ property_get("config.headless", value, "0");
+ if (atoi(value) == 1) {
+ mAllocator = new GraphicBufferAlloc();
+ } else {
+ sp<ISurfaceComposer> composer(ComposerService::getComposerService());
+ mAllocator = composer->createGraphicBufferAlloc();
+ }
+#endif // HAVE_NO_SURFACE_FLINGER
+
if (mAllocator == NULL) {
BQ_LOGE("createGraphicBufferAlloc failed");
}