你知道Android USER 版本与ENG 版本差异吗

文摘 Android MediaTek 2020-03-6 阅读:3668

[Description]
Android USER 版本与ENG 版本的差异, 用户版本与工程版本的差异

[Keyword]
USER ENG user eng 用户版本 工程版本 差异

[Solution]
Google 官方描述: USER/USERDEBUG/ENG 版本的差异, 参考alps/build/core/build-system.html 的详细说明
eng This is the default flavor. A plain make is the same as make eng.
*       Installs modules tagged with: eng, debug, user, and/or development.
*       Installs non-APK modules that have no tags specified.
*       Installs APKs according to the product definition files, in addition to tagged APKs.
*       ro.secure=0
*       ro.debuggable=1
*       ro.kernel.android.checkjni=1
*       adb is enabled by default.
*       Setupwizard is optional
user make user
This is the flavor intended to be the final release bits.
*       Installs modules tagged with user.
*       Installs non-APK modules that have no tags specified.
*       Installs APKs according to the product definition files; tags are ignored for APK modules.
*       ro.secure=1
*       ro.debuggable=0
*       adb is disabled by default.
*       Enable dex pre-optimization for all TARGET projects in default to speed up device first boot-up
userdebug make userdebug
The same as user, except:
*       Also installs modules tagged with debug.
*       ro.debuggable=1
*       adb is enabled by default.

MTK 补充说明差异:
(1) Debug/LOG 方面,原则上user 版本只能抓到有限的资讯,eng 可以抓到更多的资讯,Debug 能力更强,推崇使用eng 版本开发测试
*       因ro.debuggable 的差异,eng 版本默认开启了app 的JDWP,以及uart console debug; 相对应的user 版本关闭, 导致在DDMS 上无法看到app process 的列表.
*       MTK System LOG 在ICS 以后,在user 版本默认关闭全部LOG, 在eng 版本中默认打开,以便抓到完整的资讯
*       在eng 版本上,LOG 量 >= user 版本的log 量,一些地方会直接check eng/user 版本来确认是否打印LOG
*       user 版本默认关闭uart, eng 版本默认开启uart
*       在eng 版本上,开启ANR 的predump, 会抓取ftrace,可以得到更多ANR的资讯
*       在eng 版本上,可用rtt 抓取backtrace,可开启kdb 进行kernel debug, 可用ftrace 抓取cpu 执行场景
*       MTK aee 在ENG 版本抓取更多的异常资讯,比如native exception 会抓取core dump 信息
*       eng 版本linux kernel 开启了大量的debug 选项,可以抓取出更多的资讯,如可以使用sysrq-trigger, KDB, User 版本则关闭

(2) 性能方面(Performance),原则上进行性能测试请使用user 版本测试
*       user 版本为提高第一次开机速度,使用了DVM 的预优化,将dex 文件分解成可直接load 运行的odex 文件,eng 版本不会开启这项优化
*       user 版本相关kernel debug 关闭,有利于提高linux kernel 的性能
*       user 版本更少的LOG 打印,更少的debug 代码,以及uart 的关闭,原则上user 版本的性能要优于eng 版本

(3) 安全方面(security)的影响
*       eng 版本默认关闭了adb 的PC RSA指纹验证,而user 版本默认开启, 如果没有验证 PC RSA 指纹, adb 连接时将提升devices offline
*       因user/eng 版本设置ro.secure不同,导致user 版本adb 只拥有shell 权限,而eng 版本具有root 权限

*       eng 版本内置了su, adb 具有root 权限, 导致系统的安全性严重受到影响

(4) 如何确认user/eng 版本
*       Java 层,check android.os.Build 类中的TYPE 值
       native 层,property_get("ro.build.type", char value, "eng"); 然后check value 值
*       Debug 时, adb shell getprop ro.build.type 返回值如果是user 即user 版本,eng 即eng 版本
*       Log 确认,  mobile log/Aplog_xxxxx/versions 中查看ro.build.type 属性

(5) 如何编译user/eng 版本
*       默认编译是eng 版本,如果需要编译user 版本,请加入参数 -o=TARGET_BUILD_VARIANT=user 如:
        ./mk -o=TARGET_BUILD_VARIANT=user mt6595_phone new

0条评论

© 2024 芯缘异码. Powered by Typecho