目录
Author: kevin.xu
Email:13570805860@163.com
1.watchprops代码来源
watchprops.c 在android5.0 toolbox 集合中存在 从6A638/android_v2/system/core/toolbox/ 中拷贝到9632_build/system/core/toolbox
2.代码修改
2.1 Android.bp 修改
diff --git a/system/core/toolbox/Android.bp b/system/core/toolbox/Android.bp
index ddd95b207d..5dd4404bb9 100644
--- a/system/core/toolbox/Android.bp
+++ b/system/core/toolbox/Android.bp
@@ -49,6 +49,7 @@ cc_defaults {
srcs: [
"toolbox.c",
"getevent.c",
+ "watchprops.c",
"getprop.cpp",
"newfs_msdos.c",
],
@@ -66,6 +67,7 @@ cc_defaults {
"dd",
"getevent",
"getprop",
+ "watchprops",
"newfs_msdos",
],
}
2.2 toolbox 增加子工具
diff --git a/system/core/toolbox/tools.h b/system/core/toolbox/tools.h
index 505f5281b1..bdd0ba4113 100644
--- a/system/core/toolbox/tools.h
+++ b/system/core/toolbox/tools.h
@@ -2,4 +2,5 @@ TOOL(dd)
TOOL(getevent)
TOOL(getprop)
TOOL(newfs_msdos)
+TOOL(watchprops)
TOOL(toolbox)
2.3 编译
croot
mm system/core/toolbox
2.4 工具置入
拷贝
out\target\product\m7332_eu\system\bin\toolbox
与 out\target\product\m7332_eu\system\bin\watchprops
到主板/system/bin/
chmod 777 /system/bin/toolbox /system/bin/watchprops
2.5 工具使用
toolbox watchprops 或 watchprops 便可监控系统属性的变化
3 FAQ:
3.1 编译错误
system/core/toolbox/watchprops.c:15:29: error: implicitly declaring library function 'strlen' with type 'unsigned int (const char *)' [-Werror,-Wimplicit-function-declaration]
return hashmapHash(key, strlen(key));
system/core/toolbox/watchprops.c:15:29: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
system/core/toolbox/watchprops.c:20:12: error: implicitly declaring library function 'strcmp' with type 'int (const char *, const char *)' [-Werror,-Wimplicit-function-declaration]
return strcmp(keyA, keyB) == 0;
^
system/core/toolbox/watchprops.c:20:12: note: include the header <string.h> or explicitly provide a declaration for 'strcmp'
system/core/toolbox/watchprops.c:37:17: error: implicitly declaring library function 'strdup' with type 'char *(const char *)' [-Werror,-Wimplicit-function-declaration]
char *key = strdup(name);
3.2 解决
增加头文件 #include <string.h>