Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions cmds/installd/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion libs/gui/IGraphicBufferConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ status_t BnGraphicBufferConsumer::onTransact(
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
sp<GraphicBuffer> buffer = new GraphicBuffer();
data.read(*buffer.get());
int slot;
int slot = -1;
int result = attachBuffer(&slot, buffer);
reply->writeInt32(slot);
reply->writeInt32(result);
Expand Down
1 change: 1 addition & 0 deletions libs/gui/IGraphicBufferProducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ status_t BnGraphicBufferProducer::onTransact(
QueueBufferOutput* const output =
reinterpret_cast<QueueBufferOutput *>(
reply->writeInplace(sizeof(QueueBufferOutput)));
memset(output, 0, sizeof(QueueBufferOutput));
status_t result = queueBuffer(buf, input, output);
reply->writeInt32(result);
return NO_ERROR;
Expand Down