Fix non-critical updates on boards without an OOBE flow.
A recent change in the policy made update_engine to ignore available
updates if the OOBE flow is not completed and the update is not
critical. Nevertheless, some custom boards don't have a OOBE flow as
Chromebooks do and set is_oobe_enabled=false in the policy manager.
These board were not getting regular updates because the OOBE flow is
considered not completed in those cases.
This patch moves the is_oobe_enabled flag to the HardwareInterface class
together with the IsOOBEComplete() method and updates the callers to
check the IsOOBEEnabled() value before.
Bug: 28460247
Bug: 28553821
TEST=Added unittest for the disabled and not complete case.
Change-Id: Ifd3ac2dc5e7a43f6c24eb014b7e3eacad22e3ab3
diff --git a/common/fake_hardware.h b/common/fake_hardware.h
index 449787b..4558c8c 100644
--- a/common/fake_hardware.h
+++ b/common/fake_hardware.h
@@ -34,21 +34,15 @@
// false.
static const int kPowerwashCountNotSet = -1;
- FakeHardware()
- : is_official_build_(true),
- is_normal_boot_mode_(true),
- is_oobe_complete_(true),
- oobe_timestamp_(base::Time::FromTimeT(1169280000)), // Jan 20, 2007
- hardware_class_("Fake HWID BLAH-1234"),
- firmware_version_("Fake Firmware v1.0.1"),
- ec_version_("Fake EC v1.0a"),
- powerwash_count_(kPowerwashCountNotSet) {}
+ FakeHardware() = default;
// HardwareInterface methods.
bool IsOfficialBuild() const override { return is_official_build_; }
bool IsNormalBootMode() const override { return is_normal_boot_mode_; }
+ bool IsOOBEEnabled() const override { return is_oobe_enabled_; }
+
bool IsOOBEComplete(base::Time* out_time_of_oobe) const override {
if (out_time_of_oobe != nullptr)
*out_time_of_oobe = oobe_timestamp_;
@@ -80,13 +74,17 @@
is_normal_boot_mode_ = is_normal_boot_mode;
}
+ // Sets the SetIsOOBEEnabled to |is_oobe_enabled|.
+ void SetIsOOBEEnabled(bool is_oobe_enabled) {
+ is_oobe_enabled_ = is_oobe_enabled;
+ }
+
// Sets the IsOOBEComplete to True with the given timestamp.
void SetIsOOBEComplete(base::Time oobe_timestamp) {
is_oobe_complete_ = true;
oobe_timestamp_ = oobe_timestamp;
}
- // Sets the IsOOBEComplete to False.
void UnsetIsOOBEComplete() {
is_oobe_complete_ = false;
}
@@ -108,14 +106,15 @@
}
private:
- bool is_official_build_;
- bool is_normal_boot_mode_;
- bool is_oobe_complete_;
- base::Time oobe_timestamp_;
- std::string hardware_class_;
- std::string firmware_version_;
- std::string ec_version_;
- int powerwash_count_;
+ bool is_official_build_{true};
+ bool is_normal_boot_mode_{true};
+ bool is_oobe_enabled_{true};
+ bool is_oobe_complete_{true};
+ base::Time oobe_timestamp_{base::Time::FromTimeT(1169280000)}; // Jan 20, 2007
+ 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"};
+ int powerwash_count_{kPowerwashCountNotSet};
DISALLOW_COPY_AND_ASSIGN(FakeHardware);
};