Fix mixed build launch failure

Composite disk creater will use new_super_image() if exists, and fall
back to super_image() otherwise. Now, super image remixer will
call set_super_image() to change original super image path and re-write
the original super image. However, new_super_image() still points to old
image, therefore, launch_cvd proceeds to using unmodified original super
image, resulting in VBMETA failure.

Test: acloud create --local-instance --build-id 9730819
--system-build-id 9731304

Change-Id: I7c9c9b9995bf3a44e954f1b6b0fd7a3facbe5c4d
diff --git a/host/commands/assemble_cvd/disk_flags.cc b/host/commands/assemble_cvd/disk_flags.cc
index 35a2acc..585d726 100644
--- a/host/commands/assemble_cvd/disk_flags.cc
+++ b/host/commands/assemble_cvd/disk_flags.cc
@@ -1320,7 +1320,6 @@
       cur_super_image = super_image[instance_index];
     }
     instance.set_super_image(cur_super_image);
-    instance.set_new_super_image(cur_super_image);
     if (instance_index >= data_image.size()) {
       instance.set_data_image(data_image[0]);
     } else {
@@ -1430,16 +1429,16 @@
       if (cur_initramfs_path.size()) {
         // change the new flag value to corresponding instance
         instance.set_new_vendor_boot_image(new_vendor_boot_image_path.c_str());
-        const std::string new_super_image_path =
-            const_instance.PerInstancePath("super_repacked.img");
-        instance.set_new_super_image(new_super_image_path.c_str());
       }
     }
 
-    if (SuperImageNeedsRebuilding(fetcher_config)) {
+    // We will need to rebuild vendor_dlkm if custom ramdisk is specified, as a
+    // result super image would need to be rebuilt as well.
+    if (SuperImageNeedsRebuilding(fetcher_config) ||
+        cur_initramfs_path.size()) {
       const std::string new_super_image_path =
           const_instance.PerInstancePath("super.img");
-      instance.set_super_image(new_super_image_path);
+      instance.set_new_super_image(new_super_image_path);
     }
 
     if (FileExists(cur_metadata_image) &&
diff --git a/host/commands/assemble_cvd/super_image_mixer.cc b/host/commands/assemble_cvd/super_image_mixer.cc
index d0bdee1..a22e2e1 100644
--- a/host/commands/assemble_cvd/super_image_mixer.cc
+++ b/host/commands/assemble_cvd/super_image_mixer.cc
@@ -273,8 +273,8 @@
   std::unordered_set<SetupFeature*> Dependencies() const override { return {}; }
   Result<void> ResultSetup() override {
     if (SuperImageNeedsRebuilding(fetcher_config_)) {
-      CF_EXPECT(
-          RebuildSuperImage(fetcher_config_, config_, instance_.super_image()));
+      CF_EXPECT(RebuildSuperImage(fetcher_config_, config_,
+                                  instance_.new_super_image()));
     }
     return {};
   }