From bd9a859d61293ca125f5ae1783f2a17676685132 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Fri, 30 Sep 2016 08:46:11 +0200 Subject: [PATCH] Enable hwcomposer support only conditionally --- src/anbox/qemu/boot_properties_message_processor.cpp | 10 ++++++---- src/anbox/utils.cpp | 4 ++++ src/anbox/utils.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/anbox/qemu/boot_properties_message_processor.cpp b/src/anbox/qemu/boot_properties_message_processor.cpp index 112c426..2c91a16 100644 --- a/src/anbox/qemu/boot_properties_message_processor.cpp +++ b/src/anbox/qemu/boot_properties_message_processor.cpp @@ -64,15 +64,17 @@ void BootPropertiesMessageProcessor::list_properties() { // Disable on-screen virtual keys as we can use the hardware keyboard "qemu.hw.mainkeys=1", - // To let surfaceflinger load our hwcomposer implementation we specify - // the correct subkey of the module here. - // "ro.hardware.hwcomposer=anbox", - // Android has builtin detection (inside Zygote) for proper container // detection support "ro.boot.container=1", }; + if (utils::is_env_set("USE_HWCOMPOSER")) { + // To let surfaceflinger load our hwcomposer implementation we specify + // the correct subkey of the module here. + properties.push_back("ro.hardware.hwcomposer=anbox"); + } + for (const auto &prop : properties) { send_header(prop.length()); messenger_->send(prop.c_str(), prop.length()); diff --git a/src/anbox/utils.cpp b/src/anbox/utils.cpp index b15d422..ba602ec 100644 --- a/src/anbox/utils.cpp +++ b/src/anbox/utils.cpp @@ -141,6 +141,10 @@ std::string get_env_value(const std::string &name, const std::string &default_va return std::string(value); } +bool is_env_set(const std::string &name) { + return getenv(name.c_str()) != nullptr; +} + void ensure_paths(const std::vector &paths) { for (const auto &path: paths) { if (!fs::is_directory(fs::path(path))) diff --git a/src/anbox/utils.h b/src/anbox/utils.h index 13a0c5c..343872f 100644 --- a/src/anbox/utils.h +++ b/src/anbox/utils.h @@ -39,6 +39,7 @@ bool string_starts_with(const std::string &text, const std::string &prefix); std::string hex_dump(const uint8_t *data, uint32_t size); std::string get_env_value(const std::string &name, const std::string &default_value = ""); +bool is_env_set(const std::string &name); void ensure_paths(const std::vector &paths);