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 Deymo | 2b4e2a5 | 2014-09-23 12:05:56 -0700 | [diff] [blame] | 21 | #include <chromeos/key_value_store.h> |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 22 | |
| 23 | #include "update_engine/constants.h" |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 24 | #include "update_engine/update_manager/generic_variables.h" |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 25 | #include "update_engine/utils.h" |
| 26 | |
Alex Deymo | 2b4e2a5 | 2014-09-23 12:05:56 -0700 | [diff] [blame] | 27 | using chromeos::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 |