From c25abe47392f4f86ce3706846995fe6c948caf84 Mon Sep 17 00:00:00 2001 From: Nate Myren Date: Fri, 25 Aug 2023 14:30:50 -0700 Subject: [PATCH] Initialize the appcompat system property folder Certain applications may have their system properties overlaid with the contents overlaid for appcompat purposes. Init must initialize the appcompat folder, same as it does the standard folder. Bug: 291814949 Test: manual Change-Id: I6d239e0a10a1c81a05d4121e5fc2c41da5b3dbc4 Merged-In: I0c6a0f66dc543c6e861bc86a417e4feb5ecd7789 --- init/property_service.cpp | 16 +++++++++++++--- .../property_info_parser/property_info_parser.h | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index cdd0afe8b..21502fb35 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -76,6 +76,10 @@ #include "system/core/init/property_service.pb.h" #include "util.h" +static constexpr char APPCOMPAT_OVERRIDE_PROP_FOLDERNAME[] = + "/dev/__properties__/appcompat_override"; +static constexpr char APPCOMPAT_OVERRIDE_PROP_TREE_FILE[] = + "/dev/__properties__/appcompat_override/property_info"; using namespace std::literals; using android::base::ErrnoError; @@ -1280,11 +1284,17 @@ void CreateSerializedPropertyInfo() { return; } - constexpr static const char kPropertyInfosPath[] = "/dev/__properties__/property_info"; - if (!WriteStringToFile(serialized_contexts, kPropertyInfosPath, 0444, 0, 0, false)) { + if (!WriteStringToFile(serialized_contexts, PROP_TREE_FILE, 0444, 0, 0, false)) { PLOG(ERROR) << "Unable to write serialized property infos to file"; } - selinux_android_restorecon(kPropertyInfosPath, 0); + selinux_android_restorecon(PROP_TREE_FILE, 0); + + mkdir(APPCOMPAT_OVERRIDE_PROP_FOLDERNAME, S_IRWXU | S_IXGRP | S_IXOTH); + if (!WriteStringToFile(serialized_contexts, APPCOMPAT_OVERRIDE_PROP_TREE_FILE, 0444, 0, 0, + false)) { + PLOG(ERROR) << "Unable to write vendor overrides to file"; + } + selinux_android_restorecon(APPCOMPAT_OVERRIDE_PROP_TREE_FILE, 0); } static void ExportKernelBootProps() { diff --git a/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h b/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h index 054802197..65705accb 100644 --- a/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h +++ b/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h @@ -20,6 +20,8 @@ #include #include +static constexpr char PROP_TREE_FILE[] = "/dev/__properties__/property_info"; + namespace android { namespace properties {