http://my.oschina.net/u/996206/blog/215960
1.ro.serialno不存在于任何属性文件,比如build.prop, default.prop等,而是在/system/core/init/init.c里由ro.boot.serialno 转换而来,见export_kernel_boot_props()。
2.而ro.boot.serialno的来源是/proc/cmdline,也就是linux kernel启动时被传入的cmdline, 由bootloader传入。
bootloader传进来的是androidboot.serialno, 而不是ro.boot.serialno,因为还要解析过cmdline
3.ro.serialno的用处是来保存唯一设备号,在settings->about->status里会显示,也会用在USB device name里。
about->status 里获取serialno的流程:
Build.SERIAL
->getString(“ro.serialno”)
->SystemProperties.get()
->SystemProperties.native_get()
->SystemProperties_getSS() in android_os_SystemProperties.cpp
->property_get() in Properties.c
->__system_property_get() in System_properties.c in bionic
获取到的前提是之前已经有设置好,也就是有调用property_set() in init.c
4.其他类似ro属性还有:
ro.boot.mode
ro.boot.baseband
ro.boot.bootloader
ro.boot.hardware
|
emmc has a unique serialno to mark the device/emmc.
there are 2 method to get the serialno for device/EMMC, this is useful to mark the device when doing stabilty tests. 1. boot your device to fastboot yingangl@yingangl-work:~$ fastboot getvar serialno serialno: aaa035df finished. total time: 0.002s 2. in kernel cd /sys/class/mmc_host/mmc0/mmc0:0001 cat serial 0xaaa035df The ro.serialno system property contains the product serial number. LK bootloader reads the "Product serial number (psn)" from the mmc card and add this to the kernel command line as a property "androidboot.serialno=<psn>". For more details check function target_serialno(), File: lk/target/msm952/init.c The kernel command line will be further parsed by the "init" process and will set system property as ro.serialno=<psn>. For code details check function: static void export_kernel_boot_props(void) (system/core/init/init.c) kernel command line is parsed by : import_kernel_nv() in init.c If you want to reset the ro.serialno system property temporarily, then you can reset in function export_kernel_boot_props() like shown below: + property_set("ro.serialno","<WRITE YOUR VALUE>"); ret = property_get("ro.boot.console", tmp); if (ret) strlcpy(console, tmp, sizeof(console)); |
本文深入探讨了Android系统中用于唯一标识设备的ro.serialno属性的生成过程及其在不同场景下的获取方式,包括通过fastboot命令和内核文件系统的直接读取。同时解释了ro.boot.serialno的来源及其在设备启动时的作用。

5576

被折叠的 条评论
为什么被折叠?



