a95abdd8ed
getprop used to output a colon after the property name like: [property.name]: [property.value] Add back the colon that was missing, because com.android.ddmlib.GetPropReceiver's regex expects it. Without the colon, the GetPropReceiver doesn't parse the device's properties causing CTS to not recognize the device. Change-Id: I9bef5ab2b310c831c49c8c51cae7f129167c2dc5
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
#include <sys/system_properties.h>
|
|
#include "dynarray.h"
|
|
|
|
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;
|
|
}
|