update_engine: Remove ec_version and fw_version

It seems like these values were set for devices like parrot that have
been AUE'ed long time ago. The server side doesn't use this values and
it doesn't seem we need them anywhere. So its better to not send them
anymore since currently we're just sending empty values for them.

BUG=b:171829801
TEST=FEATURES=test emerge-reef update_engine

Change-Id: I2d2cd5f9d079ce5c87fc8167e30f91d1ffe1c87a
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2504454
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Tianjie Xu <xunchang@google.com>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/common/fake_hardware.h b/common/fake_hardware.h
index 82382ff..00a212e 100644
--- a/common/fake_hardware.h
+++ b/common/fake_hardware.h
@@ -76,10 +76,6 @@
 
   std::string GetHardwareClass() const override { return hardware_class_; }
 
-  std::string GetFirmwareVersion() const override { return firmware_version_; }
-
-  std::string GetECVersion() const override { return ec_version_; }
-
   std::string GetDeviceRequisition() const override {
     return device_requisition_;
   }
@@ -176,12 +172,6 @@
     hardware_class_ = hardware_class;
   }
 
-  void SetFirmwareVersion(const std::string& firmware_version) {
-    firmware_version_ = firmware_version;
-  }
-
-  void SetECVersion(const std::string& ec_version) { ec_version_ = ec_version; }
-
   void SetDeviceRequisition(const std::string& requisition) {
     device_requisition_ = requisition;
   }
@@ -233,8 +223,6 @@
   // Jan 20, 2007
   base::Time oobe_timestamp_{base::Time::FromTimeT(1169280000)};
   std::string hardware_class_{"Fake HWID BLAH-1234"};
-  std::string firmware_version_{"Fake Firmware v1.0.1"};
-  std::string ec_version_{"Fake EC v1.0a"};
   std::string device_requisition_{"fake_requisition"};
   int min_kernel_key_version_{kMinKernelKeyVersion};
   int min_firmware_key_version_{kMinFirmwareKeyVersion};
diff --git a/common/hardware_interface.h b/common/hardware_interface.h
index b37b007..cad32fc 100644
--- a/common/hardware_interface.h
+++ b/common/hardware_interface.h
@@ -64,14 +64,6 @@
   // Returns the HWID or an empty string on error.
   virtual std::string GetHardwareClass() const = 0;
 
-  // Returns the firmware version or an empty string if the system is
-  // not running chrome os firmware.
-  virtual std::string GetFirmwareVersion() const = 0;
-
-  // Returns the ec version or an empty string if the system is not
-  // running a custom chrome os ec.
-  virtual std::string GetECVersion() const = 0;
-
   // Returns the OEM device requisition or an empty string if the system does
   // not have a requisition, or if not running Chrome OS.
   virtual std::string GetDeviceRequisition() const = 0;
diff --git a/common/mock_hardware.h b/common/mock_hardware.h
index 84c0c5b..071906b 100644
--- a/common/mock_hardware.h
+++ b/common/mock_hardware.h
@@ -45,11 +45,6 @@
     ON_CALL(*this, GetHardwareClass())
         .WillByDefault(
             testing::Invoke(&fake_, &FakeHardware::GetHardwareClass));
-    ON_CALL(*this, GetFirmwareVersion())
-        .WillByDefault(
-            testing::Invoke(&fake_, &FakeHardware::GetFirmwareVersion));
-    ON_CALL(*this, GetECVersion())
-        .WillByDefault(testing::Invoke(&fake_, &FakeHardware::GetECVersion));
     ON_CALL(*this, GetMinKernelKeyVersion())
         .WillByDefault(
             testing::Invoke(&fake_, &FakeHardware::GetMinKernelKeyVersion));
@@ -90,8 +85,6 @@
   MOCK_CONST_METHOD0(IsOOBEEnabled, bool());
   MOCK_CONST_METHOD1(IsOOBEComplete, bool(base::Time* out_time_of_oobe));
   MOCK_CONST_METHOD0(GetHardwareClass, std::string());
-  MOCK_CONST_METHOD0(GetFirmwareVersion, std::string());
-  MOCK_CONST_METHOD0(GetECVersion, std::string());
   MOCK_CONST_METHOD0(GetMinKernelKeyVersion, int());
   MOCK_CONST_METHOD0(GetMinFirmwareKeyVersion, int());
   MOCK_CONST_METHOD0(GetMaxFirmwareKeyRollforward, int());
