
结论:1必须采用persist开头的属性名才能永久保存。2如果具有root权限,可以直接编辑/system/buildprop并加入需要永久保存的属性On system initialization, Android will allocates a block of shared memory for storing the properties This is done in “init” daemon whose sourcecode is at: device/system/init The “init” daemon will start a PropertyServiceThe 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 directlyThis promotes the read performanceJava API:import androidosSystemProperties;public static String get(String key, String def) {} public static void set(String key, String val) {} The Native API:int property_get(const char key, char value, const char default_value); int property_set(const char key, const char value);bionic/libc/include/sys/system_propertiesh#define PROP_NAME_MAX 32 #define PROP_VALUE_MAX 92以上定义可知属性最大长度为32,属性值最大长度92字节.bionic/libc/include/sys/_system_propertiesh#define PROP_PATH_RAMDISK_DEFAULT "/defaultprop" #define PROP_PATH_SYSTEM_BUILD "/system/buildprop" #define PROP_PATH_SYSTEM_DEFAULT "/system/defaultprop" #define PROP_PATH_LOCAL_OVERRIDE "/data/localprop"属性服务启动后会从系统文件中读取默认的属性,并写入共享内存中,以下4个文件为按顺序读取:/defaultprop/system/buildprop/system/defaultprop/data/localprop后读入的属性将覆盖前面读取的相同的属性。int property_set(const char name, const char value) { if(namelen < 1) return -1; pi = (prop_info) __system_property_find(name); if(pi != 0) { / ro properties may NEVER be modified once set / if(!strncmp(name, "ro", 3)) return -1; pa = __system_property_area__; update_prop_info(pi, value, valuelen); pa->serial++; __futex_wake(&pa->serial, INT32_MAX); } else { pa = __system_property_area__; if(pa->count == PA_COUNT_MAX) return -1; pi = pa_info_array + pa->count; pi->serial = (valuelen << 24); memcpy(pi->name, name, namelen + 1); memcpy(pi->value, value, valuelen + 1); pa->toc[pa->count] = (namelen << 24) | (((unsigned) pi) - ((unsigned) pa)); pa->count++; pa->serial++; __futex_wake(&pa->serial, INT32_MAX); } / If name starts with "net" treat as a DNS property / if (strncmp("net", name, strlen("net")) == 0) { if (strcmp("netchange", name) == 0) { return 0; } / The 'netchange' property is a special property used track when any 'net' property name is updated It is _ONLY_ updated here Its value contains the last updated 'net' property / property_set("netchange", name); } else if (persistent_properties_loaded && strncmp("persist", name, strlen("persist")) == 0) { / Don't write properties to disk until after we have read all default properties to prevent them from being overwritten by default values / write_persistent_property(name, value); } property_changed(name, value); return 0; } 当用户设置属性时,如果以属性名字以persist开头,则会同时在/data/property目录下创建以该属性名字命名的文件,并写入属性值。
以上就是关于pring boot 中controller如何接收http请求的参数全部的内容,包括:pring boot 中controller如何接收http请求的参数、persist.sys.logkit.ctrlcode=0 在什么地方修改、Android属性:所设属性值为何在重起后被清除等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)