installd: Run dex2oat with relative path to the APK

Previous CL (I6aaddffe79c55b9a6560c2d6542cf87abbd4fb11) started
passing the absolute path of an APK to dex2oat. This renders APKs
dexopted while in a temporary folder during install out-of-date when
moved to the final location.

Bug: 26409579
Change-Id: Icccf2d1bb34e2d5f4d98efae3c8f5609784abafd
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index e9ec3d3..8fcf9e8 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -1194,7 +1194,14 @@
             || dexopt_needed == DEXOPT_SELF_PATCHOAT_NEEDED) {
             run_patchoat(input_fd, out_fd, input_file, out_path, pkgname, instruction_set);
         } else if (dexopt_needed == DEXOPT_DEX2OAT_NEEDED) {
-            run_dex2oat(input_fd, out_fd, image_fd, input_file, out_path, swap_fd,
+            // Pass dex2oat the relative path to the input file.
+            const char *input_file_name = strrchr(input_file, '/');
+            if (input_file_name == NULL) {
+                input_file_name = input_file;
+            } else {
+                input_file_name++;
+            }
+            run_dex2oat(input_fd, out_fd, image_fd, input_file_name, out_path, swap_fd,
                         instruction_set, vm_safe_mode, debuggable, boot_complete, extract_only,
                         profile_files_fd, reference_profile_files_fd);
         } else {