From 527d80d945e7b53e53bcc4d42900b3bce228f5d1 Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Fri, 2 Jun 2017 18:59:46 +0800 Subject: Load default prop from /system/etc/prop.default /default.prop is moved to /system/etc/prop.default for full Treblized devices. Modifies property_service to load it from there first. In recovery mode, the file is renamed as /prop.default. This path is tried if /system/etc/prop.default is not available. Bug: 37815285 Test: Tested with ag/2419001. Booted pixel phones, checked the location of prop.default, verified the symlink at /default.prop, checked a few properties via adb shell and manually tested a few apps. Booted to recovery and ran 'adb sideload' successfully. Change-Id: I485231f21fc86b0aec58edf867e229a31e77d85e --- init/property_service.cpp | 15 +++++++++++---- libcutils/fs_config.cpp | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 3490544c8..20f21a950 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -443,7 +443,7 @@ static void handle_property_set_fd() { } } -static void load_properties_from_file(const char *, const char *); +static bool load_properties_from_file(const char *, const char *); /* * Filter is used to decide which properties to load: NULL loads all keys, @@ -507,17 +507,18 @@ static void load_properties(char *data, const char *filter) // Filter is used to decide which properties to load: NULL loads all keys, // "ro.foo.*" is a prefix match, and "ro.foo.bar" is an exact match. -static void load_properties_from_file(const char* filename, const char* filter) { +static bool load_properties_from_file(const char* filename, const char* filter) { Timer t; std::string data; std::string err; if (!ReadFile(filename, &data, &err)) { PLOG(WARNING) << "Couldn't load property file: " << err; - return; + return false; } data.push_back('\n'); load_properties(&data[0], filter); LOG(VERBOSE) << "(Loading properties from " << filename << " took " << t << ".)"; + return true; } static void load_persistent_properties() { @@ -592,7 +593,13 @@ static void update_sys_usb_config() { } void property_load_boot_defaults() { - load_properties_from_file("/default.prop", NULL); + if (!load_properties_from_file("/system/etc/prop.default", NULL)) { + // Try recovery path + if (!load_properties_from_file("/prop.default", NULL)) { + // Try legacy path + load_properties_from_file("/default.prop", NULL); + } + } load_properties_from_file("/odm/default.prop", NULL); load_properties_from_file("/vendor/default.prop", NULL); diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp index 221dea268..c39071cb0 100644 --- a/libcutils/fs_config.cpp +++ b/libcutils/fs_config.cpp @@ -134,7 +134,8 @@ static const struct fs_path_config android_files[] = { { 00640, AID_ROOT, AID_SHELL, 0, "data/nativetest64/tests.txt" }, { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest/*" }, { 00750, AID_ROOT, AID_SHELL, 0, "data/nativetest64/*" }, - { 00600, AID_ROOT, AID_ROOT, 0, "default.prop" }, + { 00600, AID_ROOT, AID_ROOT, 0, "default.prop" }, // legacy + { 00600, AID_ROOT, AID_ROOT, 0, "system/etc/prop.default" }, { 00600, AID_ROOT, AID_ROOT, 0, "odm/build.prop" }, { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" }, { 00444, AID_ROOT, AID_ROOT, 0, odm_conf_dir + 1 }, -- cgit v1.2.3-54-g00ecf