How does adb shell getprop and setprop work?
Asked Answered
R

1

16

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.

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.

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?

Religionism answered 16/11, 2016 at 4:44 Comment(0)
G
34

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.

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.

Guessrope answered 16/11, 2016 at 5:18 Comment(2)
so if there is an embedded application that has to read from a build.prop file, that value would always be available to it since the device would hve been rebooted already?Religionism
So, if I'll add .property prefix for my log.tag.CrashlyticsCore variable. Will it becomes persistent?Exoteric

© 2022 - 2024 — McMap. All rights reserved.