Add DynamicPartitionControl::EraseSystemOtherAvbFooter

Erase AVB footer of system other partition prior to any updates so that if
an update overwrites it partially, and the device rolled back (or even
before we finish writing the partition), and the device factory resets,
mapping system_other as /postinstall won't trigger verity errors and
reboots the device.

Bug: 152444348
Test: apply update, rollback, then FDR
Test: apply update, then set sys.cppreopt=requested; observe that
/postinstall cannot be mounted.

Change-Id: I62e5bb8f4c31d9a1beff485c47fc4b07a3a5686b
diff --git a/mock_dynamic_partition_control.h b/mock_dynamic_partition_control.h
index 169c265..1e4e5fd 100644
--- a/mock_dynamic_partition_control.h
+++ b/mock_dynamic_partition_control.h
@@ -77,10 +77,34 @@
   MOCK_METHOD1(GetSuperPartitionName, std::string(uint32_t));
   MOCK_METHOD0(GetVirtualAbFeatureFlag, FeatureFlag());
   MOCK_METHOD1(FinishUpdate, bool(bool));
+  MOCK_METHOD5(
+      GetSystemOtherPath,
+      bool(uint32_t, uint32_t, const std::string&, std::string*, bool*));
+  MOCK_METHOD2(EraseSystemOtherAvbFooter, bool(uint32_t, uint32_t));
+  MOCK_METHOD0(IsAvbEnabledOnSystemOther, std::optional<bool>());
 
   void set_fake_mapped_devices(const std::set<std::string>& fake) override {
     DynamicPartitionControlAndroid::set_fake_mapped_devices(fake);
   }
+
+  bool RealGetSystemOtherPath(uint32_t source_slot,
+                              uint32_t target_slot,
+                              const std::string& partition_name_suffix,
+                              std::string* path,
+                              bool* should_unmap) {
+    return DynamicPartitionControlAndroid::GetSystemOtherPath(
+        source_slot, target_slot, partition_name_suffix, path, should_unmap);
+  }
+
+  bool RealEraseSystemOtherAvbFooter(uint32_t source_slot,
+                                     uint32_t target_slot) {
+    return DynamicPartitionControlAndroid::EraseSystemOtherAvbFooter(
+        source_slot, target_slot);
+  }
+
+  std::optional<bool> RealIsAvbEnabledInFstab(const std::string& path) {
+    return DynamicPartitionControlAndroid::IsAvbEnabledInFstab(path);
+  }
 };
 
 }  // namespace chromeos_update_engine