OSDN Git Service

property_contexts: split into platform and non-platform components
authorSandeep Patil <sspatil@google.com>
Wed, 28 Dec 2016 01:37:44 +0000 (17:37 -0800)
committerSandeep Patil <sspatil@google.com>
Fri, 27 Jan 2017 21:12:32 +0000 (13:12 -0800)
Bug: 33746484
Bug: 34370523
Test: Successfully boot with original service and property contexts.
Test: Successfully boot with split serivce and property contexts.
Test: Incremental build works on sailfish (reported in b/34370523)
Test: adb sideload works with aosp updater (reported in b/34370523)

Change-Id: Idf24856193032a8bc89ec384a72451e578a9d5ac
Signed-off-by: Sandeep Patil <sspatil@google.com>
libc/bionic/system_properties.cpp

index 96a4017..1d26a13 100644 (file)
@@ -1017,9 +1017,8 @@ static int read_spec_entries(char *line_buf, int num_args, ...)
     return items;
 }
 
-static bool initialize_properties() {
-    FILE* file = fopen("/property_contexts", "re");
-
+static bool initialize_properties_from_file(const char *filename) {
+    FILE* file = fopen(filename, "re");
     if (!file) {
         return false;
     }
@@ -1063,6 +1062,27 @@ static bool initialize_properties() {
 
     free(buffer);
     fclose(file);
+
+    return true;
+}
+
+static bool initialize_properties() {
+    // If we do find /property_contexts, then this is being
+    // run as part of the OTA updater on older release that had
+    // /property_contexts - b/34370523
+    if (initialize_properties_from_file("/property_contexts")) {
+        return true;
+    }
+
+    // TODO: Change path to /system/property_contexts after b/27805372
+    if (!initialize_properties_from_file("/plat_property_contexts")) {
+        return false;
+    }
+
+    // TODO: Change path to /vendor/property_contexts after b/27805372
+    // device-specific property context is optional, so load if it exists.
+    initialize_properties_from_file("/nonplat_property_contexts");
+
     return true;
 }