blob: ac334c4b940e37f75cf423a5dfac803404f82b8a [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 -070016
17namespace {
18
Alex Deymo63784a52014-05-28 10:46:14 -070019const char* kConfigFilePath = "/etc/update_manager.conf";
Alex Deymof9f12632014-04-17 13:51:26 -070020
21// Config options:
22const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled";
23
24} // namespace
25
Alex Deymo63784a52014-05-28 10:46:14 -070026namespace chromeos_update_manager {
Alex Deymof9f12632014-04-17 13:51:26 -070027
Alex Deymo42c30c32014-04-24 18:41:18 -070028bool RealConfigProvider::Init() {
Alex Deymof9f12632014-04-17 13:51:26 -070029 KeyValueStore store;
30
31 if (hardware_->IsNormalBootMode()) {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070032 store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
Alex Deymof9f12632014-04-17 13:51:26 -070033 } else {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070034 if (store.Load(base::FilePath(root_prefix_ +
35 chromeos_update_engine::kStatefulPartition +
36 kConfigFilePath))) {
Alex Deymo63784a52014-05-28 10:46:14 -070037 LOG(INFO) << "UpdateManager Config loaded from stateful partition.";
Alex Deymof9f12632014-04-17 13:51:26 -070038 } else {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070039 store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
Alex Deymof9f12632014-04-17 13:51:26 -070040 }
41 }
42
43 bool is_oobe_enabled;
44 if (!store.GetBoolean(kConfigOptsIsOOBEEnabled, &is_oobe_enabled))
45 is_oobe_enabled = true; // Default value.
46 var_is_oobe_enabled_.reset(
47 new ConstCopyVariable<bool>(kConfigOptsIsOOBEEnabled, is_oobe_enabled));
48
49 return true;
50}
51
Alex Deymo63784a52014-05-28 10:46:14 -070052} // namespace chromeos_update_manager