Sanity check that no downgrade package on launch VAB device.
am: 6e0d0ef979
Change-Id: Icf916a3fffe4a3e8267f45345fbe92250ab3cd32
diff --git a/dynamic_partition_control_android.cc b/dynamic_partition_control_android.cc
index 0c1f0d3..e194670 100644
--- a/dynamic_partition_control_android.cc
+++ b/dynamic_partition_control_android.cc
@@ -369,6 +369,13 @@
return PrepareSnapshotPartitionsForUpdate(
source_slot, target_slot, manifest);
}
+
+ if (GetVirtualAbFeatureFlag().IsLaunch() && !target_supports_snapshot_) {
+ LOG(ERROR) << "Cannot downgrade to a build that does not support "
+ << "snapshots because this device launches with Virtual A/B.";
+ return false;
+ }
+
if (!snapshot_->CancelUpdate()) {
LOG(ERROR) << "Cannot cancel previous update.";
return false;
diff --git a/dynamic_partition_control_interface.h b/dynamic_partition_control_interface.h
index 9c4c2e8..9c18973 100644
--- a/dynamic_partition_control_interface.h
+++ b/dynamic_partition_control_interface.h
@@ -36,6 +36,7 @@
constexpr explicit FeatureFlag(Value value) : value_(value) {}
constexpr bool IsEnabled() const { return value_ != Value::NONE; }
constexpr bool IsRetrofit() const { return value_ == Value::RETROFIT; }
+ constexpr bool IsLaunch() const { return value_ == Value::LAUNCH; }
private:
Value value_;