• 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_PROCESS_H
17 #define FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_PROCESS_H
18 
19 #include "ability_info.h"
20 #include "inner_bundle_info.h"
21 #include "resource_info.h"
22 
23 #include <string>
24 #include <vector>
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 class BundleResourceProcess {
29 public:
30     // used for show in desktop
31     static bool GetLauncherAbilityResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId,
32         std::vector<ResourceInfo> &resourceInfo);
33     // used for show in settings
34     static bool GetBundleResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId,
35         ResourceInfo &resourceInfo);
36     // get LauncherAbilityResourceInfo and BundleResourceInfo
37     static bool GetResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId,
38         std::vector<ResourceInfo> &resourceInfo);
39     // get LauncherAbilityResourceInfo and BundleResourceInfo by bundleName
40     static bool GetResourceInfoByBundleName(const std::string &bundleName, const int32_t userId,
41         std::vector<ResourceInfo> &resourceInfo);
42     // get LauncherAbilityResourceInfo by abilityName
43     static bool GetResourceInfoByAbilityName(const std::string &bundleName, const std::string &moduleName,
44         const std::string &abilityName, const int32_t userId,
45         ResourceInfo &resourceInfo);
46     // get all LauncherAbilityResourceInfo and BundleResourceInfo
47     static bool GetAllResourceInfo(const int32_t userId, std::vector<ResourceInfo> &resourceInfos);
48     // get LauncherAbilityResourceInfo when colorMode changed
49     static bool GetResourceInfoByColorModeChanged(const std::vector<std::string> &resourceNames,
50         std::vector<ResourceInfo> &resourceInfos);
51 
52     static bool GetDefaultIconResource(int32_t &iconId, std::string &hapPath);
53 
54 private:
55     static bool IsBundleExist(const InnerBundleInfo &innerBundleInfo, const int32_t userId);
56 
57     static int64_t GetUpdateTime(const InnerBundleInfo &innerBundleInfo,  const int32_t userId);
58 
59     static ResourceInfo ConvertToLauncherAbilityResourceInfo(const AbilityInfo &ability);
60 
61     static ResourceInfo ConvertToBundleResourceInfo(const InnerBundleInfo &innerBundleInfo,
62         const int32_t userId);
63 
64     static bool InnerGetResourceInfo(const InnerBundleInfo &innerBundleInfo,  const int32_t userId,
65         std::vector<ResourceInfo> &resourceInfos);
66 
67     static std::string systemResourceHap_;
68     static int32_t defaultIconId_;
69 };
70 } // AppExecFwk
71 } // OHOS
72 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_PROCESS_H
73