OSDN Git Service

Fix incorrect odex path handling android-x86-4.4-r1
authorChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 28 Apr 2014 07:47:45 +0000 (15:47 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 29 Apr 2014 04:04:35 +0000 (12:04 +0800)
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

index 84ad204..7034e68 100644 (file)
@@ -674,9 +674,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)) {