From e3e19f0dfa57bbf8350f35dce25e5417664cd3c4 Mon Sep 17 00:00:00 2001
From: Nicolas Geoffray <ngeoffray@google.com>
Date: Wed, 24 Jan 2018 14:00:33 +0000
Subject: [PATCH] For prebuilts, use the built_module for nostripping
 dexpreopt.

Earlier, we would use the prebuilt directly, which doesn't go through
build optimizations like uncompressing the dex files.

bug: 63920015
Test: m -j32 && verify priv-apps prebuilt's vdex don't contain
      the dex code.

Change-Id: I1a69d3b6832e3a940616f71a95c13091a4220b4b
---
 core/prebuilt_internal.mk | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index c7caf12bb..ea7fd0383 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -417,11 +417,19 @@ endif  # LOCAL_COMPRESSED_MODULE
 endif  # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
 
 ###############################
-## Rule to build the odex file
+## Rule to build the odex file.
+# In case we don't strip the built module, use it, as dexpreopt
+# can do optimizations based on whether the built module only
+# contains uncompressed dex code.
 ifdef LOCAL_DEX_PREOPT
+ifeq (nostripping,$(LOCAL_DEX_PREOPT))
+$(built_odex) : $(built_module)
+	$(call dexpreopt-one-file,$<,$@)
+else
 $(built_odex) : $(my_prebuilt_src_file)
 	$(call dexpreopt-one-file,$<,$@)
 endif
+endif
 
 ###############################
 ## Install split apks.