Snap for 13025002 from 44c3563baf65b24f6647324be7a19e9114294a4b to 25Q2-release
Change-Id: I96f1a87ad3084be4ba28198bf715d52c75bca777
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index 08c8a67..db94a6f 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -648,11 +648,17 @@
return;
}
CHECK(curl_handle_);
- CHECK_EQ(curl_easy_pause(curl_handle_, CURLPAUSE_CONT), CURLE_OK);
- // Since the transfer is in progress, we need to dispatch a CurlPerformOnce()
- // now to let the connection continue, otherwise it would be called by the
- // TimeoutCallback but with a delay.
- CurlPerformOnce();
+ auto ret = curl_easy_pause(curl_handle_, CURLPAUSE_CONT);
+ if (ret != CURLE_OK) {
+ LOG(ERROR) << "Failed to unpause connection, reason: " << ret
+ << ". Terminating transfer.";
+ TerminateTransfer();
+ } else {
+ // Since the transfer is in progress, we need to dispatch a
+ // CurlPerformOnce() now to let the connection continue, otherwise it would
+ // be called by the TimeoutCallback but with a delay.
+ CurlPerformOnce();
+ }
}
// This method sets up callbacks with the MessageLoop.
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 1717dd7..84237b1 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -111,12 +111,17 @@
// 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);
+ if (dynamic_control->GetVirtualAbFeatureFlag().IsEnabled()) {
+ // 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);
+ }
}
}
diff --git a/payload_consumer/postinstall_runner_action_unittest.cc b/payload_consumer/postinstall_runner_action_unittest.cc
index 7416e66..74775ad 100644
--- a/payload_consumer/postinstall_runner_action_unittest.cc
+++ b/payload_consumer/postinstall_runner_action_unittest.cc
@@ -112,6 +112,8 @@
.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
@@ -291,6 +293,8 @@
// /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_);
@@ -302,12 +306,16 @@
}
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(),
@@ -324,6 +332,8 @@
// 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_);
@@ -334,6 +344,8 @@
}
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";
@@ -415,6 +427,8 @@
// 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));
@@ -430,6 +444,8 @@
// 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));