| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 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 | // | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 16 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 17 | #include "update_engine/update_manager/real_config_provider.h" | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 18 |  | 
| Alex Deymo | 2b4e2a5 | 2014-09-23 12:05:56 -0700 | [diff] [blame] | 19 | #include <base/files/file_path.h> | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 20 | #include <base/logging.h> | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 21 | #include <brillo/key_value_store.h> | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 22 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 23 | #include "update_engine/common/constants.h" | 
|  | 24 | #include "update_engine/common/utils.h" | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 25 | #include "update_engine/update_manager/generic_variables.h" | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 26 |  | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 27 | using brillo::KeyValueStore; | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 28 |  | 
|  | 29 | namespace { | 
|  | 30 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 31 | const char* kConfigFilePath = "/etc/update_manager.conf"; | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 32 |  | 
|  | 33 | // Config options: | 
|  | 34 | const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled"; | 
|  | 35 |  | 
|  | 36 | }  // namespace | 
|  | 37 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 38 | namespace chromeos_update_manager { | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 39 |  | 
| Alex Deymo | 42c30c3 | 2014-04-24 18:41:18 -0700 | [diff] [blame] | 40 | bool RealConfigProvider::Init() { | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 41 | KeyValueStore store; | 
|  | 42 |  | 
|  | 43 | if (hardware_->IsNormalBootMode()) { | 
| Alex Deymo | 2b4e2a5 | 2014-09-23 12:05:56 -0700 | [diff] [blame] | 44 | store.Load(base::FilePath(root_prefix_ + kConfigFilePath)); | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 45 | } else { | 
| Alex Deymo | 2b4e2a5 | 2014-09-23 12:05:56 -0700 | [diff] [blame] | 46 | if (store.Load(base::FilePath(root_prefix_ + | 
|  | 47 | chromeos_update_engine::kStatefulPartition + | 
|  | 48 | kConfigFilePath))) { | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 49 | LOG(INFO) << "UpdateManager Config loaded from stateful partition."; | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 50 | } else { | 
| Alex Deymo | 2b4e2a5 | 2014-09-23 12:05:56 -0700 | [diff] [blame] | 51 | store.Load(base::FilePath(root_prefix_ + kConfigFilePath)); | 
| Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 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 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 64 | }  // namespace chromeos_update_manager |