是由 system/core/init/property_service.c 負責的,包括系統 prop 的初始,之後回答app 的詢問,設定/變更 prop。
init.c 的 main 啟動後,create, setup 好需要的 system folder。
之後,就先:
void property_init(void)
{
init_property_area();
load_properties_from_file(PROP_PATH_RAMDISK_DEFAULT);
}
然後再 call
void start_property_service(void)
{
int fd;
load_properties_from_file(PROP_PATH_SYSTEM_BUILD);
load_properties_from_file(PROP_PATH_SYSTEM_DEFAULT);
load_properties_from_file(PROP_PATH_LOCAL_OVERRIDE);
/* Read persistent properties after all default values have been loaded. */
load_persistent_properties();
所以 prop 讀取,設定的順序是:
- PROP_PATH_RAMDISK_DEFAULT : /default.prop
- PROP_PATH_SYSTEM_BUILD : /system/build.prop
- PROP_PATH_SYSTEM_DEFAULT : /system/default.prop
- PROP_PATH_LOCAL_OVERRIDE : /data/local.prop
- PERSISTENT_PROPERTY_DIR/persist.*
應該要放在 /data/local.prop,這樣使用 factory reset 後,自己的設定會被刪掉。
真正的恢復出廠狀態。
要是想要增加自己的 prop 設定檔,可以修改 property_service.c ,
y 增加一個 load_properties_from_file(PROP_PATH_MYPROP);
* 以上的 path 定義在 /bionic/libc/include/sys/_system_properties.h
現在產品的作法是改 Makefile..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/Makefile b/core/Makefile | |
index a1428ed..ec64ced 100644 | |
--- a/core/Makefile | |
+++ b/core/Makefile | |
@@ -117,10 +117,9 @@ endef | |
define default-locale-region | |
$(word 3, 3, $(call default-locale, $(1))) | |
endef | |
- | |
BUILDINFO_SH := build/tools/buildinfo.sh | |
$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) | |
- @echo Target buildinfo: $@ | |
+ @echo Target buildinfo: $(PRODUCT_OUT)/myset.prop | |
@mkdir -p $(dir $@) | |
$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ | |
TARGET_DEVICE="$(TARGET_DEVICE)" \ | |
@@ -145,6 +144,9 @@ $(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) | |
TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \ | |
TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \ | |
bash $(BUILDINFO_SH) > $@ | |
+ $(hide) if [ -f $(PRODUCT_OUT)/myset.prop ]; then \ | |
+ cat $(PRODUCT_OUT)/myset.prop >> $@; \ | |
+ fi | |
$(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \ | |
cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \ |
沒有留言:
張貼留言