Gracefully return an error if cow reader failed

Invoke cow_writer->OpenReader() before constructing
CowWriterFileDescriptor, and return nullptr if OpenReader() failed.

Bug: 210474209
Test: th
Change-Id: Icbdf98c5151f4964d31315eadca2ee8eaa0e101e
diff --git a/aosp/dynamic_partition_control_android.cc b/aosp/dynamic_partition_control_android.cc
index 60936f2..825e0d6 100644
--- a/aosp/dynamic_partition_control_android.cc
+++ b/aosp/dynamic_partition_control_android.cc
@@ -1430,9 +1430,16 @@
     return nullptr;
   }
   if (!cow_writer->InitializeAppend(kEndOfInstallLabel)) {
+    LOG(ERROR) << "Failed to InitializeAppend(" << kEndOfInstallLabel << ")";
     return nullptr;
   }
-  return std::make_shared<CowWriterFileDescriptor>(std::move(cow_writer));
+  auto reader = cow_writer->OpenReader();
+  if (reader == nullptr) {
+    LOG(ERROR) << "ICowWriter::OpenReader() failed.";
+    return nullptr;
+  }
+  return std::make_shared<CowWriterFileDescriptor>(std::move(cow_writer),
+                                                   std::move(reader));
 }
 
 std::optional<base::FilePath> DynamicPartitionControlAndroid::GetSuperDevice() {