From 0e8ae16f084e3d4772ea6dd33a9b72925d7b40d5 Mon Sep 17 00:00:00 2001 From: Chih-Wei Huang Date: Mon, 28 Apr 2014 15:47:45 +0800 Subject: [PATCH] Fix incorrect odex path handling It's wrong to just concatenate the apk_path and .odex. The bug prevents the prebuilt odex being used since Kitkat. The patch is copied from the code of JellyBean. Change-Id: I0ce8a877e3df8ae1ab9a0e3aeeef2d5253efc223 --- cmds/installd/commands.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index 669f403e6..a86abe1b7 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -685,9 +685,13 @@ int dexopt(const char *apk_path, uid_t uid, int is_public, /* Before anything else: is there a .odex file? If so, we have * precompiled the apk and there is nothing to do here. */ - sprintf(out_path, "%s%s", apk_path, ".odex"); - if (stat(out_path, &dex_stat) == 0) { - return 0; + strcpy(out_path, apk_path); + end = strrchr(out_path, '.'); + if (end != NULL) { + strcpy(end, ".odex"); + if (stat(out_path, &dex_stat) == 0) { + return 0; + } } if (create_cache_path(out_path, apk_path)) {