• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <string>
21 #include <vector>
22 
23 #include "aidl/com/android/server/art/BnArtd.h"
24 #include "android-base/result.h"
25 #include "base/file_utils.h"
26 
27 namespace art {
28 namespace artd {
29 
30 // Returns all existing files that are managed by artd.
31 android::base::Result<std::vector<std::string>> ListManagedFiles();
32 
33 android::base::Result<void> ValidateDexPath(const std::string& dex_path);
34 
35 android::base::Result<std::string> BuildArtBinPath(const std::string& binary_name);
36 
37 // Returns the absolute path to the OAT file built from the `ArtifactsPath`.
38 android::base::Result<std::string> BuildOatPath(
39     const aidl::com::android::server::art::ArtifactsPath& artifacts_path);
40 
41 // Returns the path to the VDEX file that corresponds to the OAT file.
OatPathToVdexPath(const std::string & oat_path)42 inline std::string OatPathToVdexPath(const std::string& oat_path) {
43   return ReplaceFileExtension(oat_path, "vdex");
44 }
45 
46 // Returns the path to the ART file that corresponds to the OAT file.
OatPathToArtPath(const std::string & oat_path)47 inline std::string OatPathToArtPath(const std::string& oat_path) {
48   return ReplaceFileExtension(oat_path, "art");
49 }
50 
51 android::base::Result<std::string> BuildPrimaryRefProfilePath(
52     const aidl::com::android::server::art::ProfilePath::PrimaryRefProfilePath&
53         primary_ref_profile_path);
54 
55 android::base::Result<std::string> BuildPrebuiltProfilePath(
56     const aidl::com::android::server::art::ProfilePath::PrebuiltProfilePath& prebuilt_profile_path);
57 
58 android::base::Result<std::string> BuildPrimaryCurProfilePath(
59     const aidl::com::android::server::art::ProfilePath::PrimaryCurProfilePath&
60         primary_cur_profile_path);
61 
62 android::base::Result<std::string> BuildSecondaryRefProfilePath(
63     const aidl::com::android::server::art::ProfilePath::SecondaryRefProfilePath&
64         secondary_ref_profile_path);
65 
66 android::base::Result<std::string> BuildSecondaryCurProfilePath(
67     const aidl::com::android::server::art::ProfilePath::SecondaryCurProfilePath&
68         secondary_cur_profile_path);
69 
70 android::base::Result<std::string> BuildFinalProfilePath(
71     const aidl::com::android::server::art::ProfilePath::TmpProfilePath& tmp_profile_path);
72 
73 android::base::Result<std::string> BuildTmpProfilePath(
74     const aidl::com::android::server::art::ProfilePath::TmpProfilePath& tmp_profile_path);
75 
76 android::base::Result<std::string> BuildDexMetadataPath(
77     const aidl::com::android::server::art::DexMetadataPath& dex_metadata_path);
78 
79 android::base::Result<std::string> BuildProfileOrDmPath(
80     const aidl::com::android::server::art::ProfilePath& profile_path);
81 
82 android::base::Result<std::string> BuildVdexPath(
83     const aidl::com::android::server::art::VdexPath& vdex_path);
84 
85 }  // namespace artd
86 }  // namespace art
87 
88 #endif  // ART_ARTD_PATH_UTILS_H_
89