BootControlStub: New class used if CreateBootControl() fail.
This can happen if running update_engine on Brillo in the emulator or
other device lacking a boot_control HAL implementation. With this
change, the update_engine process continues to run but updates won't
work.
Bug: 25012817
Change-Id: I03d516c5e9a53c893c376885cd48068cd359e902
Test: update_engine no longer crashes on brilloemulator_arm.
diff --git a/real_system_state.cc b/real_system_state.cc
index 1d11090..cf904c2 100644
--- a/real_system_state.cc
+++ b/real_system_state.cc
@@ -18,8 +18,10 @@
#include <base/files/file_util.h>
#include <base/time/time.h>
+#include <brillo/make_unique_ptr.h>
#include "update_engine/boot_control.h"
+#include "update_engine/boot_control_stub.h"
#include "update_engine/constants.h"
#include "update_engine/hardware.h"
#include "update_engine/update_manager/state_factory.h"
@@ -39,8 +41,11 @@
metrics_lib_.Init();
boot_control_ = boot_control::CreateBootControl();
- if (!boot_control_)
- return false;
+ if (!boot_control_) {
+ LOG(WARNING) << "Unable to create BootControl instance, using stub "
+ << "instead. All update attempts will fail.";
+ boot_control_ = brillo::make_unique_ptr(new BootControlStub());
+ }
hardware_ = hardware::CreateHardware();
if (!hardware_) {