From 0c328d02c1546537478ffc575eed128e69fce84a Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 28 Apr 2020 13:31:11 -0700 Subject: Add add_slot_suffix function. This function appends androidboot.slot_suffix to the value of the argument. Test: apply update Bug: 153581609 Change-Id: I28a4047b5f2051acc039084f65a71deb492d9dcb (cherry picked from commit dff80042750992ed635056cd9719481a14f93007) Merged-In: I28a4047b5f2051acc039084f65a71deb492d9dcb --- updater/install.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'updater/install.cpp') diff --git a/updater/install.cpp b/updater/install.cpp index 7608dc3cd..afa5195d0 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -852,6 +852,20 @@ Value* Tune2FsFn(const char* name, State* state, const std::vector>& argv) { + if (argv.size() != 1) { + return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1 arg, got %zu", name, argv.size()); + } + std::vector args; + if (!ReadArgs(state, argv, &args)) { + return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name); + } + const std::string& arg = args[0]; + auto updater_runtime = state->updater->GetRuntime(); + return StringValue(updater_runtime->AddSlotSuffix(arg)); +} + void RegisterInstallFunctions() { RegisterFunction("mount", MountFn); RegisterFunction("is_mounted", IsMountedFn); @@ -885,4 +899,6 @@ void RegisterInstallFunctions() { RegisterFunction("enable_reboot", EnableRebootFn); RegisterFunction("tune2fs", Tune2FsFn); + + RegisterFunction("add_slot_suffix", AddSlotSuffixFn); } -- cgit v1.2.3