Adding GetInfo method for tasks

Using for easier debugging. Replacing old getter methods in flash task
with GetInfo(key)

Test: fastboot_test
Change-Id: If42df86c4b0278c3dc5525b1058f1947f0b34794
diff --git a/fastboot/task.cpp b/fastboot/task.cpp
index 9ce2cfd..03f9b89 100644
--- a/fastboot/task.cpp
+++ b/fastboot/task.cpp
@@ -46,6 +46,14 @@
     do_for_partitions(pname_, slot_, flash, true);
 }
 
+std::string FlashTask::ToString() {
+    std::string apply_vbmeta_string = "";
+    if (apply_vbmeta_) {
+        apply_vbmeta_string = " --apply_vbmeta";
+    }
+    return "flash" + apply_vbmeta_string + " " + pname_ + " " + fname_;
+}
+
 std::string FlashTask::GetPartitionAndSlot() {
     auto slot = slot_;
     if (slot.empty()) {
@@ -84,6 +92,10 @@
     }
 }
 
+std::string RebootTask::ToString() {
+    return "reboot " + reboot_target_;
+}
+
 FlashSuperLayoutTask::FlashSuperLayoutTask(const std::string& super_name,
                                            std::unique_ptr<SuperFlashHelper> helper,
                                            SparsePtr sparse_layout, uint64_t super_size)
@@ -106,6 +118,9 @@
     // Send the data to the device.
     flash_partition_files(super_name_, files);
 }
+std::string FlashSuperLayoutTask::ToString() {
+    return "optimized-flash-super";
+}
 
 std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize(
         const FlashingPlan* fp, std::vector<ImageEntry>& os_images) {
@@ -263,6 +278,9 @@
     }
     fp_->fb->RawCommand(command, "Updating super partition");
 }
+std::string UpdateSuperTask::ToString() {
+    return "update-super";
+}
 
 ResizeTask::ResizeTask(const FlashingPlan* fp, const std::string& pname, const std::string& size,
                        const std::string& slot)
@@ -277,12 +295,20 @@
     do_for_partitions(pname_, slot_, resize_partition, false);
 }
 
+std::string ResizeTask::ToString() {
+    return "resize " + pname_;
+}
+
 DeleteTask::DeleteTask(const FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){};
 
 void DeleteTask::Run() {
     fp_->fb->DeletePartition(pname_);
 }
 
+std::string DeleteTask::ToString() {
+    return "delete " + pname_;
+}
+
 WipeTask::WipeTask(const FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){};
 
 void WipeTask::Run() {
@@ -298,3 +324,7 @@
     }
     fb_perform_format(pname_, 1, partition_type, "", fp_->fs_options);
 }
+
+std::string WipeTask::ToString() {
+    return "erase " + pname_;
+}
diff --git a/fastboot/task.h b/fastboot/task.h
index 82e8ebf..500655d 100644
--- a/fastboot/task.h
+++ b/fastboot/task.h
@@ -35,6 +35,8 @@
   public:
     Task() = default;
     virtual void Run() = 0;
+    virtual std::string ToString() = 0;
+
     virtual FlashTask* AsFlashTask() { return nullptr; }
     virtual RebootTask* AsRebootTask() { return nullptr; }
     virtual UpdateSuperTask* AsUpdateSuperTask() { return nullptr; }
@@ -49,11 +51,12 @@
               const bool apply_vbmeta, const FlashingPlan* fp);
     virtual FlashTask* AsFlashTask() override { return this; }
 
+    void Run() override;
+    std::string ToString() override;
     std::string GetPartition() { return pname_; }
     std::string GetImageName() { return fname_; }
-    std::string GetPartitionAndSlot();
     std::string GetSlot() { return slot_; }
-    void Run() override;
+    std::string GetPartitionAndSlot();
 
   private:
     const std::string pname_;
@@ -69,6 +72,7 @@
     RebootTask(const FlashingPlan* fp, const std::string& reboot_target);
     virtual RebootTask* AsRebootTask() override { return this; }
     void Run() override;
+    std::string ToString() override;
 
   private:
     const std::string reboot_target_ = "";
@@ -85,6 +89,7 @@
             const FlashingPlan* fp, std::vector<std::unique_ptr<Task>>& tasks);
     using ImageEntry = std::pair<const Image*, std::string>;
     void Run() override;
+    std::string ToString() override;
 
   private:
     const std::string super_name_;
@@ -99,6 +104,7 @@
     virtual UpdateSuperTask* AsUpdateSuperTask() override { return this; }
 
     void Run() override;
+    std::string ToString() override;
 
   private:
     const FlashingPlan* fp_;
@@ -109,6 +115,7 @@
     ResizeTask(const FlashingPlan* fp, const std::string& pname, const std::string& size,
                const std::string& slot);
     void Run() override;
+    std::string ToString() override;
 
   private:
     const FlashingPlan* fp_;
@@ -121,6 +128,7 @@
   public:
     DeleteTask(const FlashingPlan* fp, const std::string& pname);
     void Run() override;
+    std::string ToString() override;
 
   private:
     const FlashingPlan* fp_;
@@ -131,8 +139,8 @@
   public:
     WipeTask(const FlashingPlan* fp, const std::string& pname);
     virtual WipeTask* AsWipeTask() override { return this; }
-
     void Run() override;
+    std::string ToString() override;
 
   private:
     const FlashingPlan* fp_;