* commit 'f82926fc02a6fecb28b1a6fd759035177064de5b': Installd: Add a swap override flag
This commit is contained in:
commit
7d8852f8a1
@ -984,20 +984,49 @@ static int wait_child(pid_t pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Whether dexopt should use a swap file when compiling an APK. If kAlwaysProvideSwapFile, do this
|
* Whether dexopt should use a swap file when compiling an APK.
|
||||||
* on all devices (dex2oat will make a more informed decision itself, anyways). Otherwise, only do
|
*
|
||||||
* this on a low-mem device.
|
* 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() {
|
static bool ShouldUseSwapFileForDexopt() {
|
||||||
if (kAlwaysProvideSwapFile) {
|
if (kAlwaysProvideSwapFile) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char low_mem_buf[PROPERTY_VALUE_MAX];
|
// Check the "override" property. If it exists, return value == "true".
|
||||||
property_get("ro.config.low_ram", low_mem_buf, "");
|
char dex2oat_prop_buf[PROPERTY_VALUE_MAX];
|
||||||
return (strcmp(low_mem_buf, "true") == 0);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user