adb shell getprop和setprop如何工作? [英] How does adb shell getprop and setprop work?

查看:1358
本文介绍了adb shell getprop和setprop如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解 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 在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如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