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 service that sets up the chroot environment for Pre-reboot Dexopt. 31 class DexoptChrootSetup : public aidl::com::android::server::art::BnDexoptChrootSetup { 32 public: 33 ndk::ScopedAStatus setUp(const std::optional<std::string>& in_otaSlot, 34 bool in_mapSnapshotsForOta) override; 35 36 ndk::ScopedAStatus init() override; 37 38 ndk::ScopedAStatus tearDown() override; 39 40 android::base::Result<void> Start(); 41 42 private: 43 android::base::Result<void> SetUpChroot(const std::optional<std::string>& ota_slot, 44 bool map_snapshots_for_ota) const REQUIRES(mu_); 45 46 android::base::Result<void> InitChroot() const REQUIRES(mu_); 47 48 android::base::Result<void> TearDownChroot() const REQUIRES(mu_); 49 50 std::mutex mu_; 51 }; 52 53 std::string PathInChroot(std::string_view path); 54 55 } // namespace dexopt_chroot_setup 56 } // namespace art 57 58 #endif // ART_DEXOPT_CHROOT_SETUP_DEXOPT_CHROOT_SETUP_H_ 59