diff options
author | Andreas Gampe <agampe@google.com> | 2015-07-17 01:03:24 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-17 01:03:24 +0000 |
commit | a0abdab2fe67032d5edc850f6e69041fb2caf153 (patch) | |
tree | 40479be15a0882f87e9152400c33e79a831df3e3 | |
parent | 31e138db15b2460a0bb34d78f5b01d66cc8428f1 (diff) | |
parent | c968c0175e967e39e72f557b5e014b9575ba4727 (diff) | |
download | frameworks_native-a0abdab2fe67032d5edc850f6e69041fb2caf153.zip frameworks_native-a0abdab2fe67032d5edc850f6e69041fb2caf153.tar.gz frameworks_native-a0abdab2fe67032d5edc850f6e69041fb2caf153.tar.bz2 |
am c968c017: Installd: Add a swap override flag
* commit 'c968c0175e967e39e72f557b5e014b9575ba4727':
Installd: Add a swap override flag
-rw-r--r-- | cmds/installd/commands.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index 0c3ae02..880877c 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -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 - * 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; } /* |