How does adb shell getprop and setprop work?

I would like to understand how adb shell setprop mypropertykey mypropertyvalue for adb shell setprop mypropertykey mypropertyvalue . In other words, I edited the /system/build.prop file, but when I try to use the getprop command to read the value back, I seem to get an empty value instead.

However, when I set the property via adb shell setprop in root mode, and then unscrew the emulator and read the value using the code, I can get the correct value.

I do not understand, if the value is set via adb shell setprop then why is it not written to the build.prop file? Then where getprop read the values ​​from?

+7
source share
1 answer

Android system properties are controlled by a special property_service . /system/build.prop is just one of 4-6 (depending on version) read-only files containing default values ​​that property_service uses to fill its internal database in memory at startup. Therefore, changes to files at run time will not propagate until reboot.

The setprop and getprop are used to access data in this database. If the property name does not start with persist. - then the value is stored in the /data/property folder.

+9
source

Source: https://habr.com/ru/post/1259800/


All Articles