xref: /aosp_15_r20/external/cronet/base/android/bundle_utils.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker // Copyright 2019 The Chromium Authors
2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file.
4*6777b538SAndroid Build Coastguard Worker 
5*6777b538SAndroid Build Coastguard Worker #ifndef BASE_ANDROID_BUNDLE_UTILS_H_
6*6777b538SAndroid Build Coastguard Worker #define BASE_ANDROID_BUNDLE_UTILS_H_
7*6777b538SAndroid Build Coastguard Worker 
8*6777b538SAndroid Build Coastguard Worker #include <string>
9*6777b538SAndroid Build Coastguard Worker 
10*6777b538SAndroid Build Coastguard Worker #include "base/base_export.h"
11*6777b538SAndroid Build Coastguard Worker 
12*6777b538SAndroid Build Coastguard Worker namespace base {
13*6777b538SAndroid Build Coastguard Worker namespace android {
14*6777b538SAndroid Build Coastguard Worker 
15*6777b538SAndroid Build Coastguard Worker // Utils to help working with android app bundles.
16*6777b538SAndroid Build Coastguard Worker class BASE_EXPORT BundleUtils {
17*6777b538SAndroid Build Coastguard Worker  public:
18*6777b538SAndroid Build Coastguard Worker   // Returns true if the current build is a bundle.
19*6777b538SAndroid Build Coastguard Worker   static bool IsBundle();
20*6777b538SAndroid Build Coastguard Worker 
21*6777b538SAndroid Build Coastguard Worker   // Helper function asking Java to resolve a library path. This is required for
22*6777b538SAndroid Build Coastguard Worker   // resolving a module library made available via SplitCompat, rather than in
23*6777b538SAndroid Build Coastguard Worker   // its eventual fully-installed state.
24*6777b538SAndroid Build Coastguard Worker   static std::string ResolveLibraryPath(const std::string& library_name,
25*6777b538SAndroid Build Coastguard Worker                                         const std::string& split_name);
26*6777b538SAndroid Build Coastguard Worker 
27*6777b538SAndroid Build Coastguard Worker   // dlopen wrapper that works for partitioned native libraries in dynamic
28*6777b538SAndroid Build Coastguard Worker   // feature modules. This routine looks up the partition's address space in a
29*6777b538SAndroid Build Coastguard Worker   // table of main library symbols, and uses it when loading the feature
30*6777b538SAndroid Build Coastguard Worker   // library. It requires |library_name| (eg. chrome_foo) to resolve the file
31*6777b538SAndroid Build Coastguard Worker   // path (which may be in an interesting location due to SplitCompat) and
32*6777b538SAndroid Build Coastguard Worker   // |partition_name| to look up the load parameters in the main library. These
33*6777b538SAndroid Build Coastguard Worker   // two values may be identical, but since the partition name is set at compile
34*6777b538SAndroid Build Coastguard Worker   // time, and the code is linked into multiple libraries (eg. Chrome vs
35*6777b538SAndroid Build Coastguard Worker   // Monochrome), they may not be.
36*6777b538SAndroid Build Coastguard Worker   static void* DlOpenModuleLibraryPartition(const std::string& library_name,
37*6777b538SAndroid Build Coastguard Worker                                             const std::string& partition,
38*6777b538SAndroid Build Coastguard Worker                                             const std::string& split_name);
39*6777b538SAndroid Build Coastguard Worker };
40*6777b538SAndroid Build Coastguard Worker 
41*6777b538SAndroid Build Coastguard Worker }  // namespace android
42*6777b538SAndroid Build Coastguard Worker }  // namespace base
43*6777b538SAndroid Build Coastguard Worker 
44*6777b538SAndroid Build Coastguard Worker #endif  // BASE_ANDROID_BUNDLE_UTILS_H_
45