Use libsnapshot stub classes
... to avoid crashes in update_engine. The stub classes
does nothing but return a failure for all function
calls, and act as if Virtual A/B is not enabled.
Fixes: 148956645
Test: update_engine_unittests
Change-Id: I48206958aba8d9a71cc7cf49f6b9d5d4f1c8735d
diff --git a/dynamic_partition_control_android.cc b/dynamic_partition_control_android.cc
index a310f20..bf31244 100644
--- a/dynamic_partition_control_android.cc
+++ b/dynamic_partition_control_android.cc
@@ -35,6 +35,7 @@
#include <libavb/libavb.h>
#include <libdm/dm.h>
#include <libsnapshot/snapshot.h>
+#include <libsnapshot/snapshot_stub.h>
#include "update_engine/cleanup_previous_update_action.h"
#include "update_engine/common/boot_control_interface.h"
@@ -58,6 +59,7 @@
using android::snapshot::OptimizeSourceCopyOperation;
using android::snapshot::Return;
using android::snapshot::SnapshotManager;
+using android::snapshot::SnapshotManagerStub;
using android::snapshot::UpdateState;
namespace chromeos_update_engine {
@@ -108,8 +110,10 @@
virtual_ab_(GetFeatureFlag(kVirtualAbEnabled, kVirtualAbRetrofit)) {
if (GetVirtualAbFeatureFlag().IsEnabled()) {
snapshot_ = SnapshotManager::New();
- CHECK(snapshot_ != nullptr) << "Cannot initialize SnapshotManager.";
+ } else {
+ snapshot_ = SnapshotManagerStub::New();
}
+ CHECK(snapshot_ != nullptr) << "Cannot initialize SnapshotManager.";
}
FeatureFlag DynamicPartitionControlAndroid::GetDynamicPartitionsFeatureFlag() {