aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2013-05-13 16:47:14 -0700
committerKoushik Dutta <koushd@gmail.com>2013-05-13 16:47:14 -0700
commitc6834e32a0bfef51cc24d86d4955ffe078d2f746 (patch)
tree454c570b889fc7407683ffd770f0250f26b69bba
parentabc56ea91d926d80e15146e561f4414d207d22ee (diff)
downloadbootable_recovery-c6834e32a0bfef51cc24d86d4955ffe078d2f746.zip
bootable_recovery-c6834e32a0bfef51cc24d86d4955ffe078d2f746.tar.gz
bootable_recovery-c6834e32a0bfef51cc24d86d4955ffe078d2f746.tar.bz2
add getprop
Change-Id: Id7a87626d2351d49750e9982d6f81d2646d9d36d
-rw-r--r--Android.mk5
-rw-r--r--prop.c68
-rw-r--r--recovery.c2
-rw-r--r--setprop.c18
4 files changed, 73 insertions, 20 deletions
diff --git a/Android.mk b/Android.mk
index 28605e5..2cdf3ac 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,9 +14,10 @@ LOCAL_SRC_FILES := \
extendedcommands.c \
nandroid.c \
../../system/core/toolbox/reboot.c \
+ ../../system/core/toolbox/dynarray.c \
firmware.c \
edifyscripting.c \
- setprop.c \
+ prop.c \
default_recovery_ui.c \
adb_install.c \
verifier.c
@@ -105,7 +106,7 @@ LOCAL_C_INCLUDES += system/extras/ext4_utils
include $(BUILD_EXECUTABLE)
-RECOVERY_LINKS := bu make_ext4fs edify busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid reboot volume setprop dedupe minizip
+RECOVERY_LINKS := bu make_ext4fs edify busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid reboot volume setprop getprop dedupe minizip
# nc is provided by external/netcat
RECOVERY_SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(RECOVERY_LINKS))
diff --git a/prop.c b/prop.c
new file mode 100644
index 0000000..d80baa9
--- /dev/null
+++ b/prop.c
@@ -0,0 +1,68 @@
+#include <stdio.h>
+
+#include <cutils/properties.h>
+#include <sys/system_properties.h>
+#include "../../system/core/toolbox/dynarray.h"
+
+int setprop_main(int argc, char *argv[])
+{
+ if(argc != 3) {
+ fprintf(stderr,"usage: setprop <key> <value>\n");
+ return 1;
+ }
+
+ if(property_set(argv[1], argv[2])){
+ fprintf(stderr,"could not set property\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static void record_prop(const char* key, const char* name, void* opaque)
+{
+ strlist_t* list = opaque;
+ char temp[PROP_VALUE_MAX + PROP_NAME_MAX + 16];
+ snprintf(temp, sizeof temp, "[%s]: [%s]", key, name);
+ strlist_append_dup(list, temp);
+}
+
+static void list_properties(void)
+{
+ strlist_t list[1] = { STRLIST_INITIALIZER };
+
+ /* Record properties in the string list */
+ (void)property_list(record_prop, list);
+
+ /* Sort everything */
+ strlist_sort(list);
+
+ /* print everything */
+ STRLIST_FOREACH(list, str, printf("%s\n", str));
+
+ /* voila */
+ strlist_done(list);
+}
+
+int __system_property_wait(prop_info *pi);
+
+int getprop_main(int argc, char *argv[])
+{
+ int n = 0;
+
+ if (argc == 1) {
+ list_properties();
+ } else {
+ char value[PROPERTY_VALUE_MAX];
+ char *default_value;
+ if(argc > 2) {
+ default_value = argv[2];
+ } else {
+ default_value = "";
+ }
+
+ property_get(argv[1], value, default_value);
+ printf("%s\n", value);
+ }
+ return 0;
+}
diff --git a/recovery.c b/recovery.c
index 72ea381..6778ac9 100644
--- a/recovery.c
+++ b/recovery.c
@@ -835,6 +835,8 @@ main(int argc, char **argv) {
}
if (strstr(argv[0], "setprop"))
return setprop_main(argc, argv);
+ if (strstr(argv[0], "getprop"))
+ return getprop_main(argc, argv);
return busybox_driver(argc, argv);
}
__system("/sbin/postrecoveryboot.sh");
diff --git a/setprop.c b/setprop.c
deleted file mode 100644
index 63ad2b4..0000000
--- a/setprop.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-
-#include <cutils/properties.h>
-
-int setprop_main(int argc, char *argv[])
-{
- if(argc != 3) {
- fprintf(stderr,"usage: setprop <key> <value>\n");
- return 1;
- }
-
- if(property_set(argv[1], argv[2])){
- fprintf(stderr,"could not set property\n");
- return 1;
- }
-
- return 0;
-}