How Android Loads Prop Files At Boot
Aside: props precendence
-
Description of android property system
- Property system implementation
- http://rxwen.blogspot.com/2010/01/android-property-system.html
- https://android.googlesource.com/platform/system/core/+/nougat-release/init/property_service.cpp
- List of prop files, and precedence:
These filenames are defined in bionic/libc/include/sys/_system_properties.h
#define PROP_PATH_RAMDISK_DEFAULT "/default.prop"
#define PROP_PATH_SYSTEM_BUILD "/system/build.prop"
#define PROP_PATH_VENDOR_BUILD "/vendor/build.prop"
#define PROP_PATH_LOCAL_OVERRIDE "/data/local.prop"
#define PROP_PATH_FACTORY "/factory/factory.prop"
The system loads prop files in an order that matches how they become available as the system mounts different filesystems during boot.
- Load properties from the initrd.
Soon after the kernel has started the init process, but before any filesystems have been mounted, init’s main calls property_load_boot_defaults.PROP_PATH_RAMDISK_DEFAULT
/default.prop
- Load properties from the system image.
init continues to boot up and load init.rc, which is written in Android Init Language and fulfills a function similar to SystemD’s unit files.
During on late-init, after mounting filesystems, eventually load_system_props is called.PROP_PATH_SYSTEM_BUILD
/system/build.propPROP_PATH_VENDOR_BUILD
/vendor/build.propPROP_PATH_FACTORY
/factory/factory.prop, only prefix matching “ro.*”
- Load properties from /data.
The system continues to boot up and mounts /data, then calls load_persist_props, which does a couple things: load_override_properties - ifALLOW_LOCAL_PROP_OVERRIDE
(a build-time makefile variable) ANDro.debuggable
are set, thenPROP_PATH_LOCAL_OVERRIDE
“/data/local.prop” load_persistent_properties - looks for files inPERSISTENT_PROPERTY_DIR
“/data/property” starting with “persist.”
- Modifying prop files
- should be done as early as possible
- it may be possible to set a property in default.prop and only have to modify the boot.img where the initrd is.
- If properties are overridden later on, then you have to customize other files.
- Certain files like /data/local.prop are only read if flags are set at build time, and “debugging” mode.