Move dumpstate to calling getprop.
There's no obvious reason for reinventing the wheel like this (given that
dumpstate already spends most of its time calling out to other utilities),
and I keep having to come and fix this code.
(This time the problem being that there's no longer a limit on system
property names.)
Bug: http://b/33926793
Test: ran dumpstate
Change-Id: I08281680df5aabfdb39228abf8c2aab089cc8b9e
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 3c019ac..ab323bb 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1059,7 +1059,7 @@
#endif
DumpFile("INTERRUPTS (2)", "/proc/interrupts");
- print_properties();
+ RunCommand("SYSTEM PROPERTIES", {"getprop"});
RunCommand("VOLD DUMP", {"vdc", "dump"});
RunCommand("SECURE CONTAINERS", {"vdc", "asec", "list"});
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index d988429..7fcb980 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -363,9 +363,6 @@
int dump_files(const std::string& title, const char* dir, bool (*skip)(const char* path),
int (*dump_from_fd)(const char* title, const char* path, int fd));
-/* prints all the system properties */
-void print_properties();
-
/** opens a socket and returns its file descriptor */
int open_socket(const char *service);
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index baa6458..4655d33 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -710,40 +710,6 @@
RunCommand(title, dumpsys, options);
}
-size_t num_props = 0;
-static char* props[2000];
-
-static void print_prop(const char *key, const char *name, void *user) {
- (void) user;
- if (num_props < sizeof(props) / sizeof(props[0])) {
- char buf[PROPERTY_KEY_MAX + PROPERTY_VALUE_MAX + 10];
- snprintf(buf, sizeof(buf), "[%s]: [%s]\n", key, name);
- props[num_props++] = strdup(buf);
- }
-}
-
-static int compare_prop(const void *a, const void *b) {
- return strcmp(*(char * const *) a, *(char * const *) b);
-}
-
-/* prints all the system properties */
-void print_properties() {
- const char* title = "SYSTEM PROPERTIES";
- DurationReporter duration_reporter(title);
- printf("------ %s ------\n", title);
- if (PropertiesHelper::IsDryRun()) return;
- size_t i;
- num_props = 0;
- property_list(print_prop, NULL);
- qsort(&props, num_props, sizeof(props[0]), compare_prop);
-
- for (i = 0; i < num_props; ++i) {
- fputs(props[i], stdout);
- free(props[i]);
- }
- printf("\n");
-}
-
int open_socket(const char *service) {
int s = android_get_control_socket(service);
if (s < 0) {