summaryrefslogtreecommitdiff
path: root/aosp
diff options
context:
space:
mode:
Diffstat (limited to 'aosp')
-rw-r--r--aosp/apex_handler_android.cc21
-rw-r--r--aosp/apex_handler_android.h10
-rw-r--r--aosp/apex_handler_android_unittest.cc39
-rw-r--r--aosp/cleanup_previous_update_action.cc4
-rw-r--r--aosp/daemon_state_android.cc11
-rw-r--r--aosp/dynamic_partition_control_android.cc13
-rw-r--r--aosp/dynamic_partition_control_android_unittest.cc4
7 files changed, 82 insertions, 20 deletions
diff --git a/aosp/apex_handler_android.cc b/aosp/apex_handler_android.cc
index 38ec410b..8beef966 100644
--- a/aosp/apex_handler_android.cc
+++ b/aosp/apex_handler_android.cc
@@ -14,10 +14,13 @@
// limitations under the License.
//
+#include <memory>
#include <utility>
#include <base/files/file_util.h>
+#include <ApexProperties.sysprop.h>
+
#include "update_engine/aosp/apex_handler_android.h"
#include "update_engine/common/utils.h"
@@ -44,6 +47,14 @@ android::apex::CompressedApexInfoList CreateCompressedApexInfoList(
} // namespace
+std::unique_ptr<ApexHandlerInterface> CreateApexHandler() {
+ if (android::sysprop::ApexProperties::updatable().value_or(false)) {
+ return std::make_unique<ApexHandlerAndroid>();
+ } else {
+ return std::make_unique<FlattenedApexHandlerAndroid>();
+ }
+}
+
android::base::Result<uint64_t> ApexHandlerAndroid::CalculateSize(
const std::vector<ApexInfo>& apex_infos) const {
// We might not need to decompress every APEX. Communicate with apexd to get
@@ -86,4 +97,14 @@ android::sp<android::apex::IApexService> ApexHandlerAndroid::GetApexService()
return android::interface_cast<android::apex::IApexService>(binder);
}
+android::base::Result<uint64_t> FlattenedApexHandlerAndroid::CalculateSize(
+ const std::vector<ApexInfo>& apex_infos) const {
+ return 0;
+}
+
+bool FlattenedApexHandlerAndroid::AllocateSpace(
+ const std::vector<ApexInfo>& apex_infos) const {
+ return true;
+}
+
} // namespace chromeos_update_engine
diff --git a/aosp/apex_handler_android.h b/aosp/apex_handler_android.h
index 00f3a80b..767f5618 100644
--- a/aosp/apex_handler_android.h
+++ b/aosp/apex_handler_android.h
@@ -17,6 +17,7 @@
#ifndef SYSTEM_UPDATE_ENGINE_AOSP_APEX_HANDLER_ANDROID_H_
#define SYSTEM_UPDATE_ENGINE_AOSP_APEX_HANDLER_ANDROID_H_
+#include <memory>
#include <string>
#include <vector>
@@ -28,6 +29,8 @@
namespace chromeos_update_engine {
+std::unique_ptr<ApexHandlerInterface> CreateApexHandler();
+
class ApexHandlerAndroid : virtual public ApexHandlerInterface {
public:
android::base::Result<uint64_t> CalculateSize(
@@ -38,6 +41,13 @@ class ApexHandlerAndroid : virtual public ApexHandlerInterface {
android::sp<android::apex::IApexService> GetApexService() const;
};
+class FlattenedApexHandlerAndroid : virtual public ApexHandlerInterface {
+ public:
+ android::base::Result<uint64_t> CalculateSize(
+ const std::vector<ApexInfo>& apex_infos) const;
+ bool AllocateSpace(const std::vector<ApexInfo>& apex_infos) const;
+};
+
} // namespace chromeos_update_engine
#endif // SYSTEM_UPDATE_ENGINE_AOSP_APEX_HANDLER_ANDROID_H_
diff --git a/aosp/apex_handler_android_unittest.cc b/aosp/apex_handler_android_unittest.cc
index 981ae9dd..847ccaad 100644
--- a/aosp/apex_handler_android_unittest.cc
+++ b/aosp/apex_handler_android_unittest.cc
@@ -41,7 +41,7 @@ ApexInfo CreateApexInfo(const std::string& package_name,
return std::move(result);
}
-TEST(ApexHandlerAndroidTest, CalculateSize) {
+TEST(ApexHandlerAndroidTest, CalculateSizeUpdatableApex) {
ApexHandlerAndroid apex_handler;
std::vector<ApexInfo> apex_infos;
ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1);
@@ -52,10 +52,10 @@ TEST(ApexHandlerAndroidTest, CalculateSize) {
apex_infos.push_back(uncompressed_apex);
auto result = apex_handler.CalculateSize(apex_infos);
ASSERT_TRUE(result.ok());
- EXPECT_EQ(*result, 3u);
+ ASSERT_EQ(*result, 3u);
}
-TEST(ApexHandlerAndroidTest, AllocateSpace) {
+TEST(ApexHandlerAndroidTest, AllocateSpaceUpdatableApex) {
ApexHandlerAndroid apex_handler;
std::vector<ApexInfo> apex_infos;
ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1);
@@ -64,10 +64,39 @@ TEST(ApexHandlerAndroidTest, AllocateSpace) {
apex_infos.push_back(compressed_apex_1);
apex_infos.push_back(compressed_apex_2);
apex_infos.push_back(uncompressed_apex);
- EXPECT_TRUE(apex_handler.AllocateSpace(apex_infos));
+ ASSERT_TRUE(apex_handler.AllocateSpace(apex_infos));
// Should be able to pass empty list
- EXPECT_TRUE(apex_handler.AllocateSpace({}));
+ ASSERT_TRUE(apex_handler.AllocateSpace({}));
+}
+
+TEST(ApexHandlerAndroidTest, CalculateSizeFlattenedApex) {
+ FlattenedApexHandlerAndroid apex_handler;
+ std::vector<ApexInfo> apex_infos;
+ ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1);
+ ApexInfo compressed_apex_2 = CreateApexInfo("sample2", 2, true, 2);
+ ApexInfo uncompressed_apex = CreateApexInfo("uncompressed", 1, false, 4);
+ apex_infos.push_back(compressed_apex_1);
+ apex_infos.push_back(compressed_apex_2);
+ apex_infos.push_back(uncompressed_apex);
+ auto result = apex_handler.CalculateSize(apex_infos);
+ ASSERT_TRUE(result.ok());
+ ASSERT_EQ(*result, 0u);
+}
+
+TEST(ApexHandlerAndroidTest, AllocateSpaceFlattenedApex) {
+ FlattenedApexHandlerAndroid apex_handler;
+ std::vector<ApexInfo> apex_infos;
+ ApexInfo compressed_apex_1 = CreateApexInfo("sample1", 1, true, 1);
+ ApexInfo compressed_apex_2 = CreateApexInfo("sample2", 2, true, 2);
+ ApexInfo uncompressed_apex = CreateApexInfo("uncompressed", 1, false, 4);
+ apex_infos.push_back(compressed_apex_1);
+ apex_infos.push_back(compressed_apex_2);
+ apex_infos.push_back(uncompressed_apex);
+ ASSERT_TRUE(apex_handler.AllocateSpace(apex_infos));
+
+ // Should be able to pass empty list
+ ASSERT_TRUE(apex_handler.AllocateSpace({}));
}
} // namespace chromeos_update_engine
diff --git a/aosp/cleanup_previous_update_action.cc b/aosp/cleanup_previous_update_action.cc
index 68954f6f..dde6b89a 100644
--- a/aosp/cleanup_previous_update_action.cc
+++ b/aosp/cleanup_previous_update_action.cc
@@ -324,6 +324,7 @@ void CleanupPreviousUpdateAction::WaitForMergeOrSchedule() {
case UpdateState::MergeFailed: {
LOG(ERROR) << "Merge failed. Device may be corrupted.";
+ merge_stats_->set_merge_failure_code(snapshot_->ReadMergeFailureCode());
processor_->ActionComplete(this, ErrorCode::kDeviceCorrupted);
return;
}
@@ -492,7 +493,8 @@ void CleanupPreviousUpdateAction::ReportMergeStats() {
report.total_cow_size_bytes(),
report.estimated_cow_size_bytes(),
report.boot_complete_time_ms(),
- report.boot_complete_to_merge_start_time_ms());
+ report.boot_complete_to_merge_start_time_ms(),
+ static_cast<int32_t>(report.merge_failure_code()));
#endif
}
diff --git a/aosp/daemon_state_android.cc b/aosp/daemon_state_android.cc
index fc89d73e..da49080c 100644
--- a/aosp/daemon_state_android.cc
+++ b/aosp/daemon_state_android.cc
@@ -65,12 +65,11 @@ bool DaemonStateAndroid::Initialize() {
certificate_checker_->Init();
// Initialize the UpdateAttempter before the UpdateManager.
- update_attempter_.reset(
- new UpdateAttempterAndroid(this,
- prefs_.get(),
- boot_control_.get(),
- hardware_.get(),
- std::make_unique<ApexHandlerAndroid>()));
+ update_attempter_.reset(new UpdateAttempterAndroid(this,
+ prefs_.get(),
+ boot_control_.get(),
+ hardware_.get(),
+ CreateApexHandler()));
return true;
}
diff --git a/aosp/dynamic_partition_control_android.cc b/aosp/dynamic_partition_control_android.cc
index ab349a82..538b57ce 100644
--- a/aosp/dynamic_partition_control_android.cc
+++ b/aosp/dynamic_partition_control_android.cc
@@ -1116,9 +1116,9 @@ DynamicPartitionControlAndroid::GetPartitionDevice(
if (UpdateUsesSnapshotCompression() && slot != current_slot &&
IsDynamicPartition(partition_name, slot)) {
return {
- {.mountable_device_path = base::FilePath{std::string{VABC_DEVICE_DIR}}
- .Append(partition_name_suffix)
- .value(),
+ {.readonly_device_path = base::FilePath{std::string{VABC_DEVICE_DIR}}
+ .Append(partition_name_suffix)
+ .value(),
.is_dynamic = true}};
}
@@ -1137,7 +1137,7 @@ DynamicPartitionControlAndroid::GetPartitionDevice(
&device)) {
case DynamicPartitionDeviceStatus::SUCCESS:
return {{.rw_device_path = device,
- .mountable_device_path = device,
+ .readonly_device_path = device,
.is_dynamic = true}};
case DynamicPartitionDeviceStatus::TRY_STATIC:
@@ -1155,7 +1155,7 @@ DynamicPartitionControlAndroid::GetPartitionDevice(
}
return {{.rw_device_path = static_path,
- .mountable_device_path = static_path,
+ .readonly_device_path = static_path,
.is_dynamic = false}};
}
@@ -1470,7 +1470,8 @@ bool DynamicPartitionControlAndroid::IsDynamicPartition(
}
bool DynamicPartitionControlAndroid::UpdateUsesSnapshotCompression() {
- return snapshot_->UpdateUsesCompression();
+ return GetVirtualAbFeatureFlag().IsEnabled() &&
+ snapshot_->UpdateUsesCompression();
}
} // namespace chromeos_update_engine
diff --git a/aosp/dynamic_partition_control_android_unittest.cc b/aosp/dynamic_partition_control_android_unittest.cc
index 0bb8df7a..6f1d4ef8 100644
--- a/aosp/dynamic_partition_control_android_unittest.cc
+++ b/aosp/dynamic_partition_control_android_unittest.cc
@@ -431,7 +431,7 @@ TEST_P(DynamicPartitionControlAndroidTestP, GetMountableDevicePath) {
auto device_info =
dynamicControl().GetPartitionDevice("system", target(), source(), false);
ASSERT_TRUE(device_info.has_value());
- ASSERT_EQ(device_info->mountable_device_path, device);
+ ASSERT_EQ(device_info->readonly_device_path, device);
}
TEST_P(DynamicPartitionControlAndroidTestP, GetMountableDevicePathVABC) {
@@ -475,7 +475,7 @@ TEST_P(DynamicPartitionControlAndroidTestP, GetMountableDevicePathVABC) {
ASSERT_TRUE(device_info.has_value());
base::FilePath vabc_device_dir{
std::string{DynamicPartitionControlAndroid::VABC_DEVICE_DIR}};
- ASSERT_EQ(device_info->mountable_device_path,
+ ASSERT_EQ(device_info->readonly_device_path,
vabc_device_dir.Append(T("system")).value());
}