From aa17ab41eb13d24f0f17ce07cdda1f141a82f037 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 15 Aug 2017 14:51:05 +0100 Subject: Unconditionally unlink image. In case there is a stale one. Useful when doing: adb shell cmd package compile --reset ... bug: 64708178 Test: adb shell cmd package compile removes the app image (cherry picked from commit 775cdd9b94ad0094944fa8df64a52a5e43440a68) Change-Id: Ic85eeecedd7dd762e01e943a74349b7da6063d6d --- cmds/installd/dexopt.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp index d78431542c..487f6b39ef 100644 --- a/cmds/installd/dexopt.cpp +++ b/cmds/installd/dexopt.cpp @@ -1067,10 +1067,9 @@ class Dex2oatFileWrapper { // (re)Creates the app image if needed. Dex2oatFileWrapper maybe_open_app_image(const char* out_oat_path, bool profile_guided, bool is_public, int uid, bool is_secondary_dex) { - // Use app images only if it is enabled (by a set image format) and we are compiling - // profile-guided (so the app image doesn't conservatively contain all classes). - // Note that we don't create an image for secondary dex files. - if (is_secondary_dex || !profile_guided) { + + // We don't create an image for secondary dex files. + if (is_secondary_dex) { return Dex2oatFileWrapper(); } @@ -1079,6 +1078,14 @@ Dex2oatFileWrapper maybe_open_app_image(const char* out_oat_path, bool profile_g // Happens when the out_oat_path has an unknown extension. return Dex2oatFileWrapper(); } + + // Use app images only if it is enabled (by a set image format) and we are compiling + // profile-guided (so the app image doesn't conservatively contain all classes). + if (!profile_guided) { + // In case there is a stale image, remove it now. Ignore any error. + unlink(image_path.c_str()); + return Dex2oatFileWrapper(); + } char app_image_format[kPropertyValueMax]; bool have_app_image_format = get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0; -- cgit v1.2.3-59-g8ed1b