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 <map> 24 #include <string> 25 #include <vector> 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 class BundleResourceProcess { 30 public: 31 // get LauncherAbilityResourceInfo and BundleResourceInfo by bundleName 32 static bool GetResourceInfoByBundleName(const std::string &bundleName, const int32_t userId, 33 std::vector<ResourceInfo> &resourceInfo); 34 // get LauncherAbilityResourceInfo by abilityName 35 static bool GetLauncherResourceInfoByAbilityName(const std::string &bundleName, const std::string &moduleName, 36 const std::string &abilityName, const int32_t userId, 37 ResourceInfo &resourceInfo); 38 // get all LauncherAbilityResourceInfo and BundleResourceInfo 39 static bool GetAllResourceInfo(const int32_t userId, 40 std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap); 41 // get LauncherAbilityResourceInfo when colorMode changed 42 static bool GetResourceInfoByColorModeChanged(const std::vector<std::string> &resourceNames, 43 const int32_t userId, std::vector<ResourceInfo> &resourceInfos); 44 45 static void GetTargetBundleName(const std::string &bundleName, std::string &targetBundleName); 46 47 private: 48 // used for show in settings 49 static bool GetBundleResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 50 ResourceInfo &resourceInfo); 51 // get launcher ability resource 52 static bool GetLauncherAbilityResourceInfos(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 53 std::vector<ResourceInfo> &resourceInfos); 54 // get all ability resource 55 static bool GetAbilityResourceInfos(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 56 std::vector<ResourceInfo> &resourceInfos); 57 58 static ResourceInfo ConvertToLauncherAbilityResourceInfo(const AbilityInfo &ability); 59 60 static ResourceInfo ConvertToBundleResourceInfo(const InnerBundleInfo &innerBundleInfo); 61 62 static bool InnerGetResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 63 std::vector<ResourceInfo> &resourceInfos); 64 65 static bool OnGetResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 66 std::vector<ResourceInfo> &resourceInfos); 67 68 static bool CheckIsNeedProcessAbilityResource(const InnerBundleInfo &innerBundleInfo); 69 70 static bool GetOverlayModuleHapPaths(const InnerBundleInfo &innerBundleInfo, const std::string &moduleName, 71 int32_t userId, std::vector<std::string> &overlayHapPaths); 72 73 static void ChangeDynamicIcon( 74 std::vector<ResourceInfo> &resourceInfos, const ResourceInfo &resourceInfo); 75 76 static bool GetDynamicIcon( 77 const InnerBundleInfo &innerBundleInfo, ResourceInfo &resourceInfo); 78 79 static bool GetExternalOverlayHapState(const std::string &bundleName, 80 const std::string &moduleName, const int32_t userId, int32_t &state); 81 }; 82 } // AppExecFwk 83 } // OHOS 84 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_PROCESS_H 85