diff --git a/common/utils.cc b/common/utils.cc
index 9e1e6c5..c8924b1 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -112,27 +112,6 @@
 
 namespace utils {
 
-string ParseECVersion(string input_line) {
-  base::TrimWhitespaceASCII(input_line, base::TRIM_ALL, &input_line);
-
-  // At this point we want to convert the format key=value pair from mosys to
-  // a vector of key value pairs.
-  vector<pair<string, string>> kv_pairs;
-  if (base::SplitStringIntoKeyValuePairs(input_line, '=', ' ', &kv_pairs)) {
-    for (const pair<string, string>& kv_pair : kv_pairs) {
-      // Finally match against the fw_verion which may have quotes.
-      if (kv_pair.first == "fw_version") {
-        string output;
-        // Trim any quotes.
-        base::TrimString(kv_pair.second, "\"", &output);
-        return output;
-      }
-    }
-  }
-  LOG(ERROR) << "Unable to parse fwid from ec info.";
-  return "";
-}
-
 bool WriteFile(const char* path, const void* data, size_t data_len) {
   int fd = HANDLE_EINTR(open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600));
   TEST_AND_RETURN_FALSE_ERRNO(fd >= 0);
diff --git a/common/utils.h b/common/utils.h
index bcaed31..f364bfd 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -53,10 +53,6 @@
 std::string CalculateP2PFileId(const brillo::Blob& payload_hash,
                                size_t payload_size);
 
-// Parse the firmware version from one line of output from the
-// "mosys" command.
-std::string ParseECVersion(std::string input_line);
-
 // Writes the data passed to path. The file at path will be overwritten if it
 // exists. Returns true on success, false otherwise.
 bool WriteFile(const char* path, const void* data, size_t data_len);
diff --git a/common/utils_unittest.cc b/common/utils_unittest.cc
index d73b3da..bc5c3b0 100644
--- a/common/utils_unittest.cc
+++ b/common/utils_unittest.cc
@@ -41,19 +41,6 @@
 
 class UtilsTest : public ::testing::Test {};
 
-TEST(UtilsTest, CanParseECVersion) {
-  // Should be able to parse and valid key value line.
-  EXPECT_EQ("12345", utils::ParseECVersion("fw_version=12345"));
-  EXPECT_EQ("123456",
-            utils::ParseECVersion("b=1231a fw_version=123456 a=fasd2"));
-  EXPECT_EQ("12345", utils::ParseECVersion("fw_version=12345"));
-  EXPECT_EQ("00VFA616",
-            utils::ParseECVersion("vendor=\"sam\" fw_version=\"00VFA616\""));
-
-  // For invalid entries, should return the empty string.
-  EXPECT_EQ("", utils::ParseECVersion("b=1231a fw_version a=fasd2"));
-}
-
 TEST(UtilsTest, WriteFileOpenFailure) {
   EXPECT_FALSE(utils::WriteFile("/this/doesn't/exist", "hello", 5));
 }
diff --git a/hardware_android.cc b/hardware_android.cc
index 4894522..8d1fdfd 100644
--- a/hardware_android.cc
+++ b/hardware_android.cc
@@ -49,8 +49,6 @@
 // Android properties that identify the hardware and potentially non-updatable
 // parts of the bootloader (such as the bootloader version and the baseband
 // version).
-const char kPropBootBootloader[] = "ro.boot.bootloader";
-const char kPropBootBaseband[] = "ro.boot.baseband";
 const char kPropProductManufacturer[] = "ro.product.manufacturer";
 const char kPropBootHardwareSKU[] = "ro.boot.hardware.sku";
 const char kPropBootRevision[] = "ro.boot.revision";
@@ -128,14 +126,6 @@
   return manufacturer + ":" + sku + ":" + revision;
 }
 
-string HardwareAndroid::GetFirmwareVersion() const {
-  return GetProperty(kPropBootBootloader, "");
-}
-
-string HardwareAndroid::GetECVersion() const {
-  return GetProperty(kPropBootBaseband, "");
-}
-
 string HardwareAndroid::GetDeviceRequisition() const {
   LOG(WARNING) << "STUB: Getting requisition is not supported.";
   return "";
diff --git a/hardware_android.h b/hardware_android.h
index b670447..d7e39f3 100644
--- a/hardware_android.h
+++ b/hardware_android.h
@@ -43,8 +43,6 @@
   bool IsOOBEEnabled() const override;
   bool IsOOBEComplete(base::Time* out_time_of_oobe) const override;
   std::string GetHardwareClass() const override;
-  std::string GetFirmwareVersion() const override;
-  std::string GetECVersion() const override;
   std::string GetDeviceRequisition() const override;
   int GetMinKernelKeyVersion() const override;
   int GetMinFirmwareKeyVersion() const override;
diff --git a/hardware_chromeos.cc b/hardware_chromeos.cc
index cce5e84..dbb99db 100644
--- a/hardware_chromeos.cc
+++ b/hardware_chromeos.cc
@@ -175,25 +175,6 @@
   return ReadValueFromCrosSystem("hwid");
 }
 
