diff options
| author | 2017-05-26 16:32:55 -0700 | |
|---|---|---|
| committer | 2017-06-01 13:10:05 -0700 | |
| commit | 3291cd9eaab89538dac3af66a5f099da7d320c86 (patch) | |
| tree | e78ca0db71910be54f2c81255ed1453ee88d2a7f | |
| parent | c523409f0fd03aa498cedc486f85e9a4b7257f3a (diff) | |
Disable in-place vdex update
Vdex files can be corrupted by dexlayout or by previously dexlayout-ed
files being recompiled if they are used as both input and output.
Disable this feature.
Bug: 38113240
Test: OTA and dexopt
Change-Id: Iee2d9a6c1ba8cddda25290f68f50649d5288d588
(cherry picked from commit e446fede9258359b61d4c8753d7e96477fa29388)
| -rw-r--r-- | cmds/installd/dexopt.cpp | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp index fea7b0dcf8..296b87de87 100644 --- a/cmds/installd/dexopt.cpp +++ b/cmds/installd/dexopt.cpp @@ -1182,13 +1182,7 @@ bool open_vdex_files(const char* apk_path, const char* out_oat_path, int dexopt_ ALOGE("installd cannot compute input vdex location for '%s'\n", path); return false; } - if (dexopt_action == DEX2OAT_FOR_BOOT_IMAGE) { - // When we dex2oat because of boot image change, we are going to update - // in-place the vdex file. - in_vdex_wrapper_fd->reset(open(in_vdex_path_str.c_str(), O_RDWR, 0)); - } else { - in_vdex_wrapper_fd->reset(open(in_vdex_path_str.c_str(), O_RDONLY, 0)); - } + in_vdex_wrapper_fd->reset(open(in_vdex_path_str.c_str(), O_RDONLY, 0)); } // Infer the name of the output VDEX and create it. @@ -1197,27 +1191,12 @@ bool open_vdex_files(const char* apk_path, const char* out_oat_path, int dexopt_ return false; } - // If we are compiling because the boot image is out of date, we do not - // need to recreate a vdex, and can use the same existing one. - if (dexopt_action == DEX2OAT_FOR_BOOT_IMAGE && - in_vdex_wrapper_fd->get() != -1 && - in_vdex_path_str == out_vdex_path_str) { - // We unlink the file in case the invocation of dex2oat fails, to ensure we don't - // have bogus stale vdex files. - out_vdex_wrapper_fd->reset( - in_vdex_wrapper_fd->get(), - [out_vdex_path_str]() { unlink(out_vdex_path_str.c_str()); }); - // Disable auto close for the in wrapper fd (it will be done when destructing the out - // wrapper). - in_vdex_wrapper_fd->DisableAutoClose(); - } else { - out_vdex_wrapper_fd->reset( - open_output_file(out_vdex_path_str.c_str(), /*recreate*/true, /*permissions*/0644), - [out_vdex_path_str]() { unlink(out_vdex_path_str.c_str()); }); - if (out_vdex_wrapper_fd->get() < 0) { - ALOGE("installd cannot open vdex'%s' during dexopt\n", out_vdex_path_str.c_str()); - return false; - } + out_vdex_wrapper_fd->reset( + open_output_file(out_vdex_path_str.c_str(), /*recreate*/true, /*permissions*/0644), + [out_vdex_path_str]() { unlink(out_vdex_path_str.c_str()); }); + if (out_vdex_wrapper_fd->get() < 0) { + ALOGE("installd cannot open vdex'%s' during dexopt\n", out_vdex_path_str.c_str()); + return false; } if (!set_permissions_and_ownership(out_vdex_wrapper_fd->get(), is_public, uid, out_vdex_path_str.c_str(), is_secondary_dex)) { |