1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_DEXOPT_CHROOT_SETUP_DEXOPT_CHROOT_SETUP_H_ 18 #define ART_DEXOPT_CHROOT_SETUP_DEXOPT_CHROOT_SETUP_H_ 19 20 #include <optional> 21 #include <string> 22 23 #include "aidl/com/android/server/art/BnDexoptChrootSetup.h" 24 #include "android-base/result.h" 25 #include "android-base/thread_annotations.h" 26 27 namespace art { 28 namespace dexopt_chroot_setup { 29 30 // A comma-separated list, where each entry is a colon-separated pair of a partition name in the 31 // super image and a mount point. E.g., 32 // some_partition_1:/some_mount_point_1,some_partition_2:/some_mount_point_2 33 constexpr const char* kAdditionalPartitionsSysprop = 34 "dalvik.vm.pr_dexopt_additional_system_partitions"; 35 36 // A service that sets up the chroot environment for Pre-reboot Dexopt. 37 class DexoptChrootSetup : public aidl::com::android::server::art::BnDexoptChrootSetup { 38 public: 39 ndk::ScopedAStatus setUp(const std::optional<std::string>& in_otaSlot, 40 bool in_mapSnapshotsForOta) override; 41 42 ndk::ScopedAStatus init() override; 43 44 ndk::ScopedAStatus tearDown(bool in_allowConcurrent) override; 45 46 android::base::Result<void> Start(); 47 48 private: 49 android::base::Result<void> SetUpChroot(const std::optional<std::string>& ota_slot, 50 bool map_snapshots_for_ota) const REQUIRES(mu_); 51 52 android::base::Result<void> InitChroot() const REQUIRES(mu_); 53 54 android::base::Result<void> TearDownChroot() const REQUIRES(mu_); 55 56 std::mutex mu_; 57 }; 58 59 std::string PathInChroot(std::string_view path); 60 61 android::base::Result<std::string> ConstructLinkerConfigCompatEnvSection( 62 const std::string& art_linker_config_content); 63 64 } // namespace dexopt_chroot_setup 65 } // namespace art 66 67 #endif // ART_DEXOPT_CHROOT_SETUP_DEXOPT_CHROOT_SETUP_H_ 68