-string HardwareChromeOS::GetFirmwareVersion() const {
-  return ReadValueFromCrosSystem("fwid");
-}
-
-string HardwareChromeOS::GetECVersion() const {
-  string input_line, error;
-  int exit_code = 0;
-  vector<string> cmd = {"/usr/sbin/mosys", "-k", "ec", "info"};
-
-  if (!Subprocess::SynchronousExec(cmd, &exit_code, &input_line, &error) ||
-      exit_code != 0) {
-    LOG(ERROR) << "Unable to read EC info from mosys with exit code: "
-               << exit_code << " and error: " << error;
-    return "";
-  }
-
-  return utils::ParseECVersion(input_line);
-}
-
 string HardwareChromeOS::GetDeviceRequisition() const {
 #if USE_CFM
   const char* kLocalStatePath = "/home/chronos/Local State";
diff --git a/hardware_chromeos.h b/hardware_chromeos.h
index bbfe273..9ee62f6 100644
--- a/hardware_chromeos.h
+++ b/hardware_chromeos.h
@@ -46,8 +46,6 @@
   bool IsOOBEEnabled() const override;
   bool IsOOBEComplete(base::Time* out_time_of_oobe) const override;
   std::string GetHardwareClass() const override;
-  std::string GetFirmwareVersion() const override;
-  std::string GetECVersion() const override;
   std::string GetDeviceRequisition() const override;
   int GetMinKernelKeyVersion() const override;
   int GetMinFirmwareKeyVersion() const override;
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index adb95df..61e988b 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -365,8 +365,6 @@
     request_params_.set_current_channel("unittest");
     request_params_.set_target_channel("unittest");
     request_params_.set_hwid("OEM MODEL 09235 7471");
-    request_params_.set_fw_version("ChromeOSFirmware.1.0");
-    request_params_.set_ec_version("0X0A1");
     request_params_.set_delta_okay(true);
     request_params_.set_interactive(false);
     request_params_.set_update_url("http://url");
@@ -1604,8 +1602,6 @@
       string::npos);
   EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""),
             string::npos);
-  EXPECT_NE(post_str.find("fw_version=\"ChromeOSFirmware.1.0\""), string::npos);
-  EXPECT_NE(post_str.find("ec_version=\"0X0A1\""), string::npos);
   // No <event> tag should be sent if we didn't reboot to an update.
   EXPECT_EQ(post_str.find("<event"), string::npos);
 }
diff --git a/omaha_request_builder_xml.cc b/omaha_request_builder_xml.cc
index 690a4ef..6660afb 100644
--- a/omaha_request_builder_xml.cc
+++ b/omaha_request_builder_xml.cc
@@ -368,8 +368,6 @@
       // DLC excluded for installs and updates.
       (app_data.is_dlc ? "" :
       "lang=\"" + XmlEncodeWithDefault(params_->app_lang(), "en-US") + "\" " +
-      "fw_version=\"" + XmlEncodeWithDefault(params_->fw_version()) + "\" " +
-      "ec_version=\"" + XmlEncodeWithDefault(params_->ec_version()) + "\" " +
       requisition_arg) +
 
       ">\n" +
diff --git a/omaha_request_builder_xml_unittest.cc b/omaha_request_builder_xml_unittest.cc
index a804420..042d991 100644
--- a/omaha_request_builder_xml_unittest.cc
+++ b/omaha_request_builder_xml_unittest.cc
@@ -108,8 +108,6 @@
   // in fact present in the <app ...></app>.
   const string app = omaha_request.GetApp(dlc_app_data);
   EXPECT_NE(string::npos, app.find("lang="));
-  EXPECT_NE(string::npos, app.find("fw_version="));
-  EXPECT_NE(string::npos, app.find("ec_version="));
   EXPECT_NE(string::npos, app.find("requisition="));
 }
 
@@ -132,8 +130,6 @@
   // fact not present in the <app ...></app>.
   const string app = omaha_request.GetApp(dlc_app_data);
   EXPECT_EQ(string::npos, app.find("lang="));
-  EXPECT_EQ(string::npos, app.find("fw_version="));
-  EXPECT_EQ(string::npos, app.find("ec_version="));
   EXPECT_EQ(string::npos, app.find("requisition="));
 }
 
