Keywords:Android Linux getprop setprop wathcprop
System:Android2.3 android4.0
1. Configuration File
In the Android system, there are some Initialization Configuration files, such:
/Init. RC/Default. Prop/system/build. Prop
The file contains the system attribute values configured for the boot settings. These attribute values can be obtained through getprop and set by setprop, such:
Ii. Use getprop stopprop watchprop and its format
1. getprop [Key]
Get the configuration value of the specified key. If the parameter is not included but getprop is used, all the configuration values of the system are displayed. Enter the command, for example:
# Getprop
2. setprop [Key] [value]: Set the attribute value of the specified key.
Example: setprop
3. getprop setprop instance
Root @ Android: // # getpropdhcp. wlan0.leasetime // The value is 36003600root @ Android:/# setprop DHCP. wlan0.leasetime3000 // set the value to 3000root @ Android:/# getprop [DHCP. wlan0.ipaddress]: [192.168.1.113] [DHCP. wlan0.leasetime]: [3000] // use getporp to view the set value [DHCP. wlan0.mask]: [255.255.255.0]
4. watchprops
Monitors system attribute changes. If the system attribute changes during this period, the changed value is displayed.
/System # watchprops1307501833 SYS. settings_system_version = '37' 1307501836 SYS. settings_system_version = '38' 1307501862 persist. SYS. timezone = 'Asia/hong_kong'
3. toolbox subcommands
1. Command implementationCodeLocation
In fact, these three commands are the sub-commands of toolbox. If you are interested, you can see the corresponding source code in the android source code:
System/CORE/toolbox/
Generally, when we enter the getprop command in the serial port, many system variable values similar to key-value pairs will appear, such:
2. Call Linux commands in Java
(1) how to call Linux commands in Java is mainly implemented through the following code:
Process process implements runtime.getruntime(.exe C (COM); inputstreamreader IR = newinputstreamreader (process. getinputstream (); bufferedreader input = newbufferedreader (IR );
(2) Since getprop and setprop are both commands, we also try to get the value from the above aspects.
Getprop usage: getprop [Key]
Setprop usage: setprop [Key] [value]
Note: Actually, there is no brackets.
So the usage is the same as above:
Process Execution runtime.getruntime(cmd.exe C ("getprop Ro. runtime. firstboot"); inputstreamreader IR = newinputstreamreader (process. getinputstream (); bufferedreader input = newbufferedreader (IR );