在展讯6820代码中customize\customer_cfg\sp6820a\res\system.prop文件中添加ro.floatkey.show = true属性值, 最后编译完成后,在idh.code\out\target\product\hsdroid\system\build.prop会添加ro.floatkey.show = true属性值, 我们在android应用程序中如何访问属性值呢?
SystemProperties.getBoolean("ro.floatkey.show", false);// 得到系统属性的值
SystemProperties.set("ro.floatkey.show", false);// 设置系统属性的值
SystemProperties是如何访问到系统属性值的呢, 我们可以在SystemProperties.java(framework\base\core
\java\android\os)文件中看到
public static boolean getBoolean(String key, boolean def) {
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
return native_get_boolean(key, def);
}
最后调用的是JNI函数native_get_boolean(), 这个函数最终实现在framework/base/core/jni/android_os_
SystemProperties.cpp文件中, SystemProperties_get_boolean()与这个函数对应。