blob: d986b1067cc570eb96e0edeac7deb0c9e135dc73 [file] [log] [blame]
Alex Deymof9f12632014-04-17 13:51:26 -07001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Deymo63784a52014-05-28 10:46:14 -07005#include "update_engine/update_manager/real_config_provider.h"
Alex Deymof9f12632014-04-17 13:51:26 -07006
Alex Deymo2b4e2a52014-09-23 12:05:56 -07007#include <base/files/file_path.h>
Alex Deymof9f12632014-04-17 13:51:26 -07008#include <base/logging.h>
Alex Deymo2b4e2a52014-09-23 12:05:56 -07009#include <chromeos/key_value_store.h>
Alex Deymof9f12632014-04-17 13:51:26 -070010
11#include "update_engine/constants.h"
Alex Deymo63784a52014-05-28 10:46:14 -070012#include "update_engine/update_manager/generic_variables.h"
Alex Deymof9f12632014-04-17 13:51:26 -070013#include "update_engine/utils.h"
14
Alex Deymo2b4e2a52014-09-23 12:05:56 -070015using chromeos::KeyValueStore;
Alex Deymof9f12632014-04-17 13:51:26 -070016using std::string;
17
18namespace {
19
Alex Deymo63784a52014-05-28 10:46:14 -070020const char* kConfigFilePath = "/etc/update_manager.conf";
Alex Deymof9f12632014-04-17 13:51:26 -070021
22// Config options:
23const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled";
24
25} // namespace
26
Alex Deymo63784a52014-05-28 10:46:14 -070027namespace chromeos_update_manager {
Alex Deymof9f12632014-04-17 13:51:26 -070028
Alex Deymo42c30c32014-04-24 18:41:18 -070029bool RealConfigProvider::Init() {
Alex Deymof9f12632014-04-17 13:51:26 -070030 KeyValueStore store;
31
32 if (hardware_->IsNormalBootMode()) {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070033 store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
Alex Deymof9f12632014-04-17 13:51:26 -070034 } else {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070035 if (store.Load(base::FilePath(root_prefix_ +
36 chromeos_update_engine::kStatefulPartition +
37 kConfigFilePath))) {
Alex Deymo63784a52014-05-28 10:46:14 -070038 LOG(INFO) << "UpdateManager Config loaded from stateful partition.";
Alex Deymof9f12632014-04-17 13:51:26 -070039 } else {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070040 store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
Alex Deymof9f12632014-04-17 13:51:26 -070041 }
42 }
43
44 bool is_oobe_enabled;
45 if (!store.GetBoolean(kConfigOptsIsOOBEEnabled, &is_oobe_enabled))
46 is_oobe_enabled = true; // Default value.
47 var_is_oobe_enabled_.reset(
48 new ConstCopyVariable<bool>(kConfigOptsIsOOBEEnabled, is_oobe_enabled));
49
50 return true;
51}
52
Alex Deymo63784a52014-05-28 10:46:14 -070053} // namespace chromeos_update_manager