函数原型 int property_get(const char *key, char *value, const char *default_value);
在Hal 用法代码片段:
static const char *variant_keys[] = {
"ro.hardware", /* This goes first so that it can pick up a different file on the emulator. */
"ro.product.board",
"ro.board.platform",
"ro.arch"
};
char prop[PATH_MAX];
/* Loop through the configuration variants looking for a module */
for (i=0 ; i<HAL_VARIANT_KEYS_COUNT; i++) {
if (property_get(variant_keys[i], prop, NULL) == 0) {
continue;
}
if (hw_module_exists(path, sizeof(path), name, prop) == 0) {
goto found;
}
}
我由于没找到 property_get() 的实现源码,对Android property机制也不是很明白。
一直不清楚 property_get 它会把 variant_keys[] 里的值,拷贝到prop 数组吗?
谢谢!
哈哈,我说怎么这么熟悉的代码,原来是hardware.c,是的呢