diff --git a/omaha_request_params.cc b/omaha_request_params.cc
index 79d19e8..5a48720 100644
--- a/omaha_request_params.cc
+++ b/omaha_request_params.cc
@@ -92,10 +92,6 @@
   os_sp_ = image_props_.version + "_" + GetMachineType();
   app_lang_ = "en-US";
   hwid_ = system_state_->hardware()->GetHardwareClass();
-  if (CollectECFWVersions()) {
-    fw_version_ = system_state_->hardware()->GetFirmwareVersion();
-    ec_version_ = system_state_->hardware()->GetECVersion();
-  }
   device_requisition_ = system_state_->hardware()->GetDeviceRequisition();
 
   if (image_props_.current_channel == mutable_image_props_.target_channel) {
@@ -170,14 +166,6 @@
           update_url_ == image_props_.omaha_url);
 }
 
-bool OmahaRequestParams::CollectECFWVersions() const {
-  return base::StartsWith(
-             hwid_, string("PARROT"), base::CompareCase::SENSITIVE) ||
-         base::StartsWith(
-             hwid_, string("SPRING"), base::CompareCase::SENSITIVE) ||
-         base::StartsWith(hwid_, string("SNOW"), base::CompareCase::SENSITIVE);
-}
-
 bool OmahaRequestParams::SetTargetChannel(const string& new_target_channel,
                                           bool is_powerwash_allowed,
                                           string* error_message) {
diff --git a/omaha_request_params.h b/omaha_request_params.h
index 7e19262..ed3cc80 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -104,8 +104,6 @@
   }
   inline std::string app_lang() const { return app_lang_; }
   inline std::string hwid() const { return hwid_; }
-  inline std::string fw_version() const { return fw_version_; }
-  inline std::string ec_version() const { return ec_version_; }
   inline std::string device_requisition() const { return device_requisition_; }
 
   inline void set_app_version(const std::string& version) {
@@ -294,12 +292,6 @@
   }
   void set_app_lang(const std::string& app_lang) { app_lang_ = app_lang; }
   void set_hwid(const std::string& hwid) { hwid_ = hwid; }
-  void set_fw_version(const std::string& fw_version) {
-    fw_version_ = fw_version;
-  }
-  void set_ec_version(const std::string& ec_version) {
-    ec_version_ = ec_version;
-  }
   void set_is_powerwash_allowed(bool powerwash_allowed) {
     mutable_image_props_.is_powerwash_allowed = powerwash_allowed;
   }
@@ -313,7 +305,6 @@
 
  private:
   FRIEND_TEST(OmahaRequestParamsTest, ChannelIndexTest);
-  FRIEND_TEST(OmahaRequestParamsTest, CollectECFWVersionsTest);
   FRIEND_TEST(OmahaRequestParamsTest, IsValidChannelTest);
   FRIEND_TEST(OmahaRequestParamsTest, SetIsPowerwashAllowedTest);
   FRIEND_TEST(OmahaRequestParamsTest, SetTargetChannelInvalidTest);
@@ -336,10 +327,6 @@
   // i.e. index(target_channel) > index(current_channel).
   bool ToMoreStableChannel() const;
 
-  // Returns True if we should store the fw/ec versions based on our hwid_.
-  // Compares hwid to a set of prefixes in the allowlist.
-  bool CollectECFWVersions() const;
-
   // Gets the machine type (e.g. "i686").
   std::string GetMachineType() const;
 
@@ -380,8 +367,6 @@
   std::string lts_tag_;
 
   std::string hwid_;        // Hardware Qualification ID of the client
-  std::string fw_version_;  // Chrome OS Firmware Version.
-  std::string ec_version_;  // Chrome OS EC Version.
   // TODO(b:133324571) tracks removal of this field once it is no longer
   // needed in AU requests. Remove by October 1st 2019.
   std::string device_requisition_;  // Chrome OS Requisition type.
diff --git a/omaha_request_params_unittest.cc b/omaha_request_params_unittest.cc
index 140cad3..fcf8062 100644
--- a/omaha_request_params_unittest.cc
+++ b/omaha_request_params_unittest.cc
@@ -257,14 +257,6 @@
   EXPECT_TRUE(params_.ShouldPowerwash());
 }
 
-TEST_F(OmahaRequestParamsTest, CollectECFWVersionsTest) {
-  params_.hwid_ = string("STUMPY ALEX 12345");
-  EXPECT_FALSE(params_.CollectECFWVersions());
-
-  params_.hwid_ = string("SNOW 12345");
-  EXPECT_TRUE(params_.CollectECFWVersions());
-}
-
 TEST_F(OmahaRequestParamsTest, RequisitionIsSetTest) {
   EXPECT_TRUE(params_.Init("", "", {}));
   EXPECT_EQ("fake_requisition", params_.device_requisition());