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/cleanup_previous_update_action.cc b/cleanup_previous_update_action.cc
index 26cc6be..6490ca8 100644
--- a/cleanup_previous_update_action.cc
+++ b/cleanup_previous_update_action.cc
@@ -30,7 +30,7 @@
#include "update_engine/common/utils.h"
#include "update_engine/payload_consumer/delta_performer.h"
-using android::snapshot::SnapshotManager;
+using android::snapshot::ISnapshotManager;
using android::snapshot::SnapshotMergeStats;
using android::snapshot::UpdateState;
using brillo::MessageLoop;
@@ -55,7 +55,7 @@
CleanupPreviousUpdateAction::CleanupPreviousUpdateAction(
PrefsInterface* prefs,
BootControlInterface* boot_control,
- android::snapshot::SnapshotManager* snapshot,
+ android::snapshot::ISnapshotManager* snapshot,
CleanupPreviousUpdateActionDelegateInterface* delegate)
: prefs_(prefs),
boot_control_(boot_control),
@@ -64,7 +64,7 @@
running_(false),
cancel_failed_(false),
last_percentage_(0),
- merge_stats_(SnapshotMergeStats::GetInstance(*snapshot)) {}
+ merge_stats_(nullptr) {}
void CleanupPreviousUpdateAction::PerformAction() {
ResumeAction();
@@ -110,8 +110,10 @@
processor_->ActionComplete(this, ErrorCode::kSuccess);
return;
}
- // SnapshotManager is only available on VAB devices.
- CHECK(snapshot_);
+ // SnapshotManager must be available on VAB devices.
+ CHECK(snapshot_ != nullptr);
+ merge_stats_ = snapshot_->GetSnapshotMergeStatsInstance();
+ CHECK(merge_stats_ != nullptr);
WaitBootCompletedOrSchedule();
}