Android属性:所设属性值为何在重起后被清除

2014-11-24 10:56:04 来源: 作者: 浏览: 0

问题:发现adb sehll setProp所设属性值在下次重起后被清除


结论:必须采用persist.开头的属性名才能永久保存。


The Property Service is running in the process of “init”daemon. Every client that wants to SET property needs to connect to theProperty Service and send message to Property Service. Property Servicewill update/create the property in shared memory. Any client that wants to GET property can read the property from the shared memory directly.This promotes the read performance.



Java API:


import android.os.SystemProperties;


The Native API:


bionic/libc/include/sys/system_properties.h



bionic/libc/include/sys/_system_properties.h



属性服务启动后会从系统文件中读取默认的属性,并写入共享内存中,以下4个文件为按顺序读取:
/default.prop
/system/build.prop
/system/default.prop
/data/local.prop

后读入的属性将覆盖前面读取的相同的属性。
system/core/init/property_service.c



设置属性,ro.开头的属性将不能被更改属性值,persist.开头的属性会被永久纪录,其他属性值在重新开机后均将被丢弃:


当用户设置属性时,如果以属性名字以persist.开头,则会同时在/data/property目录下创建以该属性名字命名的文件,并写入属性值。


加载永久属性时,会读入在目录/data/property下所有名字以persist.开头的文件内容,作为该名字对应的属性值。


-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: