Only do dexlayout when generating comptact dex.

installd will want to either enable them both or disable them both
(latency sensitive installs or not).

Test: m
Bug: 207346972
Change-Id: I0a2c9d934c56e170b0503d9822cebe8b6e4d3ef3
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index f5c6bc9..7a27ab6 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -2324,7 +2324,11 @@
   }
 
   bool DoDexLayoutOptimizations() const {
-    return DoProfileGuidedOptimizations() || DoGenerateCompactDex();
+    // Only run dexlayout when being asked to generate compact dex. We do this
+    // to avoid having multiple arguments being passed to dex2oat and the main
+    // user of dex2oat (installd) will have the same reasons for
+    // disabling/enabling compact dex and dex layout.
+    return DoGenerateCompactDex();
   }
 
   bool DoOatLayoutOptimizations() const {
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 428ec81..b9e708f 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -3311,9 +3311,9 @@
   if (extract_dex_files_into_vdex_) {
     vdex_dex_files_offset_ = vdex_size_;
 
-    // Perform dexlayout if requested.
-    if (profile_compilation_info_ != nullptr ||
-        compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone) {
+    // Perform dexlayout if compact dex is enabled. Also see
+    // Dex2Oat::DoDexLayoutOptimizations.
+    if (compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone) {
       for (OatDexFile& oat_dex_file : oat_dex_files_) {
         // use_existing_vdex should not be used with compact dex and layout.
         CHECK(!use_existing_vdex)