From 0b54c78c1d502c58dd4a3c07613a1a71b5d4f7b9 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Thu, 16 Jul 2015 15:55:41 -0700 Subject: [PATCH 1/3] Installd: Add a swap override flag Add dalvik.vm.dex2oat-swap system property to override a default decision. Bug: 20658562 (cherry picked from commit c968c0175e967e39e72f557b5e014b9575ba4727) Change-Id: I34368c6e435d1a9ceec20a0bf1c8c6213e527f5e --- cmds/installd/commands.c | 43 +++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index c57ac99a9d52..e227581230e8 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -894,20 +894,49 @@ static int wait_child(pid_t pid) } /* - * Whether dexopt should use a swap file when compiling an APK. If kAlwaysProvideSwapFile, do this - * on all devices (dex2oat will make a more informed decision itself, anyways). Otherwise, only do - * this on a low-mem device. + * Whether dexopt should use a swap file when compiling an APK. + * + * If kAlwaysProvideSwapFile, do this on all devices (dex2oat will make a more informed decision + * itself, anyways). + * + * Otherwise, read "dalvik.vm.dex2oat-swap". If the property exists, return whether it is "true". + * + * Otherwise, return true if this is a low-mem device. + * + * Otherwise, return default value. */ -static bool kAlwaysProvideSwapFile = true; +static bool kAlwaysProvideSwapFile = false; +static bool kDefaultProvideSwapFile = true; static bool ShouldUseSwapFileForDexopt() { if (kAlwaysProvideSwapFile) { return true; } - char low_mem_buf[PROPERTY_VALUE_MAX]; - property_get("ro.config.low_ram", low_mem_buf, ""); - return (strcmp(low_mem_buf, "true") == 0); + // Check the "override" property. If it exists, return value == "true". + char dex2oat_prop_buf[PROPERTY_VALUE_MAX]; + if (property_get("dalvik.vm.dex2oat-swap", dex2oat_prop_buf, "") > 0) { + if (strcmp(dex2oat_prop_buf, "true") == 0) { + return true; + } else { + return false; + } + } + + // Shortcut for default value. This is an implementation optimization for the process sketched + // above. If the default value is true, we can avoid to check whether this is a low-mem device, + // as low-mem is never returning false. The compiler will optimize this away if it can. + if (kDefaultProvideSwapFile) { + return true; + } + + bool is_low_mem = check_boolean_property("ro.config.low_ram"); + if (is_low_mem) { + return true; + } + + // Default value must be false here. + return kDefaultProvideSwapFile; } /* From d9b370cf4d8cbc5972023bd9dde2174d9d965191 Mon Sep 17 00:00:00 2001 From: Robert Shih Date: Mon, 11 Jan 2016 11:42:48 -0800 Subject: [PATCH 2/3] IGraphicBufferConsumer: fix ATTACH_BUFFER info leak Bug: 26338113 Change-Id: I019c4df2c6adbc944122df96968ddd11a02ebe33 --- libs/gui/IGraphicBufferConsumer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gui/IGraphicBufferConsumer.cpp b/libs/gui/IGraphicBufferConsumer.cpp index f6d087d3b297..dc917a8b66fe 100644 --- a/libs/gui/IGraphicBufferConsumer.cpp +++ b/libs/gui/IGraphicBufferConsumer.cpp @@ -444,7 +444,7 @@ status_t BnGraphicBufferConsumer::onTransact( CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); sp buffer = new GraphicBuffer(); data.read(*buffer.get()); - int slot; + int slot = -1; int result = attachBuffer(&slot, buffer); reply->writeInt32(slot); reply->writeInt32(result); From b8a86fe81c0da124d04630b9b3327482fef6220a Mon Sep 17 00:00:00 2001 From: Robert Shih Date: Mon, 11 Jan 2016 15:02:12 -0800 Subject: [PATCH 3/3] IGraphicBufferProducer: fix QUEUE_BUFFER info leak Bug: 26338109 Change-Id: I8a979469bfe1e317ebdefa43685e19f9302baea8 --- libs/gui/IGraphicBufferProducer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 4f7b0d30e474..67690b70dc30 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -357,6 +357,7 @@ status_t BnGraphicBufferProducer::onTransact( QueueBufferOutput* const output = reinterpret_cast( reply->writeInplace(sizeof(QueueBufferOutput))); + memset(output, 0, sizeof(QueueBufferOutput)); status_t result = queueBuffer(buf, input, output); reply->writeInt32(result); return NO_ERROR;