简体   繁体   English

更改android adb shell中“ getprop”的输出

[英]Change the output of “getprop” in android adb shell

I am trying to change the output when we are using getprop in adb. 我正在尝试在adb中使用getprop时更改输出。 I know that the init will read the system properties from /default.prop /system/build.prop /system/default.prop /data/local.prop. 我知道init将从/default.prop /system/build.prop /system/default.prop /data/local.prop中读取系统属性。 In my case, I only got the /default.prop and /system/build.prop. 就我而言,我只有/default.prop和/system/build.prop。 So what I did is get the android source code and add this to the build/target/product/core.mk. 所以我要做的是获取android源代码并将其添加到build / target / product / core.mk中。

PRODUCT_PROPERTY_OVERRIDES :=\
ro.bootloader="PWN" \
ro.bootmode="PWN" \
ro.hardware="PWN" \
ro.kernel.qemu="PWN" \
ro.product.device="PWN" \
ro.product.model="PWN" \
ro.product.name="PWN" 

After that, I compile the source code. 之后,我编译源代码。 But the result is weird. 但是结果很奇怪。 I can see that the system/build.prop has changed. 我可以看到system / build.prop已更改。

# begin build properties
# autogenerated by buildinfo.sh   
ro.build.id=N2G47F
ro.build.display.id=aosp_arm-eng 7.1.2 N2G47F eng.sam.20180525.204329 
test-keys 
ro.build.version.incremental=eng.sam.20180525.204329
ro.build.version.sdk=25
ro.build.version.preview_sdk=0
ro.build.version.codename=REL
ro.build.version.all_codenames=REL
ro.build.version.release=7.1.2
ro.build.version.security_patch=2017-04-05
ro.build.version.base_os=
ro.build.date=Fri May 25 20:43:29 CST 2018
ro.build.date.utc=1527252209
ro.build.type=eng
ro.build.user=sam
ro.build.host=ubuntu
ro.build.tags=test-keys
ro.build.flavor=aosp_arm-eng
ro.product.model=AOSP on ARM Emulator
ro.product.brand=Android
ro.product.name=aosp_arm
ro.product.device=generic
ro.product.board=
# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,
# use ro.product.cpu.abilist instead.
ro.product.cpu.abi=armeabi-v7a
ro.product.cpu.abi2=armeabi
ro.product.cpu.abilist=armeabi-v7a,armeabi
ro.product.cpu.abilist32=armeabi-v7a,armeabi
ro.product.cpu.abilist64=
ro.product.manufacturer=unknown
ro.product.locale=en-US
ro.wifi.channels=
ro.board.platform=
# ro.build.product is obsolete; use ro.product.device
ro.build.product=generic
# Do not try to parse description, fingerprint, or thumbprint
ro.build.description=aosp_arm-eng 7.1.2 N2G47F eng.sam.20180525.204329 
test-keys


ro.build.characteristics=emulator
# end build properties
#
# from build/target/board/generic/system.prop
#
#
# system.prop for generic sdk
#

rild.libpath=/system/lib/libreference-ril.so
rild.libargs=-d /dev/ttyS0

#
# ADDITIONAL_BUILD_PROPERTIES
#
keyguard.no_require_sim=true
ro.com.android.dataroaming=true
ro.config.ringtone=Ring_Synth_04.ogg
ro.config.notification_sound=pixiedust.ogg
ro.carrier=unknown
ro.bootloader=PWN
ro.bootmode=PWN
ro.hardware=PWN
ro.kernel.qemu=PWN
ro.product.device=PWN
ro.product.model=PWN
ro.product.name=PWN
ro.config.alarm_alert=Alarm_Classic.ogg
ro.ril.hsxpa=1
ro.ril.gprsclass=10
ro.adb.qemud=1
persist.sys.dalvik.vm.lib.2=libart.so
dalvik.vm.isa.arm.variant=generic
dalvik.vm.isa.arm.features=default
ro.kernel.android.checkjni=1
dalvik.vm.lockprof.threshold=500
dalvik.vm.image-dex2oat-filter=verify-at-runtime
net.bt.name=Android
dalvik.vm.stack-trace-file=/data/anr/traces.txt

Clearly, I overwrite the properties. 显然,我覆盖了属性。 But when I tried getprop in abd shell the output is this: 但是当我在abd shell中尝试getprop时,输出是这样的:

[ro.product.device]: [generic]
[ro.product.locale]: [en-US]
[ro.product.manufacturer]: [unknown]
[ro.product.model]: [AOSP on ARM Emulator]
[ro.product.name]: [aosp_arm]

[ro.bootloader]: [unknown]
[ro.bootmode]: [unknown]

I only list a few here but we can see that none of those properties changed. 我在这里只列出了一些,但是我们可以看到这些属性都没有改变。 This is weird. 真奇怪 Since init should read from build.prop when it starts. 由于init启动时应从build.prop中读取。 Someone told me to recompile the whole system instead of only compile the sdk. 有人告诉我重新编译整个系统,而不是仅编译sdk。 I just compiled the whole system but it failed again. 我只是编译了整个系统,但是又失败了。 The same problem here. 同样的问题在这里。 I am using nougat 7.1.2_r3. 我正在使用牛轧糖7.1.2_r3。 Any help? 有什么帮助吗?

If you search the aosp build directory for some of these properties you will see the are set by makefile variables. 如果在aosp build目录中搜索这些属性中的某些属性,则将看到由makefile变量设置。 For example in build/make/tools/buildinfo.sh you can see the line: 例如,在build/make/tools/buildinfo.sh您可以看到以下行:

echo "ro.product.model=$PRODUCT_MODEL"

How it works is a little more complex but the point is that you need to set PRODUCT_MODEL in your <device>.mk file like Google suggests in their documentation here: https://source.android.com/setup/develop/new-device 它的工作原理稍微复杂一点,但要点是您需要像Google在其文档中建议的那样在<device>.mk文件中设置PRODUCT_MODEL网址为https://source.android.com/setup/develop/new-设备

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM