1.ro.serialno不存在於任何屬性文件,好比build.prop, default.prop等,而是在/system/core/init/init.c裏由ro.boot.serialno 轉換而來,見export_kernel_boot_props()。linux
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 bionicandroid
獲取到的前提是以前已經有設置好,也就是有調用property_set() in init.cionic
4.其餘相似ro屬性還有: ro.boot.mode ro.boot.baseband ro.boot.bootloader ro.boot.hardwareide
static void export_kernel_boot_props(void) { char tmp[PROP_VALUE_MAX]; int ret; unsigned i; struct { const char *src_prop; const char *dest_prop; const char *def_val; } prop_map[] = { { "ro.boot.serialno", "ro.serialno", "", }, { "ro.boot.mode", "ro.bootmode", "unknown", }, { "ro.boot.baseband", "ro.baseband", "unknown", }, { "ro.boot.bootloader", "ro.bootloader", "unknown", }, };ui
for (i = 0; i < ARRAY_SIZE(prop_map); i++) { ret = property_get(prop_map[i].src_prop, tmp); if (ret > 0) property_set(prop_map[i].dest_prop, tmp); else property_set(prop_map[i].dest_prop, prop_map[i].def_val); } ret = property_get("ro.boot.console", tmp); if (ret) strlcpy(console, tmp, sizeof(console)); /* save a copy for init's usage during boot */ property_get("ro.bootmode", tmp); strlcpy(bootmode, tmp, sizeof(bootmode)); /* if this was given on kernel command line, override what we read * before (e.g. from /proc/cpuinfo), if anything */ ret = property_get("ro.boot.hardware", tmp); if (ret) strlcpy(hardware, tmp, sizeof(hardware)); property_set("ro.hardware", hardware); snprintf(tmp, PROP_VALUE_MAX, "%d", revision); property_set("ro.revision", tmp);
摘自Android Kitkat 4.4this