Jiakai Zhang | 6b9e344 | 2022-06-06 19:57:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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_ARTD_PATH_UTILS_H_ |
| 18 | #define ART_ARTD_PATH_UTILS_H_ |
| 19 | |
| 20 | #include "aidl/com/android/server/art/BnArtd.h" |
| 21 | #include "android-base/result.h" |
Jiakai Zhang | 3aaecf0 | 2022-08-10 15:35:28 +0100 | [diff] [blame] | 22 | #include "base/file_utils.h" |
Jiakai Zhang | 6b9e344 | 2022-06-06 19:57:38 +0100 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | namespace artd { |
| 26 | |
Jiakai Zhang | 3aaecf0 | 2022-08-10 15:35:28 +0100 | [diff] [blame] | 27 | android::base::Result<void> ValidateDexPath(const std::string& dex_path); |
| 28 | |
| 29 | android::base::Result<std::string> BuildArtBinPath(const std::string& binary_name); |
| 30 | |
Jiakai Zhang | 6b9e344 | 2022-06-06 19:57:38 +0100 | [diff] [blame] | 31 | // Returns the absolute path to the OAT file built from the `ArtifactsPath`. |
| 32 | android::base::Result<std::string> BuildOatPath( |
| 33 | const aidl::com::android::server::art::ArtifactsPath& artifacts_path); |
| 34 | |
| 35 | // Returns the path to the VDEX file that corresponds to the OAT file. |
Jiakai Zhang | 3aaecf0 | 2022-08-10 15:35:28 +0100 | [diff] [blame] | 36 | inline std::string OatPathToVdexPath(const std::string& oat_path) { |
| 37 | return ReplaceFileExtension(oat_path, "vdex"); |
| 38 | } |
Jiakai Zhang | 6b9e344 | 2022-06-06 19:57:38 +0100 | [diff] [blame] | 39 | |
| 40 | // Returns the path to the ART file that corresponds to the OAT file. |
Jiakai Zhang | 3aaecf0 | 2022-08-10 15:35:28 +0100 | [diff] [blame] | 41 | inline std::string OatPathToArtPath(const std::string& oat_path) { |
| 42 | return ReplaceFileExtension(oat_path, "art"); |
| 43 | } |
| 44 | |
Jiakai Zhang | ca32797 | 2022-10-18 10:59:10 +0100 | [diff] [blame] | 45 | android::base::Result<std::string> BuildPrimaryRefProfilePath( |
| 46 | const aidl::com::android::server::art::ProfilePath::PrimaryRefProfilePath& |
| 47 | primary_ref_profile_path); |
Jiakai Zhang | 8ef6b6c | 2022-08-10 17:28:41 +0100 | [diff] [blame] | 48 | |
| 49 | android::base::Result<std::string> BuildPrebuiltProfilePath( |
| 50 | const aidl::com::android::server::art::ProfilePath::PrebuiltProfilePath& prebuilt_profile_path); |
| 51 | |
Jiakai Zhang | ca32797 | 2022-10-18 10:59:10 +0100 | [diff] [blame] | 52 | android::base::Result<std::string> BuildPrimaryCurProfilePath( |
| 53 | const aidl::com::android::server::art::ProfilePath::PrimaryCurProfilePath& |
| 54 | primary_cur_profile_path); |
| 55 | |
| 56 | android::base::Result<std::string> BuildSecondaryRefProfilePath( |
| 57 | const aidl::com::android::server::art::ProfilePath::SecondaryRefProfilePath& |
| 58 | secondary_ref_profile_path); |
| 59 | |
| 60 | android::base::Result<std::string> BuildSecondaryCurProfilePath( |
| 61 | const aidl::com::android::server::art::ProfilePath::SecondaryCurProfilePath& |
| 62 | secondary_cur_profile_path); |
| 63 | |
| 64 | android::base::Result<std::string> BuildFinalProfilePath( |
| 65 | const aidl::com::android::server::art::ProfilePath::TmpProfilePath& tmp_profile_path); |
| 66 | |
| 67 | android::base::Result<std::string> BuildTmpProfilePath( |
| 68 | const aidl::com::android::server::art::ProfilePath::TmpProfilePath& tmp_profile_path); |
Jiakai Zhang | ab3f419 | 2022-09-23 13:14:18 +0100 | [diff] [blame] | 69 | |
Jiakai Zhang | 3aaecf0 | 2022-08-10 15:35:28 +0100 | [diff] [blame] | 70 | android::base::Result<std::string> BuildDexMetadataPath( |
| 71 | const aidl::com::android::server::art::DexMetadataPath& dex_metadata_path); |
| 72 | |
Jiakai Zhang | 8ef6b6c | 2022-08-10 17:28:41 +0100 | [diff] [blame] | 73 | android::base::Result<std::string> BuildProfileOrDmPath( |
| 74 | const aidl::com::android::server::art::ProfilePath& profile_path); |
| 75 | |
Jiakai Zhang | 3aaecf0 | 2022-08-10 15:35:28 +0100 | [diff] [blame] | 76 | android::base::Result<std::string> BuildVdexPath( |
| 77 | const aidl::com::android::server::art::VdexPath& vdex_path); |
Jiakai Zhang | 6b9e344 | 2022-06-06 19:57:38 +0100 | [diff] [blame] | 78 | |
| 79 | } // namespace artd |
| 80 | } // namespace art |
| 81 | |
| 82 | #endif // ART_ARTD_PATH_UTILS_H_ |