blob: 0cc017ea8303f54b3666f41571e4be03c22f77e5 [file] [log] [blame]
Jiakai Zhang6b9e3442022-06-06 19:57:38 +01001/*
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 Zhang3aaecf02022-08-10 15:35:28 +010022#include "base/file_utils.h"
Jiakai Zhang6b9e3442022-06-06 19:57:38 +010023
24namespace art {
25namespace artd {
26
Jiakai Zhang3aaecf02022-08-10 15:35:28 +010027android::base::Result<void> ValidateDexPath(const std::string& dex_path);
28
29android::base::Result<std::string> BuildArtBinPath(const std::string& binary_name);
30
Jiakai Zhang6b9e3442022-06-06 19:57:38 +010031// Returns the absolute path to the OAT file built from the `ArtifactsPath`.
32android::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 Zhang3aaecf02022-08-10 15:35:28 +010036inline std::string OatPathToVdexPath(const std::string& oat_path) {
37 return ReplaceFileExtension(oat_path, "vdex");
38}
Jiakai Zhang6b9e3442022-06-06 19:57:38 +010039
40// Returns the path to the ART file that corresponds to the OAT file.
Jiakai Zhang3aaecf02022-08-10 15:35:28 +010041inline std::string OatPathToArtPath(const std::string& oat_path) {
42 return ReplaceFileExtension(oat_path, "art");
43}
44
Jiakai Zhangca327972022-10-18 10:59:10 +010045android::base::Result<std::string> BuildPrimaryRefProfilePath(
46 const aidl::com::android::server::art::ProfilePath::PrimaryRefProfilePath&
47 primary_ref_profile_path);
Jiakai Zhang8ef6b6c2022-08-10 17:28:41 +010048
49android::base::Result<std::string> BuildPrebuiltProfilePath(
50 const aidl::com::android::server::art::ProfilePath::PrebuiltProfilePath& prebuilt_profile_path);
51
Jiakai Zhangca327972022-10-18 10:59:10 +010052android::base::Result<std::string> BuildPrimaryCurProfilePath(
53 const aidl::com::android::server::art::ProfilePath::PrimaryCurProfilePath&
54 primary_cur_profile_path);
55
56android::base::Result<std::string> BuildSecondaryRefProfilePath(
57 const aidl::com::android::server::art::ProfilePath::SecondaryRefProfilePath&
58 secondary_ref_profile_path);
59
60android::base::Result<std::string> BuildSecondaryCurProfilePath(
61 const aidl::com::android::server::art::ProfilePath::SecondaryCurProfilePath&
62 secondary_cur_profile_path);
63
64android::base::Result<std::string> BuildFinalProfilePath(
65 const aidl::com::android::server::art::ProfilePath::TmpProfilePath& tmp_profile_path);
66
67android::base::Result<std::string> BuildTmpProfilePath(
68 const aidl::com::android::server::art::ProfilePath::TmpProfilePath& tmp_profile_path);
Jiakai Zhangab3f4192022-09-23 13:14:18 +010069
Jiakai Zhang3aaecf02022-08-10 15:35:28 +010070android::base::Result<std::string> BuildDexMetadataPath(
71 const aidl::com::android::server::art::DexMetadataPath& dex_metadata_path);
72
Jiakai Zhang8ef6b6c2022-08-10 17:28:41 +010073android::base::Result<std::string> BuildProfileOrDmPath(
74 const aidl::com::android::server::art::ProfilePath& profile_path);
75
Jiakai Zhang3aaecf02022-08-10 15:35:28 +010076android::base::Result<std::string> BuildVdexPath(
77 const aidl::com::android::server::art::VdexPath& vdex_path);
Jiakai Zhang6b9e3442022-06-06 19:57:38 +010078
79} // namespace artd
80} // namespace art
81
82#endif // ART_ARTD_PATH_UTILS_H_