Map target partitions with force_writable when resuming an update.

When resuming an update, InitPartitionMetadata isn't called, so
partitions at target slot may not be mapped. GetDynamicPartitionDevice
should map them with force_writable.

Bug: 120465293
Bug: 120775936
Test: abort and resume an update
Change-Id: I7aba53837d1e992908d2365afba881033cfa132e
diff --git a/boot_control_android.cc b/boot_control_android.cc
index 2d2b77e..7d02ee2 100644
--- a/boot_control_android.cc
+++ b/boot_control_android.cc
@@ -157,6 +157,8 @@
 
   DmDeviceState state = dynamic_control_->GetState(partition_name_suffix);
 
+  // Device is mapped in the previous GetPartitionDevice() call. Just return
+  // the path.
   if (state == DmDeviceState::ACTIVE) {
     if (dynamic_control_->GetDmDevicePathByName(partition_name_suffix,
                                                 device)) {
@@ -168,16 +170,12 @@
     return DynamicPartitionDeviceStatus::ERROR;
   }
 
-  // DeltaPerformer calls InitPartitionMetadata before calling
-  // InstallPlan::LoadPartitionsFromSlots. After InitPartitionMetadata,
-  // the target partition must be re-mapped with force_writable == true.
-  // Hence, if it is not mapped, we assume it is a source partition and
-  // map it without force_writable.
   if (state == DmDeviceState::INVALID) {
+    bool force_writable = slot != GetCurrentSlot();
     if (dynamic_control_->MapPartitionOnDeviceMapper(super_device,
                                                      partition_name_suffix,
                                                      slot,
-                                                     false /* force_writable */,
+                                                     force_writable,
                                                      device)) {
       return DynamicPartitionDeviceStatus::SUCCESS;
     }