问题描述
我想了解 adb shell setprop mypropertykey mypropertyvalue
的工作原理。换句话说,我编辑了 /system/build.prop
文件,但是当我尝试使用 getprop
命令
I would like to understand how adb shell setprop mypropertykey mypropertyvalue
works. 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.
但是,当我通过 adb shell setprop $ c设置属性时,我似乎得到了一个空白值。 $ c>在root模式下,然后取消仿真器的root权限,并使用代码读取该值,我就能获得正确的值。
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
设置的,为什么不这样做写入 build.prop
文件?那么 getprop
从哪里读取值?
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? Then where does getprop
read the values from?
推荐答案
Android系统属性由特殊的 property_service
管理。 /system/build.prop
只是4-6个只读文件(取决于版本)之一,其中包含默认值 property_service
用于在启动期间填充其内部内存数据库。因此,在运行时对文件的更改要等到重新启动后才能传播。
Android system properties are being managed by special 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. So changes to the files during run time would not propagate until after reboot.
setprop
和 getprop
命令用于访问该数据库中的数据。除非属性名称以 persist开头。
-否则该值将存储在 / data / property
文件夹中。
The setprop
and getprop
commands are used to access the data in that database. Unless the property name starts with persist.
- then the value gets stored in /data/property
folder.
这篇关于adb shell getprop和setprop如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!