Loading cmds/installd/commands.cpp +37 −22 Original line number Diff line number Diff line Loading @@ -669,7 +669,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int image_fd, const char* input_ char app_image_format[kPropertyValueMax]; char image_format_arg[strlen("--image-format=") + kPropertyValueMax]; bool have_app_image_format = get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0; image_fd >= 0 && get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0; if (have_app_image_format) { sprintf(image_format_arg, "--image-format=%s", app_image_format); } Loading Loading @@ -995,9 +995,15 @@ static void trim_extension(char* path) { } } static int open_with_extension(char* file_name, const char* extension, bool recreate) { if (strlen(file_name) + strlen(extension) + 1 <= PKG_PATH_MAX) { static bool add_extension_to_file_name(char* file_name, const char* extension) { if (strlen(file_name) + strlen(extension) + 1 > PKG_PATH_MAX) { return false; } strcat(file_name, extension); return true; } static int open_output_file(char* file_name, bool recreate) { int flags = O_RDWR | O_CREAT; if (recreate) { unlink(file_name); Loading @@ -1005,8 +1011,6 @@ static int open_with_extension(char* file_name, const char* extension, bool recr } return open(file_name, flags, 0600); } return -1; } static bool set_permissions_and_ownership(int fd, bool is_public, int uid, const char* path) { if (fchmod(fd, Loading Loading @@ -1119,7 +1123,9 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins if (ShouldUseSwapFileForDexopt()) { // Make sure there really is enough space. strcpy(swap_file_name, out_path); swap_fd = open_with_extension(swap_file_name, ".swap", /*recreate*/true); if (add_extension_to_file_name(swap_file_name, ".swap")) { swap_fd = open_output_file(swap_file_name, /*recreate*/true); } if (swap_fd < 0) { // Could not create swap file. Optimistically go on and hope that we can compile // without it. Loading @@ -1131,12 +1137,16 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins } // Avoid generating an app image for extract only since it will not contain any classes. if (!extract_only) { strcpy(image_path, out_path); trim_extension(image_path); // Recreate is false since we want to avoid deleting the image in case dex2oat decides to not // compile anything. image_fd = open_with_extension(image_path, ".art", /*recreate*/false); if (add_extension_to_file_name(image_path, ".art")) { char app_image_format[kPropertyValueMax]; bool have_app_image_format = get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0; if (!extract_only && have_app_image_format) { // Recreate is false since we want to avoid deleting the image in case dex2oat decides to // not compile anything. image_fd = open_output_file(image_path, /*recreate*/false); if (image_fd < 0) { // Could not create application image file. Go on since we can compile without it. ALOGE("installd could not create '%s' for image file during dexopt\n", image_path); Loading @@ -1144,6 +1154,11 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins image_fd = -1; } } // If we have a valid image file path but no image fd, erase the image file. if (image_fd < 0) { unlink(image_path); } } ALOGV("DexInv: --- BEGIN '%s' ---\n", input_file); Loading Loading
cmds/installd/commands.cpp +37 −22 Original line number Diff line number Diff line Loading @@ -669,7 +669,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int image_fd, const char* input_ char app_image_format[kPropertyValueMax]; char image_format_arg[strlen("--image-format=") + kPropertyValueMax]; bool have_app_image_format = get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0; image_fd >= 0 && get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0; if (have_app_image_format) { sprintf(image_format_arg, "--image-format=%s", app_image_format); } Loading Loading @@ -995,9 +995,15 @@ static void trim_extension(char* path) { } } static int open_with_extension(char* file_name, const char* extension, bool recreate) { if (strlen(file_name) + strlen(extension) + 1 <= PKG_PATH_MAX) { static bool add_extension_to_file_name(char* file_name, const char* extension) { if (strlen(file_name) + strlen(extension) + 1 > PKG_PATH_MAX) { return false; } strcat(file_name, extension); return true; } static int open_output_file(char* file_name, bool recreate) { int flags = O_RDWR | O_CREAT; if (recreate) { unlink(file_name); Loading @@ -1005,8 +1011,6 @@ static int open_with_extension(char* file_name, const char* extension, bool recr } return open(file_name, flags, 0600); } return -1; } static bool set_permissions_and_ownership(int fd, bool is_public, int uid, const char* path) { if (fchmod(fd, Loading Loading @@ -1119,7 +1123,9 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins if (ShouldUseSwapFileForDexopt()) { // Make sure there really is enough space. strcpy(swap_file_name, out_path); swap_fd = open_with_extension(swap_file_name, ".swap", /*recreate*/true); if (add_extension_to_file_name(swap_file_name, ".swap")) { swap_fd = open_output_file(swap_file_name, /*recreate*/true); } if (swap_fd < 0) { // Could not create swap file. Optimistically go on and hope that we can compile // without it. Loading @@ -1131,12 +1137,16 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins } // Avoid generating an app image for extract only since it will not contain any classes. if (!extract_only) { strcpy(image_path, out_path); trim_extension(image_path); // Recreate is false since we want to avoid deleting the image in case dex2oat decides to not // compile anything. image_fd = open_with_extension(image_path, ".art", /*recreate*/false); if (add_extension_to_file_name(image_path, ".art")) { char app_image_format[kPropertyValueMax]; bool have_app_image_format = get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0; if (!extract_only && have_app_image_format) { // Recreate is false since we want to avoid deleting the image in case dex2oat decides to // not compile anything. image_fd = open_output_file(image_path, /*recreate*/false); if (image_fd < 0) { // Could not create application image file. Go on since we can compile without it. ALOGE("installd could not create '%s' for image file during dexopt\n", image_path); Loading @@ -1144,6 +1154,11 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins image_fd = -1; } } // If we have a valid image file path but no image fd, erase the image file. if (image_fd < 0) { unlink(image_path); } } ALOGV("DexInv: --- BEGIN '%s' ---\n", input_file); Loading