• 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 FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_PARSER_H
17 #define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_PARSER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "resource_info.h"
23 #include "resource_manager.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 class BundleResourceParser {
28 public:
29     BundleResourceParser();
30 
31     ~BundleResourceParser();
32     // parse label and icon
33     bool ParseResourceInfo(ResourceInfo &resourceInfo);
34 
35     // parse label and icon
36     bool ParseResourceInfos(std::vector<ResourceInfo> &resourceInfos);
37 
38 private:
39     // for defaultIconPath is empty, icon and label exist in same hap.
40     bool ParseResourceInfoWithSameHap(ResourceInfo &resourceInfo);
41 
42     // for defaultIconPath is not empty, icon and label not exist in same hap.
43     bool ParseResourceInfoWithDifferentHap(ResourceInfo &resourceInfo);
44 
45     // parse label resource by hapPath
46     bool ParseLabelResourceByPath(const std::string &hapPath, const int32_t labelId, std::string &label);
47 
48     // parse icon resource by hapPath
49     bool ParseIconResourceByPath(const std::string &hapPath, const int32_t iconId, std::string &icon);
50 
51     bool ParseResourceInfoByResourceManager(const std::shared_ptr<Global::Resource::ResourceManager> resourceManager,
52         ResourceInfo &resourceInfo);
53 
54     // parse label resource by resourceManager
55     bool ParseLabelResourceByResourceManager(const std::shared_ptr<Global::Resource::ResourceManager> resourceManager,
56         const int32_t labelId, std::string &label);
57 
58     // parse label resource by resourceManager
59     bool ParseIconResourceByResourceManager(const std::shared_ptr<Global::Resource::ResourceManager> resourceManager,
60         const int32_t iconId, std::string &icon);
61 };
62 } // AppExecFwk
63 } // OHOS
64 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_PARSER_H
65