大家好,我是公众号3分钟学堂的郭立员~
前言
对于安卓系统属性的查看和修改需要命令行工具 getprop 和 setprop。
getprop 获取系统属性
setprop 修改系统属性
涉及到几个文件:
/default.prop
/system/build.prop
研究这个是在找adb相关资料的时候找到的,发现只运行getprop 命令时,会输出很多系统属性。
Import "zm.luae"
TracePrint zm.Execute("getprop")
输出结果:
[ack-trace-file]: [/data/anr/traces.txt]
[app.setupwizard.disable]: [0]
[dalvik.vm.appimageformat]: [lz4]
[dalvik.vm.checkjni]: [false]
[dalvik.vm.dex2oat-Xms]: [64m]
[dalvik.vm.dex2oat-Xmx]: [512m]
[dalvik.vm.heapgrowthlimit]: [192m]
[dalvik.vm.heapmaxfree]: [8m]
[dalvik.vm.heapminfree]: [512k]
[dalvik.vm.heapsize]: [512m]
[dalvik.vm.heapstartsize]: [16m]
[dalvik.vm.heaptargetutilization]: [0.75]
[dalvik.vm.image-dex2oat-Xms]: [64m]
[dalvik.vm.image-dex2oat-Xmx]: [64m]
[dalvik.vm.isa.x86.features]: [default]
[dalvik.vm.isa.x86.variant]: [x86]
[dalvik.vm.isa.x86_64.features]: [default]
[dalvik.vm.isa.x86_64.variant]: [silvermont]
[dalvik.vm.lockprof.threshold]: [500]
[dalvik.vm.stack-trace-file]: [/data/anr/traces.txt]
[dalvik.vm.usejit]: [true]
[dalvik.vm.usejitprofiles]: [true]
[debug.atrace.tags.enableflags]: [0]
[debug.force_rtl]: [0]
[debug.sf.nobootanimation]: [1]
[dev.bootcomplete]: [1]
[gsm.current.phone-type]: [1]
[gsm.network.type]: [Unknown]
[gsm.operator.alpha]: []
[gsm.operator.iso-country]: []
[gsm.operator.isroaming]: [false]
[gsm.operator.numeric]: []
[gsm.sim.operator.alpha]: []
[gsm.sim.operator.iso-country]: []
[gsm.sim.operator.numeric]: []
[gsm.sim.state]: [NOT_READY]
[init.svc.adbd]: [running]
[init.svc.audioserver]: [running]
[init.svc.cameraserver]: [running]
[init.svc.debuggerd]: [running]
[init.svc.debuggerd64]: [running]
[init.svc.drm]: [running]
[init.svc.gatekeeperd]: [running]
[init.svc.healthd]: [running]
[init.svc.installd]: [running]
[init.svc.keystore]: [running]
[init.svc.ldinit]: [running]
[init.svc.lmkd]: [running]
[init.svc.logd]: [running]
[init.svc.logd-reinit]: [stopped]
[init.svc.media]: [running]
[init.svc.mediacodec]: [running]
[init.svc.mediadrm]: [running]
[init.svc.mediaextractor]: [running]
[init.svc.nativebridge]: [stopped]
[init.svc.netd]: [running]
[init.svc.ril-daemon]: [running]
[init.svc.servicemanager]: [running]
[init.svc.su_daemon]: [running]
[init.svc.surfaceflinger]: [running]
[init.svc.ueventd]: [running]
[init.svc.vold]: [running]
[init.svc.zygote]: [running]
[init.svc.zygote_secondary]: [running]
[keyguard.no_require_sim]: [true]
[media.sf.extractor-plugin]: [libffmpeg_extractor.so]
[media.sf.hwaccel]: [1]
[media.sf.omx-plugin]: [libffmpeg_omx.so]
[net.bt.name]: [Android]
[net.change]: [net.dns3]
[net.dns1]: [192.168.31.1]
[net.dns2]: [119.29.29.29]
[net.dns3]: [114.114.114.114]
[net.hostname]: [android-55b499c67c51e632]
[net.qtaguid_enabled]: [0]
[net.tcp.default_init_rwnd]: [60]
[persist.imei]: [869394025762798]
[persist.logd.logpersistd]: []
[persist.logd.logpersistd.buffer]: []
[persist.rtc_local_time]: [1]
[persist.sys.build.time]: [1654223609]
[persist.sys.country]: [CN]
[persist.sys.dalvik.vm.lib.2]: [libart.so]
[persist.sys.gps.lpp]: []
[persist.sys.language]: [zh]
[persist.sys.locale]: [zh-CN]
[persist.sys.localevar]: []
[persist.sys.nativebridge]: [1]
[persist.sys.profiler_ms]: [0]
[persist.sys.strictmode.disable]: [1]
[persist.sys.strictmode.visual]: [0]
[persist.sys.timezone]: [Asia/Shanghai]
[persist.sys.usb.config]: [none]
[persist.sys.webview.vmsize]: [169343248]
[pm.dexopt.ab-ota]: [speed-profile]
[pm.dexopt.bg-dexopt]: [speed-profile]
[pm.dexopt.boot]: [verify-profile]
[pm.dexopt.core-app]: [speed]
[pm.dexopt.first-boot]: [interpret-only]
[pm.dexopt.forced-dexopt]: [speed]
[pm.dexopt.install]: [interpret-only]
[pm.dexopt.nsys-library]: [speed]
[pm.dexopt.shared-apk]: [speed]
[ro.adb.secure]: [1]
[ro.alarm.volume.adjustable]: [true]
[ro.allow.mock.location]: [0]
[ro.arch]: [x86]
[ro.baseband]: [unknown]
[ro.board.platform]: [aosp-user]
[ro.boot.console]: [tty0]
[ro.boot.selinux]: [permissive]
[ro.boot.serialno]: [00d21e88]
[ro.bootimage.build.date]: [Fri Jun 3 10:08:51 CST 2022]
[ro.bootimage.build.date.utc]: [1654222131]
[ro.bootimage.build.fingerprint]: [google/android_x86_64/x86_64:7.1.2/N2G47O/327:user/release-keys]
[ro.bootloader]: [unknown]
[ro.bootmode]: [unknown]
[ro.build.characteristics]: [tablet]
[ro.build.date]: [Fri Jun 3 10:08:51 CST 2022]
[ro.build.date.utc]: [1654222131]
[ro.build.description]: [android_x86_64-user 7.1.2 N2G47O 327 release-keys]
[ro.build.display.id]: [N2G47O]
[ro.build.fingerprint]: [google/android_x86_64/x86_64:7.1.2/N2G47O/327:user/release-keys]
[ro.build.flavor]: [aosp-user]
[ro.build.host]: [UBNX]
[ro.build.id]: [N2G47O]
[ro.build.product]: [aosp]
[ro.build.tags]: [release-keys]
[ro.build.time]: [1654223609]
[ro.build.type]: [user]
[ro.build.user]: [build]
[ro.build.version.all_codenames]: [REL]
[ro.build.version.base_os]: []
[ro.build.version.codename]: [REL]
[ro.build.version.incremental]: [327]
[ro.build.version.preview_sdk]: [0]
[ro.build.version.release]: [7.1.2]
[ro.build.version.sdk]: [25]
[ro.build.version.security_patch]: [2017-10-05]
[ro.carrier]: [unknown]
[ro.com.android.dataroaming]: [true]
[ro.com.android.dateformat]: [MM-dd-yyyy]
[ro.config.alarm_alert]: [Alarm_Classic.ogg]
[ro.config.notification_sound]: [OnTheHunt.ogg]
[ro.config.sync]: [yes]
[ro.crypto.state]: [unsupported]
[ro.dalvik.vm.isa.arm]: [x86]
[ro.dalvik.vm.isa.arm64]: [x86_64]
[ro.dalvik.vm.native.bridge]: [libnb.so]
[ro.debuggable]: [1]
[ro.device_owner]: [false]
[ro.enable.native.bridge.exec]: [1]
[ro.enable.native.bridge.exec64]: [1]
[ro.hardware]: [android_x86_64]
[ro.hwui.drop_shadow_cache_size]: [4.0]
[ro.hwui.gradient_cache_size]: [0.8]
[ro.hwui.layer_cache_size]: [32.0]
[ro.hwui.path_cache_size]: [24.0]
[ro.hwui.text_large_cache_height]: [1024]
[ro.hwui.text_large_cache_width]: [2048]
[ro.hwui.text_small_cache_height]: [512]
[ro.hwui.text_small_cache_width]: [1024]
[ro.hwui.texture_cache_flushrate]: [0.4]
[ro.hwui.texture_cache_size]: [48.0]
[ro.opengles.max]: [196609]
[ro.opengles.version]: [196609]
[ro.product.board]: [V1938CT]
[ro.product.brand]: [vivo]
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.product.device]: [aosp]
[ro.product.locale]: [en-US]
[ro.product.locale.language]: [zh]
[ro.product.locale.region]: [CN]
[ro.product.manufacturer]: [vivo]
[ro.product.model]: [V1938CT]
[ro.product.name]: [V1938CT]
[ro.radio.use-ppp]: [yes]
[ro.revision]: [0]
[ro.ril.gprsclass]: [10]
[ro.ril.hsxpa]: [1]
[ro.runtime.firstboot]: [1704614344671]
[ro.secure]: [1]
[ro.serialno]: [00d21e88]
[ro.setupwizard.mode]: [DISABLED]
[ro.sf.lcd_density]: [320]
[ro.simulated.phone]: [false]
[ro.wifi.channels]: []
[ro.zygote]: [zygote64_32]
[security.perf_harden]: [1]
[selinux.reload_policy]: [1]
[service.bootanim.exit]: [1]
[status.battery.level]: [5]
[status.battery.level_raw]: [50]
[status.battery.level_scale]: [9]
[status.battery.state]: [Slow]
[sys.boot_completed]: [1]
[sys.logbootcomplete]: [1]
[sys.media.vdec.drop]: [0]
[sys.sysctl.extra_free_kbytes]: [10800]
[sys.sysctl.tcp_def_init_rwnd]: [60]
[sys.usb.config]: [adb]
[sys.usb.configfs]: [0]
[sys.usb.state]: [adb]
[vold.has_adoptable]: [1]
[vold.post_fs_data_done]: [1]
进一步查找发现这些系统属性保存在上面提到的文件:
/default.prop
/system/build.prop
在上面的输出结果中,格式是这样的:[key]:[value]
key是属性名,value是属性值
getprop的用法:
getprop [key] 取得对应的key的属性值
比如获取手机品牌:
Import "zm.luae"
TracePrint zm.Execute("getprop ro.product.brand")
//输出结果:vivo
setprop的用法:
setprop [key] [value] 设置指定key的属性值。
如修改模拟器定位:
Import "zm.luae"
TracePrint zm.Execute("getprop call.locate 117,29")
需要注意一般属性名中有ro.的属性,使用setprop修改只是临时修改,ro的意思是read only(只读)。
相关文章:
整理了一下雷电模拟器的adb命令
正文完=