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 | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 16 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 17 | #include "update_engine/update_manager/real_system_provider.h" |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 18 | |
Gilad Arnold | 48e1361 | 2014-05-16 10:18:05 -0700 | [diff] [blame] | 19 | #include <string.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <unistd.h> |
| 23 | |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 24 | #include <string> |
| 25 | #include <vector> |
| 26 | |
| 27 | #include <base/logging.h> |
Gilad Arnold | 48e1361 | 2014-05-16 10:18:05 -0700 | [diff] [blame] | 28 | #include <base/strings/stringprintf.h> |
| 29 | #include <base/time/time.h> |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 30 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 31 | #include "update_engine/common/utils.h" |
Xiyuan Xia | 6e30bc5 | 2016-02-24 15:35:42 -0800 | [diff] [blame^] | 32 | #include "update_engine/libcros_proxy.h" |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 33 | #include "update_engine/update_manager/generic_variables.h" |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 34 | |
| 35 | using std::string; |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 36 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 37 | namespace chromeos_update_manager { |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 38 | |
Alex Deymo | 42c30c3 | 2014-04-24 18:41:18 -0700 | [diff] [blame] | 39 | bool RealSystemProvider::Init() { |
David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 40 | var_is_normal_boot_mode_.reset( |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 41 | new ConstCopyVariable<bool>("is_normal_boot_mode", |
Alex Deymo | 40d86b2 | 2015-09-03 22:27:10 -0700 | [diff] [blame] | 42 | hardware_->IsNormalBootMode())); |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 43 | |
David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 44 | var_is_official_build_.reset( |
Gilad Arnold | 48e1361 | 2014-05-16 10:18:05 -0700 | [diff] [blame] | 45 | new ConstCopyVariable<bool>("is_official_build", |
Alex Deymo | 40d86b2 | 2015-09-03 22:27:10 -0700 | [diff] [blame] | 46 | hardware_->IsOfficialBuild())); |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 47 | |
Gilad Arnold | 48e1361 | 2014-05-16 10:18:05 -0700 | [diff] [blame] | 48 | var_is_oobe_complete_.reset( |
| 49 | new CallCopyVariable<bool>( |
| 50 | "is_oobe_complete", |
| 51 | base::Bind(&chromeos_update_engine::HardwareInterface::IsOOBEComplete, |
| 52 | base::Unretained(hardware_), nullptr))); |
| 53 | |
Alex Deymo | 763e7db | 2015-08-27 21:08:08 -0700 | [diff] [blame] | 54 | var_num_slots_.reset( |
| 55 | new ConstCopyVariable<unsigned int>( |
| 56 | "num_slots", boot_control_->GetNumSlots())); |
Gilad Arnold | bfc44f7 | 2014-07-09 14:41:39 -0700 | [diff] [blame] | 57 | |
Xiyuan Xia | 6e30bc5 | 2016-02-24 15:35:42 -0800 | [diff] [blame^] | 58 | var_kiosk_required_platform_version_.reset(new CallCopyVariable<std::string>( |
| 59 | "kiosk_required_platform_version", |
| 60 | base::TimeDelta::FromHours(5), // Same as Chrome's CWS poll. |
| 61 | base::Bind(&RealSystemProvider::GetKioskAppRequiredPlatformVersion, |
| 62 | base::Unretained(this)))); |
| 63 | |
Alex Deymo | bd04b14 | 2014-03-18 15:00:05 -0700 | [diff] [blame] | 64 | return true; |
| 65 | } |
| 66 | |
Xiyuan Xia | 6e30bc5 | 2016-02-24 15:35:42 -0800 | [diff] [blame^] | 67 | std::string RealSystemProvider::GetKioskAppRequiredPlatformVersion() { |
| 68 | std::string required_platform_version; |
| 69 | |
| 70 | #if USE_LIBCROS |
| 71 | brillo::ErrorPtr error; |
| 72 | if (!libcros_proxy_->service_interface_proxy() |
| 73 | ->GetKioskAppRequiredPlatformVersion(&required_platform_version, |
| 74 | &error)) { |
| 75 | LOG(WARNING) << "Failed to get kiosk required platform version"; |
| 76 | } |
| 77 | #endif |
| 78 | |
| 79 | return required_platform_version; |
| 80 | } |
| 81 | |
Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 82 | } // namespace chromeos_update_manager |