diff options
-rw-r--r-- | artd/Android.bp | 7 | ||||
-rw-r--r-- | build/apex/Android.bp | 10 | ||||
-rw-r--r-- | build/apex/art.rc (renamed from artd/artd.rc) | 8 | ||||
-rwxr-xr-x | build/apex/art_apex_test.py | 1 | ||||
-rw-r--r-- | tools/Android.bp | 11 | ||||
-rw-r--r-- | tools/art_boot.cc | 55 |
6 files changed, 83 insertions, 9 deletions
diff --git a/artd/Android.bp b/artd/Android.bp index b4518c91d0..1288ebcf25 100644 --- a/artd/Android.bp +++ b/artd/Android.bp @@ -61,13 +61,6 @@ art_cc_binary { ], } -prebuilt_etc { - name: "com.android.art.artd.init.rc", - src: "artd.rc", - filename: "init.rc", - installable: false, -} - art_cc_defaults { name: "art_artd_tests_defaults", defaults: ["artd_defaults"], diff --git a/build/apex/Android.bp b/build/apex/Android.bp index 2a76057e02..d5349b6229 100644 --- a/build/apex/Android.bp +++ b/build/apex/Android.bp @@ -252,6 +252,13 @@ art_module_apex_defaults { }, } +prebuilt_etc { + name: "com.android.art.init.rc", + src: "art.rc", + filename: "init.rc", + installable: false, +} + // Default values shared by device ART APEXes. apex_defaults { name: "com.android.art-device-defaults-minus-odrefresh", @@ -271,6 +278,7 @@ apex_defaults { "libartservice", ], binaries: [ + "art_boot", "art_exec", "artd", ], @@ -291,7 +299,7 @@ apex_defaults { ], prebuilts: [ "art-linker-config", - "com.android.art.artd.init.rc", + "com.android.art.init.rc", "current_sdkinfo", ], // ART APEXes depend on bouncycastle which is disabled for PDK builds. diff --git a/artd/artd.rc b/build/apex/art.rc index 5ddfcdc219..6f3a5e878d 100644 --- a/artd/artd.rc +++ b/build/apex/art.rc @@ -1,4 +1,4 @@ -# Copyright (C) 2021 The Android Open Source Project +# Copyright (C) 2023 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,3 +21,9 @@ service artd /apex/com.android.art/bin/artd user artd group artd capabilities DAC_OVERRIDE DAC_READ_SEARCH FOWNER CHOWN + +service art_boot /apex/com.android.art/bin/art_boot + oneshot + class core + seclabel u:r:su:s0 + user root diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py index 70f1da039b..c2549cc93e 100755 --- a/build/apex/art_apex_test.py +++ b/build/apex/art_apex_test.py @@ -550,6 +550,7 @@ class ReleaseTargetChecker: # removed in Android R. # Check binaries for ART. + self._checker.check_executable('art_boot') self._checker.check_executable('art_exec') self._checker.check_executable('artd') self._checker.check_executable('oatdump') diff --git a/tools/Android.bp b/tools/Android.bp index 7ffa672a14..207a121848 100644 --- a/tools/Android.bp +++ b/tools/Android.bp @@ -37,6 +37,17 @@ soong_config_module_type_import { ], } +cc_binary { + name: "art_boot", + defaults: ["art_defaults"], + srcs: ["art_boot.cc"], + shared_libs: ["libbase"], + apex_available: [ + "com.android.art", + "com.android.art.debug", + ], +} + // Copy the art shell script to the host and target's bin directory art_module_sh_binary { name: "art-script", diff --git a/tools/art_boot.cc b/tools/art_boot.cc new file mode 100644 index 0000000000..f725fc828e --- /dev/null +++ b/tools/art_boot.cc @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This binary is run on boot as a oneshot service. It should not be run at any +// other point. + +#include <string> + +#include "android-base/logging.h" +#include "android-base/properties.h" + +// Copies the value of one system property to another if it isn't empty and +// passes the predicate test_fn. +static void CopyPropertyIf(const char* src, const char* dst, bool (*test_fn)(const std::string&)) { + std::string prop = android::base::GetProperty(src, ""); + if (prop.empty()) { + LOG(INFO) << "Property " << src << " not set"; + } else if (!test_fn(prop)) { + LOG(INFO) << "Property " << src << " has ignored value " << prop; + } else { + if (android::base::SetProperty(dst, prop)) { + LOG(INFO) << "Set property " << dst << " to " << prop << " from " << src; + } else { + LOG(ERROR) << "Failed to set property " << dst << " to " << prop; + } + } +} + +int main(int, char** argv) { + android::base::InitLogging(argv); + + // Copy properties that must only be set at boot and not change value later. + // Note that P/H can change the properties in the experiment namespaces at any + // time. + CopyPropertyIf("persist.device_config.runtime_native_boot.useartservice", + "dalvik.vm.useartservice", + // If an OEM has set dalvik.vm.useartservice to false we + // shouldn't override it to true from the P/H property. + [](const std::string& prop) { return prop == "false"; }); + + return 0; +} |