Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does adb shell getprop and setprop work?

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?

like image 858
Rat-a-tat-a-tat Ratatouille Avatar asked Nov 16 '16 04:11

Rat-a-tat-a-tat Ratatouille


People also ask

What is adb shell Setprop?

adb shell set propThis command is used to set the property service. set property service. to enable the GPU overdraw debugging setprop.

What is Getprop?

“getprop” command helps us to know / identify more information about the device as well as what are the run time properties set by this Android device which are accessed by all the applications.

What is adb shell How do you use it?

Android Shell Commands. ADB is Android Debug Bridge which is a command line utility included with Google's Android SDK. It provides a terminal interface to control your Android device connected to a computer using a USB. ADB can be used to run shell commands, transfer files, install/uninstall apps, reboot and more.

What is Android adb shell?

Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.


1 Answers

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.

like image 173
Alex P. Avatar answered Sep 24 '22 13:09

Alex P.