Merge cherrypicks of ['android-review.googlesource.com/3480990', 'android-review.googlesource.com/3480104'] into sparse-13018634-L50400030009417638.
SPARSE_CHANGE: If5970a9c0ab5e132a584092cb404ed32671e5d50
SPARSE_CHANGE: I590cb5b30f5bb2cc0b4b35e5bb332eccc1ff5a4a
Change-Id: I630b5c327dfefc9ee5cc3fedf765c87ce073e679
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index b46f584..943c3e4 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -1363,7 +1363,6 @@
// previous ApplyPayload() call may have requested powerwash, these
// settings would be saved in `this->install_plan_`. Inherit that setting.
install_plan_.powerwash_required = this->install_plan_.powerwash_required;
- install_plan_.switch_slot_on_reboot = true;
CHECK_NE(install_plan_.source_slot, UINT32_MAX);
CHECK_NE(install_plan_.target_slot, UINT32_MAX);
diff --git a/common/fake_boot_control.h b/common/fake_boot_control.h
index 82d4827..8a68501 100644
--- a/common/fake_boot_control.h
+++ b/common/fake_boot_control.h
@@ -40,11 +40,6 @@
dynamic_partition_control_.reset(new DynamicPartitionControlStub());
}
- void SetDynamicPartitionControl(
- std::unique_ptr<DynamicPartitionControlInterface> dynamic_control) {
- dynamic_partition_control_ = std::move(dynamic_control);
- }
-
// BootControlInterface overrides.
unsigned int GetNumSlots() const override { return num_slots_; }
BootControlInterface::Slot GetCurrentSlot() const override {
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 84237b1..da9075a 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -108,18 +108,14 @@
auto dynamic_control = boot_control_->GetDynamicPartitionControl();
CHECK(dynamic_control);
- // If we are switching slots, then we are required to MapAllPartitions,
- // as FinishUpdate() requires all partitions to be mapped.
- // And switching slots requires FinishUpdate() to be called first
- if (dynamic_control->GetVirtualAbFeatureFlag().IsEnabled()) {
+ // Mount snapshot partitions for Virtual AB Compression Compression.
+ if (dynamic_control->UpdateUsesSnapshotCompression()) {
// If we are switching slots, then we are required to MapAllPartitions,
// as FinishUpdate() requires all partitions to be mapped.
// And switching slots requires FinishUpdate() to be called first
if (!install_plan_.partitions.empty() ||
install_plan_.switch_slot_on_reboot) {
if (!dynamic_control->MapAllPartitions()) {
- LOG(ERROR) << "Failed to map all partitions, this would cause "
- "FinishUpdate to fail. Abort early.";
return CompletePostinstall(ErrorCode::kPostInstallMountError);
}
}
@@ -328,10 +324,10 @@
void PostinstallRunnerAction::OnProgressFdReady() {
char buf[1024];
- size_t bytes_read{};
+ size_t bytes_read;
do {
bytes_read = 0;
- bool eof = false;
+ bool eof;
bool ok =
utils::ReadAll(progress_fd_, buf, std::size(buf), &bytes_read, &eof);
progress_buffer_.append(buf, bytes_read);
diff --git a/payload_consumer/postinstall_runner_action_unittest.cc b/payload_consumer/postinstall_runner_action_unittest.cc
index 74775ad..028402a 100644
--- a/payload_consumer/postinstall_runner_action_unittest.cc
+++ b/payload_consumer/postinstall_runner_action_unittest.cc
@@ -44,14 +44,10 @@
#include "update_engine/common/subprocess.h"
#include "update_engine/common/test_utils.h"
#include "update_engine/common/utils.h"
-#include "update_engine/common/mock_dynamic_partition_control.h"
using brillo::MessageLoop;
using chromeos_update_engine::test_utils::ScopedLoopbackDeviceBinder;
using std::string;
-using testing::_;
-using testing::AtLeast;
-using testing::Return;
namespace chromeos_update_engine {
@@ -99,21 +95,6 @@
// stored in the "disk_ext2_unittest.img" image.
postinstall_image_ =
test_utils::GetBuildArtifactsPath("gen/disk_ext2_unittest.img");
- {
- auto mock_dynamic_control =
- std::make_unique<MockDynamicPartitionControl>();
- mock_dynamic_control_ = mock_dynamic_control.get();
- fake_boot_control_.SetDynamicPartitionControl(
- std::move(mock_dynamic_control));
- }
- ON_CALL(*mock_dynamic_control_, FinishUpdate(_))
- .WillByDefault(Return(true));
- ON_CALL(*mock_dynamic_control_, MapAllPartitions())
- .WillByDefault(Return(true));
- ON_CALL(*mock_dynamic_control_, UnmapAllPartitions())
- .WillByDefault(Return(true));
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::NONE)));
}
// Setup an action processor and run the PostinstallRunnerAction with a single
@@ -192,7 +173,6 @@
FakeBootControl fake_boot_control_;
FakeHardware fake_hardware_;
- MockDynamicPartitionControl* mock_dynamic_control_;
PostinstActionProcessorDelegate processor_delegate_;
// The PostinstallRunnerAction delegate receiving the progress updates.
@@ -293,8 +273,6 @@
// /postinst command which only exits 0.
TEST_F(PostinstallRunnerActionTest, RunAsRootSimpleTest) {
ScopedLoopbackDeviceBinder loop(postinstall_image_, false, nullptr);
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
RunPostinstallAction(loop.dev(), kPostinstallDefaultScript, false, false);
EXPECT_EQ(ErrorCode::kSuccess, processor_delegate_.code_);
@@ -306,16 +284,12 @@
}
TEST_F(PostinstallRunnerActionTest, RunAsRootRunSymlinkFileTest) {
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
ScopedLoopbackDeviceBinder loop(postinstall_image_, false, nullptr);
RunPostinstallAction(loop.dev(), "bin/postinst_link", false, false);
EXPECT_EQ(ErrorCode::kSuccess, processor_delegate_.code_);
}
TEST_F(PostinstallRunnerActionTest, RunAsRootPowerwashRequiredTest) {
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
ScopedLoopbackDeviceBinder loop(postinstall_image_, false, nullptr);
// Run a simple postinstall program but requiring a powerwash.
RunPostinstallAction(loop.dev(),
@@ -332,8 +306,6 @@
// Runs postinstall from a partition file that doesn't mount, so it should
// fail.
TEST_F(PostinstallRunnerActionTest, RunAsRootCantMountTest) {
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
RunPostinstallAction("/dev/null", kPostinstallDefaultScript, false, false);
EXPECT_EQ(ErrorCode::kPostInstallMountError, processor_delegate_.code_);
@@ -344,8 +316,6 @@
}
TEST_F(PostinstallRunnerActionTest, RunAsRootSkipOptionalPostinstallTest) {
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
ScopedLoopbackDeviceBinder loop(postinstall_image_, false, nullptr);
InstallPlan::Partition part;
part.name = "part";
@@ -427,10 +397,7 @@
// Test that we can cancel a postinstall action while it is running.
TEST_F(PostinstallRunnerActionTest, RunAsRootCancelPostinstallActionTest) {
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
ScopedLoopbackDeviceBinder loop(postinstall_image_, false, nullptr);
- EXPECT_CALL(*mock_dynamic_control_, MapAllPartitions()).Times(AtLeast(1));
// Wait for the action to start and then cancel it.
CancelWhenStarted();
@@ -444,12 +411,6 @@
// Test that we parse and process the progress reports from the progress
// file descriptor.
TEST_F(PostinstallRunnerActionTest, RunAsRootProgressUpdatesTest) {
- ON_CALL(*mock_dynamic_control_, GetVirtualAbFeatureFlag)
- .WillByDefault(Return(FeatureFlag(FeatureFlag::Value::LAUNCH)));
- EXPECT_CALL(*mock_dynamic_control_, MapAllPartitions())
- .Times(AtLeast(1))
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_dynamic_control_, FinishUpdate(_)).Times(AtLeast(1));
testing::StrictMock<MockPostinstallRunnerActionDelegate> mock_delegate_;
testing::InSequence s;
EXPECT_CALL(mock_delegate_, ProgressUpdate(0));