• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 ANDROID_APEXD_APEX_CLASSPATH_H_
18 #define ANDROID_APEXD_APEX_CLASSPATH_H_
19 
20 #include <android-base/result.h>
21 
22 #include <set>
23 #include <string>
24 
25 namespace android {
26 namespace apex {
27 
28 /**
29  * An utility class that contains logic to extract classpath fragments
30  * information from mounted APEX.
31  *
32  * The bulk of the work is done by derive_classpath binary, which is found
33  * inside sdkext module. This class is a wrapper for calling that binary and
34  * parsing its string output into a structured object.
35  */
36 class ClassPath {
37   static constexpr const char* kSdkExtModuleName = "com.android.sdkext";
38 
39  public:
40   static android::base::Result<ClassPath> DeriveClassPath(
41       const std::vector<std::string>& temp_mounted_apex_paths,
42       const std::string& sdkext_module_name = kSdkExtModuleName);
43 
44   bool HasClassPathJars(const std::string& package);
45 
46   // Exposed for testing only
47   static android::base::Result<ClassPath> ParseFromFile(
48       const std::string& file_path);
49 
50  private:
51   void AddPackageWithClasspathJars(const std::string& package);
52 
53   std::set<std::string> packages_with_classpath_jars;
54 };
55 
56 }  // namespace apex
57 }  // namespace android
58 
59 #endif  // ANDROID_APEXD_APEXD_CHECKPOINT_H_
60