查看: 505|回复: 0

[手机开发] Android 中build.prop 文件与 getprop 命令

发表于 2017-11-27 08:00:06
句号论坛

Android 中build.prop 文件与 getprop 命令

在android系统中,它的根文件系统下有几个用于启动系统时需要的配置文件:

  1. /init.rc
  2. /default.prop
  3. /system/build.prop

我们先看看 build.prop 里面到底有些什么东西:

  1. E:\AndroidProject\NowaMagic>adb shell
  2. shell@android:/ $ su
  3. su
  4. root@android:/ # cd system
  5. cd system
  6. root@android:/system # cat build.prop
  7. cat build.prop
  8. # begin build properties
  9. # autogenerated by buildinfo.sh
  10. ro.build.id=JRO03L
  11. ro.build.display.id=JRO03L
  12. ro.build.version.incremental=JLB21.0
  13. ro.build.version.sdk=16
  14. ro.build.version.codename=REL
  15. ro.build.version.release=4.1.1
  16. ro.build.date=Thu Aug 1 17:50:59 CST 2013
  17. ro.build.date.utc=1375350659
  18. ro.build.type=user
  19. ro.build.user=builder
  20. ro.build.host=taishan
  21. ro.build.tags=release-keys
  22. ro.product.model=MI 2
  23. ro.product.brand=Xiaomi
  24. ro.product.name=aries
  25. ro.product.device=aries
  26. ro.product.board=MSM8960
  27. ro.product.cpu.abi=armeabi-v7a
  28. ro.product.cpu.abi2=armeabi
  29. ro.product.manufacturer=Xiaomi
  30. ro.product.locale.language=zh
  31. ro.product.locale.region=CN
  32. ro.wifi.channels=
  33. ro.board.platform=msm8960
  34. # ro.build.product is obsolete; use ro.product.device
  35. ro.build.product=aries
  36. # Do not try to parse ro.build.description or .fingerprint
  37. ro.build.description=aries-user 4.1.1 JRO03L JLB21.0 release-keys
  38. ro.build.fingerprint=Xiaomi/aries/aries:4.1.1/JRO03L/JLB21.0:user/release-keys
  39. ro.build.characteristics=nosdcard
  40. # end build properties
  41. #
  42. # system.prop for surf
  43. #
  44. rild.libpath=/system/lib/libril-qc-qmi-1.so
  45. rild.libargs=-d /dev/smd0
  46. persist.rild.nitz_plmn=
  47. persist.rild.nitz_long_ons_0=
  48. persist.rild.nitz_long_ons_1=
  49. persist.rild.nitz_long_ons_2=
  50. persist.rild.nitz_long_ons_3=
  51. persist.rild.nitz_short_ons_0=
  52. persist.rild.nitz_short_ons_1=
  53. persist.rild.nitz_short_ons_2=
  54. persist.rild.nitz_short_ons_3=
  55. ril.subscription.types=RUIM
  56. DEVICE_PROVISIONED=1
  57. debug.sf.hw=1
  58. debug.egl.hw=1
  59. debug.composition.type=dyn
  60. debug.mdpcomp.maxlayer=3
  61. debug.mdpcomp.logs=0
  62. ro.sf.lcd_density=320
  63. # save modem ramdump to sdcard
  64. persist.radio.parsedump=1
  65. persist.radio.ramdump_sdcard=0
  66. persist.radio.ramdump_num=3
  67. #
  68. # system props for the cne module
  69. #
  70. #persist.cne.bat.range.low.med=30
  71. #persist.cne.bat.range.med.high=60
  72. #persist.cne.loc.policy.op=/system/etc/OperatorPolicy.xml
  73. #persist.cne.loc.policy.user=/system/etc/UserPolicy.xml
  74. #persist.cne.bwbased.rat.sel=false
  75. #persist.cne.snsr.based.rat.mgt=false
  76. #persist.cne.bat.based.rat.mgt=false
  77. #persist.cne.rat.acq.time.out=30000
  78. #persist.cne.rat.acq.retry.tout=0
  79. #persist.cne.feature=1
  80. ro.hdmi.enable=true
  81. lpa.decode=false
  82. lpa.use-stagefright=true
  83. #system props for the MM modules
  84. media.stagefright.enable-player=true
  85. media.stagefright.enable-http=true
  86. media.stagefright.enable-aac=true
  87. media.stagefright.enable-qcp=true
  88. media.stagefright.enable-fma2dp=true
  89. media.stagefright.enable-scan=true
  90. mmp.enable.3g2=true
  91. #
  92. # system props for the data modules
  93. #
  94. ro.use_data_netmgrd=true
  95. #system props for time-services
  96. #persist.timed.enable=true
  97. # System props for audio
  98. persist.audio.fluence.mode=endfire
  99. persist.audio.vr.enable=false
  100. persist.audio.handset.mic=digital
  101. # System prop to select audio resampler quality
  102. af.resampler.quality=255
  103. # System prop to select MPQAudioPlayer by default on mpq8064
  104. mpq.audio.decode=true
  105. #
  106. # system prop for opengles version
  107. #
  108. # 131072 is decimal for 0x20000 to report version 2
  109. ro.opengles.version=131072
  110. #
  111. # system property for Bluetooth Handsfree Profile version
  112. #
  113. ro.bluetooth.hfp.ver=1.6
  114. #
  115. #system prop for Bluetooth hci transport
  116. ro.qualcomm.bt.hci_transport=smd
  117. #
  118. # system prop for requesting Master role in incoming Bluetooth connection.
  119. #
  120. ro.bluetooth.request.master=true
  121. #
  122. # system prop for Bluetooth Auto connect for remote initated connections
  123. #
  124. ro.bluetooth.remote.autoconnect=true
  125. # system property for Bluetooth discoverability time out in seconds
  126. # 0: Always discoverable
  127. #debug.bt.discoverable_time=0
  128. #system prop for switching gps driver to qmi
  129. persist.gps.qmienabled=true
  130. # System property for cabl
  131. ro.qualcomm.cabl=0
  132. # System property for csc
  133. debug.csc.poll=0
  134. # System props for telephony
  135. # System prop to turn on CdmaLTEPhone always
  136. # telephony.lteOnCdmaDevice=1
  137. #
  138. # System prop for sending transmit power request to RIL during WiFi hotspot on/off
  139. #
  140. ro.ril.transmitpower=true
  141. #
  142. #Simulate sdcard on /data/media
  143. #
  144. persist.fuse_sdcard=true
  145. ro.hwui.text_cache_width=2048
  146. ro.hwui.texture_cache_size=48
  147. #
  148. # Supports warmboot capabilities
  149. #
  150. ro.warmboot.capability=1
  151. #snapdragon value add features
  152. ro.qcom.audio.ssr=true
  153. persist.sys.strictmode.disable=true
  154. power.webview.DM=false
  155. #enable cdrom installer
  156. persist.service.cdrom.enable=1
  157. #
  158. # Haptic
  159. #
  160. ro.haptic.vibrate_ex.enabled=1
  161. sys.haptic.long.weak=0,127,10,50,20,-50,10,0,10
  162. sys.haptic.long.normal=0,127,10,80,20,-80,10,0,10
  163. sys.haptic.long.strong=0,127,10,100,20,-100,10,0,10
  164. sys.haptic.down.weak=0,120,10,-50,10,0,10
  165. sys.haptic.down.normal=0,127,10,-80,10,0,10
  166. sys.haptic.down.strong=0,127,20,-80,10,0,10
  167. sys.haptic.up.weak=0,80,30,-50,10,0,10
  168. sys.haptic.up.normal=0,100,30,-100,10,0,10
  169. sys.haptic.up.strong=0,120,30,-120,10,0,10
  170. sys.haptic.tap.weak=0,80,40,-5,5,0,10
  171. sys.haptic.tap.normal=0,100,40,-5,5,0,10
  172. sys.haptic.tap.strong=0,120,40,-5,5,0,10
  173. # power mode
  174. persist.sys.aries.power_profile=middle
  175. # button jack mode and switch
  176. persist.sys.button_jack_profile=volume
  177. persist.sys.button_jack_switch=0
  178. # suspend mode capability
  179. ro.warmboot.capability=true
  180. # display preference
  181. persist.sys.display_prefer=0
  182. persist.sys.display_ce=0
  183. debug.enabletr=false
  184. #
  185. # ADDITIONAL_BUILD_PROPERTIES
  186. #
  187. ro.miui.ui.version.code=3
  188. ro.miui.ui.version.name=V5
  189. keyguard.no_require_sim=true
  190. ro.com.android.dataroaming=false
  191. ro.com.android.dateformat=MM-dd-yyyy
  192. ro.config.ringtone=MI.ogg
  193. ro.config.notification_sound=FadeIn.ogg
  194. ro.config.alarm_alert=GoodMorning.ogg
  195. ro.config.sms_received_sound=FadeIn.ogg
  196. ro.config.sms_delivered_sound=MessageComplete.ogg
  197. ro.carrier=unknown
  198. persist.sys.mitalk.enable=true
  199. ro.vendor.extension_library=/system/lib/libqc-opt.so
  200. ro.com.google.clientidbase=android-xiaomi
  201. dalvik.vm.heapstartsize=8m
  202. dalvik.vm.heapgrowthlimit=96m
  203. dalvik.vm.heapsize=384m
  204. dalvik.vm.heaputilization=0.25
  205. dalvik.vm.heapidealfree=8388608
  206. dalvik.vm.heapconcurrentstart=2097152
  207. ro.setupwizard.mode=OPTIONAL
  208. ro.com.google.gmsversion=4.1_r5
  209. net.bt.name=Android
  210. dalvik.vm.stack-trace-file=/data/anr/traces.txt
复制代码

该文件存放的数据是以这种等号形式存放的,而且它们是键值对成对出现的。

留意最后几行,我们试下用 getprop 命令:

  1. root@android:/ # getprop net.bt.name
  2. getprop net.bt.name
  3. Android
  4. root@android:/ # getprop dalvik.vm.stack-trace-file
  5. getprop dalvik.vm.stack-trace-file
  6. /data/anr/traces.txt
  7. root@android:/ #
复制代码

很明显,getprop 就是将配置文件 build.prop 里的信息读取出来并经过整理后,并以字典的形式展示给用户的。

它的格式如下:

  • getprop 列出所有配置属性值
  • getprop [key] 取得对应的key的属性值

如果要修改属性的话,很简单,只需修改字典值就可以了,如:

setprop [key] [value] 设置指定key的属性值。

而 watchprops 监听系统属性的变化,如果期间系统的属性发生变化则把变化的值显示出来。

其实这三个命令都是toolbox的子命令,如果有兴趣的可以看在android源码中看到其对应的源码:system/core/toolbox/

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!



太阳http代理AD
回复

使用道具 举报

关闭

站长推荐上一条 /1 下一条