summaryrefslogtreecommitdiffstats
path: root/updater/install.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2017-05-10 23:11:35 +0200
committerEthan Yonker <dees_troy@teamw.in>2017-05-10 23:11:35 +0200
commit84d61ce31c48d0da495617f64edb724eeb36d3bc (patch)
tree443d459f7e0e3b0b7080522891dd1b92dfb2e6c7 /updater/install.cpp
parentAdopted Storage: backup keys but do not wipe them (diff)
parentAdd a checker for signature boundary in verifier am: 54ea136fde am: 0a34b17c8b am: fb80b4f72d am: d3d5e54a45 am: 6ea9888d51 am: a055eb93c3 am: 15ca2a4763 am: ca50d7b66a am: 64f0de7a13 am: e4ec60e045 (diff)
downloadandroid_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.gz
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.bz2
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.lz
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.xz
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.tar.zst
android_bootable_recovery-84d61ce31c48d0da495617f64edb724eeb36d3bc.zip
Diffstat (limited to 'updater/install.cpp')
-rw-r--r--updater/install.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/updater/install.cpp b/updater/install.cpp
index d4ae64ee5..1c7964053 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -35,8 +35,10 @@
#include <inttypes.h>
#include <memory>
+#include <string>
#include <vector>
+#include <android-base/file.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
#include <android-base/stringprintf.h>
@@ -970,7 +972,6 @@ Value* GetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
return StringValue(strdup(value));
}
-
// file_getprop(file, key)
//
// interprets 'file' as a getprop-style file (key=value pairs, one
@@ -1432,6 +1433,31 @@ Value* ReadFileFn(const char* name, State* state, int argc, Expr* argv[]) {
return v;
}
+// write_value(value, filename)
+// Writes 'value' to 'filename'.
+// Example: write_value("960000", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq")
+Value* WriteValueFn(const char* name, State* state, int argc, Expr* argv[]) {
+ if (argc != 2) {
+ return ErrorAbort(state, kArgsParsingFailure, "%s() expects 2 args, got %d", name, argc);
+ }
+
+ char* value;
+ char* filename;
+ if (ReadArgs(state, argv, 2, &value, &filename) < 0) {
+ return ErrorAbort(state, kArgsParsingFailure, "%s(): Failed to parse the argument(s)",
+ name);
+ }
+
+ bool ret = android::base::WriteStringToFile(value, filename);
+ if (!ret) {
+ printf("%s: Failed to write to \"%s\": %s\n", name, filename, strerror(errno));
+ }
+
+ free(value);
+ free(filename);
+ return StringValue(strdup(ret ? "t" : ""));
+}
+
// Immediately reboot the device. Recovery is not finished normally,
// so if you reboot into recovery it will re-start applying the
// current package (because nothing has cleared the copy of the
@@ -1638,6 +1664,7 @@ void RegisterInstallFunctions() {
RegisterFunction("read_file", ReadFileFn);
RegisterFunction("sha1_check", Sha1CheckFn);
RegisterFunction("rename", RenameFn);
+ RegisterFunction("write_value", WriteValueFn);
RegisterFunction("wipe_cache", WipeCacheFn);