[英]How does adb shell getprop and setprop work?
I would like to understand how adb shell setprop mypropertykey mypropertyvalue
works. 我想了解adb shell setprop mypropertykey mypropertyvalue
是如何工作的。 In other words, I edited the /system/build.prop
file, but when I try to use getprop
command to read the value back I seem to be getting a blank value instead. 换句话说,我编辑了/system/build.prop
文件,但是当我尝试使用getprop
命令读取值时,我似乎得到了一个空值。
However, when I set the property via adb shell setprop
in the root mode and then unroot the emulator and read the value using code, I am able to get the proper value. 但是,当我在根模式下通过adb shell setprop
设置属性然后取消模拟器并使用代码读取值时,我能够获得正确的值。
What I don't understand is, if the value is set via adb shell setprop
then why does it not get written to the build.prop
file? 我不明白的是,如果值是通过adb shell setprop
设置的,为什么它不会被写入build.prop
文件? Then where does getprop
read the values from? 那么getprop
从哪里读取值?
Android system properties are being managed by special property_service
. Android系统属性由特殊的property_service
管理。 The /system/build.prop
is just one out of 4-6 (depending on the version) read-only files containing the default values that property_service
uses to populate its internal in-memory database with during start-up. /system/build.prop
只是4-6中的一个(取决于版本)只读文件,其中包含property_service
在启动期间用于填充其内部内存数据库的默认值。 So changes to the files during run time would not propagate until after reboot. 因此,在运行时对文件的更改不会在重新引导之后传播。
The setprop
and getprop
commands are used to access the data in that database. setprop
和getprop
命令用于访问该数据库中的数据。 Unless the property name starts with persist.
除非属性名称以persist.
开头persist.
- then the value gets stored in /data/property
folder. - 然后将值存储在/data/property
文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.