您好,登錄后才能下訂單哦!
Android 中build.prop 文件與 getprop 命令
在android系統中,它的根文件系統下有幾個用于啟動系統時需要的配置文件:
我們先看看 build.prop 里面到底有些什么東西:
E:\AndroidProject\NowaMagic>adb shell shell@android:/ $ su su root@android:/ # cd system cd system root@android:/system # cat build.prop cat build.prop # begin build properties # autogenerated by buildinfo.sh ro.build.id=JRO03L ro.build.display.id=JRO03L ro.build.version.incremental=JLB21.0 ro.build.version.sdk=16 ro.build.version.codename=REL ro.build.version.release=4.1.1 ro.build.date=Thu Aug 1 17:50:59 CST 2013 ro.build.date.utc=1375350659 ro.build.type=user ro.build.user=builder ro.build.host=taishan ro.build.tags=release-keys ro.product.model=MI 2 ro.product.brand=Xiaomi ro.product.name=aries ro.product.device=aries ro.product.board=MSM8960 ro.product.cpu.abi=armeabi-v7a ro.product.cpu.abi2=armeabi ro.product.manufacturer=Xiaomi ro.product.locale.language=zh ro.product.locale.region=CN ro.wifi.channels= ro.board.platform=msm8960 # ro.build.product is obsolete; use ro.product.device ro.build.product=aries # Do not try to parse ro.build.description or .fingerprint ro.build.description=aries-user 4.1.1 JRO03L JLB21.0 release-keys ro.build.fingerprint=Xiaomi/aries/aries:4.1.1/JRO03L/JLB21.0:user/release-keys ro.build.characteristics=nosdcard # end build properties # # system.prop for surf # rild.libpath=/system/lib/libril-qc-qmi-1.so rild.libargs=-d /dev/smd0 persist.rild.nitz_plmn= persist.rild.nitz_long_ons_0= persist.rild.nitz_long_ons_1= persist.rild.nitz_long_ons_2= persist.rild.nitz_long_ons_3= persist.rild.nitz_short_ons_0= persist.rild.nitz_short_ons_1= persist.rild.nitz_short_ons_2= persist.rild.nitz_short_ons_3= ril.subscription.types=RUIM DEVICE_PROVISIONED=1 debug.sf.hw=1 debug.egl.hw=1 debug.composition.type=dyn debug.mdpcomp.maxlayer=3 debug.mdpcomp.logs=0 ro.sf.lcd_density=320 # save modem ramdump to sdcard persist.radio.parsedump=1 persist.radio.ramdump_sdcard=0 persist.radio.ramdump_num=3 # # system props for the cne module # #persist.cne.bat.range.low.med=30 #persist.cne.bat.range.med.high=60 #persist.cne.loc.policy.op=/system/etc/OperatorPolicy.xml #persist.cne.loc.policy.user=/system/etc/UserPolicy.xml #persist.cne.bwbased.rat.sel=false #persist.cne.snsr.based.rat.mgt=false #persist.cne.bat.based.rat.mgt=false #persist.cne.rat.acq.time.out=30000 #persist.cne.rat.acq.retry.tout=0 #persist.cne.feature=1 ro.hdmi.enable=true lpa.decode=false lpa.use-stagefright=true #system props for the MM modules media.stagefright.enable-player=true media.stagefright.enable-http=true media.stagefright.enable-aac=true media.stagefright.enable-qcp=true media.stagefright.enable-fma2dp=true media.stagefright.enable-scan=true mmp.enable.3g2=true # # system props for the data modules # ro.use_data_netmgrd=true #system props for time-services #persist.timed.enable=true # System props for audio persist.audio.fluence.mode=endfire persist.audio.vr.enable=false persist.audio.handset.mic=digital # System prop to select audio resampler quality af.resampler.quality=255 # System prop to select MPQAudioPlayer by default on mpq8064 mpq.audio.decode=true # # system prop for opengles version # # 131072 is decimal for 0x20000 to report version 2 ro.opengles.version=131072 # # system property for Bluetooth Handsfree Profile version # ro.bluetooth.hfp.ver=1.6 # #system prop for Bluetooth hci transport ro.qualcomm.bt.hci_transport=smd # # system prop for requesting Master role in incoming Bluetooth connection. # ro.bluetooth.request.master=true # # system prop for Bluetooth Auto connect for remote initated connections # ro.bluetooth.remote.autoconnect=true # system property for Bluetooth discoverability time out in seconds # 0: Always discoverable #debug.bt.discoverable_time=0 #system prop for switching gps driver to qmi persist.gps.qmienabled=true # System property for cabl ro.qualcomm.cabl=0 # System property for csc debug.csc.poll=0 # System props for telephony # System prop to turn on CdmaLTEPhone always # telephony.lteOnCdmaDevice=1 # # System prop for sending transmit power request to RIL during WiFi hotspot on/off # ro.ril.transmitpower=true # #Simulate sdcard on /data/media # persist.fuse_sdcard=true ro.hwui.text_cache_width=2048 ro.hwui.texture_cache_size=48 # # Supports warmboot capabilities # ro.warmboot.capability=1 #snapdragon value add features ro.qcom.audio.ssr=true persist.sys.strictmode.disable=true power.webview.DM=false #enable cdrom installer persist.service.cdrom.enable=1 # # Haptic # ro.haptic.vibrate_ex.enabled=1 sys.haptic.long.weak=0,127,10,50,20,-50,10,0,10 sys.haptic.long.normal=0,127,10,80,20,-80,10,0,10 sys.haptic.long.strong=0,127,10,100,20,-100,10,0,10 sys.haptic.down.weak=0,120,10,-50,10,0,10 sys.haptic.down.normal=0,127,10,-80,10,0,10 sys.haptic.down.strong=0,127,20,-80,10,0,10 sys.haptic.up.weak=0,80,30,-50,10,0,10 sys.haptic.up.normal=0,100,30,-100,10,0,10 sys.haptic.up.strong=0,120,30,-120,10,0,10 sys.haptic.tap.weak=0,80,40,-5,5,0,10 sys.haptic.tap.normal=0,100,40,-5,5,0,10 sys.haptic.tap.strong=0,120,40,-5,5,0,10 # power mode persist.sys.aries.power_profile=middle # button jack mode and switch persist.sys.button_jack_profile=volume persist.sys.button_jack_switch=0 # suspend mode capability ro.warmboot.capability=true # display preference persist.sys.display_prefer=0 persist.sys.display_ce=0 debug.enabletr=false # # ADDITIONAL_BUILD_PROPERTIES # ro.miui.ui.version.code=3 ro.miui.ui.version.name=V5 keyguard.no_require_sim=true ro.com.android.dataroaming=false ro.com.android.dateformat=MM-dd-yyyy ro.config.ringtone=MI.ogg ro.config.notification_sound=FadeIn.ogg ro.config.alarm_alert=GoodMorning.ogg ro.config.sms_received_sound=FadeIn.ogg ro.config.sms_delivered_sound=MessageComplete.ogg ro.carrier=unknown persist.sys.mitalk.enable=true ro.vendor.extension_library=/system/lib/libqc-opt.so ro.com.google.clientidbase=android-xiaomi dalvik.vm.heapstartsize=8m dalvik.vm.heapgrowthlimit=96m dalvik.vm.heapsize=384m dalvik.vm.heaputilization=0.25 dalvik.vm.heapidealfree=8388608 dalvik.vm.heapconcurrentstart=2097152 ro.setupwizard.mode=OPTIONAL ro.com.google.gmsversion=4.1_r5 net.bt.name=Android dalvik.vm.stack-trace-file=/data/anr/traces.txt
該文件存放的數據是以這種等號形式存放的,而且它們是鍵值對成對出現的。
留意最后幾行,我們試下用 getprop 命令:
root@android:/ # getprop net.bt.name getprop net.bt.name Android root@android:/ # getprop dalvik.vm.stack-trace-file getprop dalvik.vm.stack-trace-file /data/anr/traces.txt root@android:/ #
很明顯,getprop 就是將配置文件 build.prop 里的信息讀取出來并經過整理后,并以字典的形式展示給用戶的。
它的格式如下:
如果要修改屬性的話,很簡單,只需修改字典值就可以了,如:
setprop [key] [value] 設置指定key的屬性值。
而 watchprops 監聽系統屬性的變化,如果期間系統的屬性發生變化則把變化的值顯示出來。
其實這三個命令都是toolbox的子命令,如果有興趣的可以看在android源碼中看到其對應的源碼:system/core/toolbox/
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。