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/update_manager/real_config_provider.cc b/update_manager/real_config_provider.cc
index 2d17a7f..97e624e 100644
--- a/update_manager/real_config_provider.cc
+++ b/update_manager/real_config_provider.cc
@@ -16,47 +16,13 @@
#include "update_engine/update_manager/real_config_provider.h"
-#include <base/files/file_path.h>
-#include <base/logging.h>
-#include <brillo/key_value_store.h>
-
-#include "update_engine/common/constants.h"
-#include "update_engine/common/utils.h"
#include "update_engine/update_manager/generic_variables.h"
-using brillo::KeyValueStore;
-
-namespace {
-
-const char* kConfigFilePath = "/etc/update_manager.conf";
-
-// Config options:
-const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled";
-
-} // namespace
-
namespace chromeos_update_manager {
bool RealConfigProvider::Init() {
- KeyValueStore store;
-
- if (hardware_->IsNormalBootMode()) {
- store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
- } else {
- if (store.Load(base::FilePath(root_prefix_ +
- chromeos_update_engine::kStatefulPartition +
- kConfigFilePath))) {
- LOG(INFO) << "UpdateManager Config loaded from stateful partition.";
- } else {
- store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
- }
- }
-
- bool is_oobe_enabled;
- if (!store.GetBoolean(kConfigOptsIsOOBEEnabled, &is_oobe_enabled))
- is_oobe_enabled = true; // Default value.
- var_is_oobe_enabled_.reset(
- new ConstCopyVariable<bool>(kConfigOptsIsOOBEEnabled, is_oobe_enabled));
+ var_is_oobe_enabled_.reset(new ConstCopyVariable<bool>(
+ "is_oobe_enabled", hardware_->IsOOBEEnabled()));
return true;
}