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 #ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_SYSTEM_PROVIDER_H_ 18 #define UPDATE_ENGINE_UPDATE_MANAGER_REAL_SYSTEM_PROVIDER_H_ 19 20 #include <memory> 21 #include <string> 22 23 #include "update_engine/common/boot_control_interface.h" 24 #include "update_engine/common/hardware_interface.h" 25 #include "update_engine/update_manager/system_provider.h" 26 27 namespace org { 28 namespace chromium { 29 class KioskAppServiceInterfaceProxyInterface; 30 } // namespace chromium 31 } // namespace org 32 33 namespace chromeos_update_manager { 34 35 // SystemProvider concrete implementation. 36 class RealSystemProvider : public SystemProvider { 37 public: RealSystemProvider(chromeos_update_engine::HardwareInterface * hardware,chromeos_update_engine::BootControlInterface * boot_control,org::chromium::KioskAppServiceInterfaceProxyInterface * kiosk_app_proxy)38 RealSystemProvider( 39 chromeos_update_engine::HardwareInterface* hardware, 40 chromeos_update_engine::BootControlInterface* boot_control, 41 org::chromium::KioskAppServiceInterfaceProxyInterface* kiosk_app_proxy) 42 : hardware_(hardware), 43 #if USE_CHROME_KIOSK_APP 44 boot_control_(boot_control), 45 kiosk_app_proxy_(kiosk_app_proxy) { 46 } 47 #else 48 boot_control_(boot_control) { 49 } 50 #endif // USE_CHROME_KIOSK_APP 51 52 // Initializes the provider and returns whether it succeeded. 53 bool Init(); 54 var_is_normal_boot_mode()55 Variable<bool>* var_is_normal_boot_mode() override { 56 return var_is_normal_boot_mode_.get(); 57 } 58 var_is_official_build()59 Variable<bool>* var_is_official_build() override { 60 return var_is_official_build_.get(); 61 } 62 var_is_oobe_complete()63 Variable<bool>* var_is_oobe_complete() override { 64 return var_is_oobe_complete_.get(); 65 } 66 var_num_slots()67 Variable<unsigned int>* var_num_slots() override { 68 return var_num_slots_.get(); 69 } 70 var_kiosk_required_platform_version()71 Variable<std::string>* var_kiosk_required_platform_version() override { 72 return var_kiosk_required_platform_version_.get(); 73 } 74 75 private: 76 bool GetKioskAppRequiredPlatformVersion( 77 std::string* required_platform_version); 78 79 std::unique_ptr<Variable<bool>> var_is_normal_boot_mode_; 80 std::unique_ptr<Variable<bool>> var_is_official_build_; 81 std::unique_ptr<Variable<bool>> var_is_oobe_complete_; 82 std::unique_ptr<Variable<unsigned int>> var_num_slots_; 83 std::unique_ptr<Variable<std::string>> var_kiosk_required_platform_version_; 84 85 chromeos_update_engine::HardwareInterface* const hardware_; 86 chromeos_update_engine::BootControlInterface* const boot_control_; 87 #if USE_CHROME_KIOSK_APP 88 org::chromium::KioskAppServiceInterfaceProxyInterface* const kiosk_app_proxy_; 89 #endif // USE_CHROME_KIOSK_APP 90 91 DISALLOW_COPY_AND_ASSIGN(RealSystemProvider); 92 }; 93 94 } // namespace chromeos_update_manager 95 96 #endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_SYSTEM_PROVIDER_H_ 97