From d118833f3e55f94d1dad416c6facddb3e2d48297 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Fri, 24 May 2019 16:08:45 -0700 Subject: Implement updater runtime for dynamic partitions The simulator skips executing the operations for dynamic partitions, and will use the logical images under target_files/IMAGES directly. (Similar to the targets without DAP enabled) Bug: 131911365 Test: run update on cuttlefish, run simulator Change-Id: Id318d97ece4560df9f20dc5cabeb8b2e261bdf9c --- updater/simulator_runtime.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'updater/simulator_runtime.cpp') diff --git a/updater/simulator_runtime.cpp b/updater/simulator_runtime.cpp index c3b3d951c..c8718c71a 100644 --- a/updater/simulator_runtime.cpp +++ b/updater/simulator_runtime.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include #include #include @@ -95,3 +97,32 @@ bool SimulatorRuntime::WriteStringToFile(const std::string_view content, LOG(INFO) << "SKip writing " << content.size() << " bytes to file " << filename; return true; } + +bool SimulatorRuntime::MapPartitionOnDeviceMapper(const std::string& partition_name, + std::string* path) { + *path = partition_name; + return true; +} + +bool SimulatorRuntime::UnmapPartitionOnDeviceMapper(const std::string& partition_name) { + LOG(INFO) << "Skip unmapping " << partition_name; + return true; +} + +bool SimulatorRuntime::UpdateDynamicPartitions(const std::string_view op_list_value) { + const std::unordered_set commands{ + "resize", "remove", "add", "move", + "add_group", "resize_group", "remove_group", "remove_all_groups", + }; + + std::vector lines = android::base::Split(std::string(op_list_value), "\n"); + for (const auto& line : lines) { + if (line.empty() || line[0] == '#') continue; + auto tokens = android::base::Split(line, " "); + if (commands.find(tokens[0]) == commands.end()) { + LOG(ERROR) << "Unknown operation in op_list: " << line; + return false; + } + } + return true; +} -- cgit v1.2.3