• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_ABILITY_RUNTIME_SIMULATOR_BUNDLE_CONTAINER_H
17 #define OHOS_ABILITY_RUNTIME_SIMULATOR_BUNDLE_CONTAINER_H
18 
19 #include <map>
20 #include <vector>
21 
22 #include "application_info.h"
23 #include "bundle_constants.h"
24 #include "bundle_info.h"
25 #include "inner_bundle_info.h"
26 #include "options.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 class BundleContainer {
31 public:
32     BundleContainer() = default;
33     ~BundleContainer() = default;
34 
35     static BundleContainer &GetInstance();
36     void LoadBundleInfos(const std::vector<uint8_t> &buffer, const std::string &resourcePath);
37     void LoadDependencyHspInfo(
38         const std::string &bundleName, const std::vector<AbilityRuntime::DependencyHspInfo> &dependencyHspInfos);
39     std::shared_ptr<ApplicationInfo> GetApplicationInfo() const;
40     std::shared_ptr<HapModuleInfo> GetHapModuleInfo(const std::string &modulePackage) const;
41     std::shared_ptr<AbilityInfo> GetAbilityInfo(const std::string &moduleName, const std::string &abilityName) const;
42     void GetBundleInfo(const std::string &bundleName, const std::string &moduleName, BundleInfo &bundleInfo);
43     ErrCode GetDependentBundleInfo(const std::string &bundleName, const std::string &moduleName,
44         BundleInfo &sharedBundleInfo, GetDependentBundleInfoFlag flag);
45     void SetBundleCodeDir(const std::string &bundleCodeDir);
46     std::string GetBundleCodeDir() const;
47 
48 private:
49     std::shared_ptr<InnerBundleInfo> bundleInfo_ = nullptr;
50     std::string resourcePath_;
51     std::map<std::string, std::shared_ptr<InnerBundleInfo>> bundleInfos_;
52     std::map<std::string, std::string> resourcePaths_;
53     std::string bundleCodeDir_;
54     std::shared_ptr<InnerBundleInfo> GetInnerBundleInfo(const std::string &bundleName, const std::string &moduleName);
55     void UpdateResourcePath(const std::string &bundleName, const std::string &moduleName, BundleInfo &bundleInfo);
56 };
57 } // namespace AppExecFwk
58 } // namespace OHOS
59 #endif // OHOS_ABILITY_RUNTIME_SIMULATOR_BUNDLE_CONTAINER_H
60