blob: 171332041794f53a06f6168bf54937b849b7b66c [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Alex Deymof9f12632014-04-17 13:51:26 -070016
Alex Deymo63784a52014-05-28 10:46:14 -070017#include "update_engine/update_manager/real_config_provider.h"
Alex Deymof9f12632014-04-17 13:51:26 -070018
Alex Deymo2b4e2a52014-09-23 12:05:56 -070019#include <base/files/file_path.h>
Alex Deymof9f12632014-04-17 13:51:26 -070020#include <base/logging.h>
Alex Deymo2b4e2a52014-09-23 12:05:56 -070021#include <chromeos/key_value_store.h>
Alex Deymof9f12632014-04-17 13:51:26 -070022
23#include "update_engine/constants.h"
Alex Deymo63784a52014-05-28 10:46:14 -070024#include "update_engine/update_manager/generic_variables.h"
Alex Deymof9f12632014-04-17 13:51:26 -070025#include "update_engine/utils.h"
26
Alex Deymo2b4e2a52014-09-23 12:05:56 -070027using chromeos::KeyValueStore;
Alex Deymof9f12632014-04-17 13:51:26 -070028
29namespace {
30
Alex Deymo63784a52014-05-28 10:46:14 -070031const char* kConfigFilePath = "/etc/update_manager.conf";
Alex Deymof9f12632014-04-17 13:51:26 -070032
33// Config options:
34const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled";
35
36} // namespace
37
Alex Deymo63784a52014-05-28 10:46:14 -070038namespace chromeos_update_manager {
Alex Deymof9f12632014-04-17 13:51:26 -070039
Alex Deymo42c30c32014-04-24 18:41:18 -070040bool RealConfigProvider::Init() {
Alex Deymof9f12632014-04-17 13:51:26 -070041 KeyValueStore store;
42
43 if (hardware_->IsNormalBootMode()) {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070044 store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
Alex Deymof9f12632014-04-17 13:51:26 -070045 } else {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070046 if (store.Load(base::FilePath(root_prefix_ +
47 chromeos_update_engine::kStatefulPartition +
48 kConfigFilePath))) {
Alex Deymo63784a52014-05-28 10:46:14 -070049 LOG(INFO) << "UpdateManager Config loaded from stateful partition.";
Alex Deymof9f12632014-04-17 13:51:26 -070050 } else {
Alex Deymo2b4e2a52014-09-23 12:05:56 -070051 store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
Alex Deymof9f12632014-04-17 13:51:26 -070052 }
53 }
54
55 bool is_oobe_enabled;
56 if (!store.GetBoolean(kConfigOptsIsOOBEEnabled, &is_oobe_enabled))
57 is_oobe_enabled = true; // Default value.
58 var_is_oobe_enabled_.reset(
59 new ConstCopyVariable<bool>(kConfigOptsIsOOBEEnabled, is_oobe_enabled));
60
61 return true;
62}
63
Alex Deymo63784a52014-05-28 10:46:14 -070064} // namespace chromeos_update_manager