summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aosp/cleanup_previous_update_action.cc1
-rw-r--r--aosp/metrics_reporter_android.cc29
-rw-r--r--aosp/metrics_reporter_android.h10
-rw-r--r--aosp/update_attempter_android.cc3
-rw-r--r--common/metrics_reporter_interface.h4
-rw-r--r--common/metrics_reporter_stub.cc3
-rw-r--r--payload_consumer/filesystem_verifier_action_unittest.cc24
-rwxr-xr-xscripts/update_device.py4
8 files changed, 67 insertions, 11 deletions
diff --git a/aosp/cleanup_previous_update_action.cc b/aosp/cleanup_previous_update_action.cc
index b4475098..ae2727a8 100644
--- a/aosp/cleanup_previous_update_action.cc
+++ b/aosp/cleanup_previous_update_action.cc
@@ -207,6 +207,7 @@ void CleanupPreviousUpdateAction::CheckSlotMarkedSuccessfulOrSchedule() {
if (!kIsRecovery &&
!boot_control_->IsSlotMarkedSuccessful(boot_control_->GetCurrentSlot())) {
ScheduleWaitMarkBootSuccessful();
+ return;
}
if (metadata_device_ == nullptr) {
diff --git a/aosp/metrics_reporter_android.cc b/aosp/metrics_reporter_android.cc
index 1f8f45a6..a324fab1 100644
--- a/aosp/metrics_reporter_android.cc
+++ b/aosp/metrics_reporter_android.cc
@@ -18,6 +18,8 @@
#include <stdint.h>
+#include <algorithm>
+#include <any>
#include <memory>
#include <string>
@@ -30,6 +32,7 @@
#include <statslog.h>
#include "update_engine/common/constants.h"
+#include "update_engine/payload_consumer/install_plan.h"
using android::fs_mgr::GetPartitionGroupName;
using android::fs_mgr::LpMetadata;
@@ -48,6 +51,22 @@ constexpr auto kMetricsReporterEnumOffset = 10000;
int32_t GetStatsdEnumValue(int32_t value) {
return kMetricsReporterEnumOffset + value;
}
+
+bool IsHashTreeEnabled(
+ const chromeos_update_engine::InstallPlan* install_plan) {
+ return std::any_of(
+ install_plan->partitions.begin(),
+ install_plan->partitions.end(),
+ [](const auto& partition) { return partition.hash_tree_size > 0; });
+}
+
+bool IsFECEnabled(const chromeos_update_engine::InstallPlan* install_plan) {
+ return std::any_of(
+ install_plan->partitions.begin(),
+ install_plan->partitions.end(),
+ [](const auto& partition) { return partition.fec_size > 0; });
+}
+
} // namespace
namespace chromeos_update_engine {
@@ -55,8 +74,10 @@ namespace chromeos_update_engine {
namespace metrics {
std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
- DynamicPartitionControlInterface* dynamic_partition_control) {
- return std::make_unique<MetricsReporterAndroid>(dynamic_partition_control);
+ DynamicPartitionControlInterface* dynamic_partition_control,
+ const InstallPlan* install_plan) {
+ return std::make_unique<MetricsReporterAndroid>(dynamic_partition_control,
+ install_plan);
}
} // namespace metrics
@@ -164,7 +185,9 @@ void MetricsReporterAndroid::ReportSuccessfulUpdateMetrics(
static_cast<int32_t>(total_bytes_downloaded),
static_cast<int32_t>(download_overhead_percentage),
static_cast<int32_t>(total_duration.InMinutes()),
- static_cast<int32_t>(reboot_count));
+ static_cast<int32_t>(reboot_count),
+ IsHashTreeEnabled(install_plan_),
+ IsFECEnabled(install_plan_));
}
void MetricsReporterAndroid::ReportAbnormallyTerminatedUpdateAttemptMetrics() {
diff --git a/aosp/metrics_reporter_android.h b/aosp/metrics_reporter_android.h
index abe7c277..aeb579a1 100644
--- a/aosp/metrics_reporter_android.h
+++ b/aosp/metrics_reporter_android.h
@@ -22,14 +22,17 @@
#include "update_engine/common/error_code.h"
#include "update_engine/common/metrics_constants.h"
#include "update_engine/common/metrics_reporter_interface.h"
+#include "update_engine/payload_consumer/install_plan.h"
namespace chromeos_update_engine {
class MetricsReporterAndroid : public MetricsReporterInterface {
public:
explicit MetricsReporterAndroid(
- DynamicPartitionControlInterface* dynamic_partition_control)
- : dynamic_partition_control_(dynamic_partition_control) {}
+ DynamicPartitionControlInterface* dynamic_partition_control,
+ const InstallPlan* install_plan)
+ : dynamic_partition_control_(dynamic_partition_control),
+ install_plan_(install_plan) {}
~MetricsReporterAndroid() override = default;
@@ -93,7 +96,8 @@ class MetricsReporterAndroid : public MetricsReporterInterface {
bool has_time_restriction_policy, int time_to_update_days) override {}
private:
- DynamicPartitionControlInterface* dynamic_partition_control_;
+ DynamicPartitionControlInterface* dynamic_partition_control_{};
+ const InstallPlan* install_plan_{};
DISALLOW_COPY_AND_ASSIGN(MetricsReporterAndroid);
};
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 1080acba..ba61f255 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -64,7 +64,6 @@ using base::Bind;
using base::Time;
using base::TimeDelta;
using base::TimeTicks;
-using std::shared_ptr;
using std::string;
using std::vector;
using update_engine::UpdateEngineStatus;
@@ -143,7 +142,7 @@ UpdateAttempterAndroid::UpdateAttempterAndroid(
processor_(new ActionProcessor()),
clock_(new Clock()) {
metrics_reporter_ = metrics::CreateMetricsReporter(
- boot_control_->GetDynamicPartitionControl());
+ boot_control_->GetDynamicPartitionControl(), &install_plan_);
network_selector_ = network::CreateNetworkSelector();
}
diff --git a/common/metrics_reporter_interface.h b/common/metrics_reporter_interface.h
index 29d13faf..a7a91a54 100644
--- a/common/metrics_reporter_interface.h
+++ b/common/metrics_reporter_interface.h
@@ -26,6 +26,7 @@
#include "update_engine/common/dynamic_partition_control_interface.h"
#include "update_engine/common/error_code.h"
#include "update_engine/common/metrics_constants.h"
+#include "update_engine/payload_consumer/install_plan.h"
namespace chromeos_update_engine {
@@ -237,7 +238,8 @@ class MetricsReporterInterface {
namespace metrics {
std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
- DynamicPartitionControlInterface* dynamic_partition_control);
+ DynamicPartitionControlInterface* dynamic_partition_control,
+ const InstallPlan* install_plan);
} // namespace metrics
diff --git a/common/metrics_reporter_stub.cc b/common/metrics_reporter_stub.cc
index 96b519bf..61559d95 100644
--- a/common/metrics_reporter_stub.cc
+++ b/common/metrics_reporter_stub.cc
@@ -23,7 +23,8 @@ namespace chromeos_update_engine {
namespace metrics {
std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
- DynamicPartitionControlInterface* dynamic_partition_control) {
+ DynamicPartitionControlInterface* dynamic_partition_control,
+ const InstallPlan* install_plan) {
return std::make_unique<MetricsReporterStub>();
}
diff --git a/payload_consumer/filesystem_verifier_action_unittest.cc b/payload_consumer/filesystem_verifier_action_unittest.cc
index 2cad5232..c1006842 100644
--- a/payload_consumer/filesystem_verifier_action_unittest.cc
+++ b/payload_consumer/filesystem_verifier_action_unittest.cc
@@ -26,8 +26,8 @@
#include <brillo/message_loops/message_loop_utils.h>
#include <brillo/secure_blob.h>
#include <gtest/gtest.h>
+#include <libsnapshot/snapshot_writer.h>
-#include "gmock/gmock-actions.h"
#include "update_engine/common/dynamic_partition_control_stub.h"
#include "update_engine/common/hash_calculator.h"
#include "update_engine/common/mock_dynamic_partition_control.h"
@@ -463,4 +463,26 @@ TEST_F(FilesystemVerifierActionTest, RunWithVABCNoVerity) {
ASSERT_EQ(actual_read_size, part.target_size);
}
+TEST_F(FilesystemVerifierActionTest, ReadAfterWrite) {
+ constexpr auto BLOCK_SIZE = 4096;
+ ScopedTempFile cow_device_file("cow_device.XXXXXX", true);
+ android::snapshot::CompressedSnapshotWriter snapshot_writer{
+ {.block_size = BLOCK_SIZE}};
+ snapshot_writer.SetCowDevice(android::base::unique_fd{cow_device_file.fd()});
+ snapshot_writer.Initialize();
+ std::vector<unsigned char> buffer;
+ buffer.resize(BLOCK_SIZE);
+ std::fill(buffer.begin(), buffer.end(), 123);
+
+ ASSERT_TRUE(snapshot_writer.AddRawBlocks(0, buffer.data(), buffer.size()));
+ ASSERT_TRUE(snapshot_writer.Finalize());
+ auto cow_reader = snapshot_writer.OpenReader();
+ ASSERT_NE(cow_reader, nullptr);
+ ASSERT_TRUE(snapshot_writer.AddRawBlocks(1, buffer.data(), buffer.size()));
+ ASSERT_TRUE(snapshot_writer.AddRawBlocks(2, buffer.data(), buffer.size()));
+ ASSERT_TRUE(snapshot_writer.Finalize());
+ cow_reader = snapshot_writer.OpenReader();
+ ASSERT_NE(cow_reader, nullptr);
+}
+
} // namespace chromeos_update_engine
diff --git a/scripts/update_device.py b/scripts/update_device.py
index 074b91d6..b784b1bc 100755
--- a/scripts/update_device.py
+++ b/scripts/update_device.py
@@ -428,6 +428,8 @@ def main():
help='Update with the secondary payload in the package.')
parser.add_argument('--no-slot-switch', action='store_true',
help='Do not perform slot switch after the update.')
+ parser.add_argument('--no-postinstall', action='store_true',
+ help='Do not execute postinstall scripts after the update.')
parser.add_argument('--allocate_only', action='store_true',
help='Allocate space for this OTA, instead of actually \
applying the OTA.')
@@ -472,6 +474,8 @@ def main():
if args.no_slot_switch:
args.extra_headers += "\nSWITCH_SLOT_ON_REBOOT=0"
+ if args.no_postinstall:
+ args.extra_headers += "\nRUN_POST_INSTALL=0"
with zipfile.ZipFile(args.otafile) as zfp:
CARE_MAP_ENTRY_NAME = "care_map.pb"