Hardcode in dexopt the information that /system/product should be /product.

On-device compilation will always see paths starting with /product. This CL
makes sure preopt does the same.

Test: m && check odex files
Bug: 126415372
Change-Id: I5764e7f22bffb97b7093f351d7b97bbe5fb1f2f1
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 9e333c1..01ee15e 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -331,6 +331,14 @@
 		rule.Command().Text("source").Tool(global.Tools.ConstructContext)
 	}
 
+	// Devices that do not have a product partition use a symlink from /product to /system/product.
+	// Because on-device dexopt will see dex locations starting with /product, we change the paths
+	// to mimic this behavior.
+	dexLocationArg := module.DexLocation
+	if strings.HasPrefix(dexLocationArg, "/system/product/") {
+		dexLocationArg = strings.TrimPrefix(dexLocationArg, "/system")
+	}
+
 	cmd := rule.Command().
 		Text(`ANDROID_LOG_TAGS="*:e"`).
 		Tool(global.Tools.Dex2oat).
@@ -344,7 +352,7 @@
 		Flag("${stored_class_loader_context_arg}").
 		FlagWithArg("--boot-image=", bootImageLocation).Implicit(bootImage).
 		FlagWithInput("--dex-file=", module.DexPath).
-		FlagWithArg("--dex-location=", module.DexLocation).
+		FlagWithArg("--dex-location=", dexLocationArg).
 		FlagWithOutput("--oat-file=", odexPath).ImplicitOutput(vdexPath).
 		// Pass an empty directory, dex2oat shouldn't be reading arbitrary files
 		FlagWithArg("--android-root=", global.EmptyDirectory).