• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
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 //
16 
17 #include "update_engine/update_manager/real_config_provider.h"
18 
19 #include <base/files/file_path.h>
20 #include <base/logging.h>
21 #include <brillo/key_value_store.h>
22 
23 #include "update_engine/common/constants.h"
24 #include "update_engine/common/utils.h"
25 #include "update_engine/update_manager/generic_variables.h"
26 
27 using brillo::KeyValueStore;
28 
29 namespace {
30 
31 const char* kConfigFilePath = "/etc/update_manager.conf";
32 
33 // Config options:
34 const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled";
35 
36 }  // namespace
37 
38 namespace chromeos_update_manager {
39 
Init()40 bool RealConfigProvider::Init() {
41   KeyValueStore store;
42 
43   if (hardware_->IsNormalBootMode()) {
44     store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
45   } else {
46     if (store.Load(base::FilePath(root_prefix_ +
47                                   chromeos_update_engine::kStatefulPartition +
48                                   kConfigFilePath))) {
49       LOG(INFO) << "UpdateManager Config loaded from stateful partition.";
50     } else {
51       store.Load(base::FilePath(root_prefix_ + kConfigFilePath));
52     }
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 
64 }  // namespace chromeos_update_manager
65