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 <set> 25 #include <string> 26 #include <vector> 27 28 namespace OHOS { 29 namespace AppExecFwk { 30 class BundleResourceProcess { 31 public: 32 // get LauncherAbilityResourceInfo and BundleResourceInfo by bundleName 33 static bool GetResourceInfoByBundleName(const std::string &bundleName, const int32_t userId, 34 std::vector<ResourceInfo> &resourceInfo, const int32_t appIndex = Constants::DEFAULT_APP_INDEX, 35 bool needParseDynamic = true); 36 // get LauncherAbilityResourceInfo by abilityName 37 static bool GetLauncherResourceInfoByAbilityName(const std::string &bundleName, const std::string &moduleName, 38 const std::string &abilityName, const int32_t userId, 39 ResourceInfo &resourceInfo); 40 // get all LauncherAbilityResourceInfo and BundleResourceInfo 41 static bool GetAllResourceInfo(const int32_t userId, 42 std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap); 43 // get LauncherAbilityResourceInfo when colorMode changed 44 static bool GetResourceInfoByColorModeChanged(const std::vector<std::string> &resourceNames, 45 const int32_t userId, std::vector<ResourceInfo> &resourceInfos); 46 47 static void GetTargetBundleName(const std::string &bundleName, std::string &targetBundleName); 48 49 static std::set<int32_t> GetAppIndexByBundleName(const std::string &bundleName); 50 51 static std::string GetCurDynamicIconModule(const std::string &bundleName, 52 const int32_t userId, const int32_t appIndex); 53 54 static bool GetExtendResourceInfo(const std::string &bundleName, const std::string &moduleName, 55 ExtendResourceInfo &extendResourceInfo); 56 57 static bool CheckThemeType(const std::string &bundleName, const int32_t userId, bool &isOnlineTheme); 58 59 static bool GetDynamicIconResourceInfo(const std::string &bundleName, 60 const std::string &dynamicModuleName, ResourceInfo &resourceInfo); 61 62 private: 63 // used for show in settings 64 static bool GetBundleResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 65 ResourceInfo &resourceInfo); 66 // get launcher ability resource 67 static bool GetLauncherAbilityResourceInfos(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 68 std::vector<ResourceInfo> &resourceInfos); 69 // get all ability resource 70 static bool GetAbilityResourceInfos(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 71 std::vector<ResourceInfo> &resourceInfos); 72 73 static bool IsOnlineTheme(const std::string &themePath); 74 75 static ResourceInfo ConvertToLauncherAbilityResourceInfo(const AbilityInfo &ability); 76 77 static ResourceInfo ConvertToBundleResourceInfo(const InnerBundleInfo &innerBundleInfo); 78 79 static ResourceInfo ConvertToExtensionAbilityResourceInfo(const ExtensionAbilityInfo &info); 80 81 static bool InnerGetResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 82 std::vector<ResourceInfo> &resourceInfos, const int32_t appIndex = Constants::DEFAULT_APP_INDEX, 83 bool needParseDynamic = true); 84 85 static bool OnGetResourceInfo(const InnerBundleInfo &innerBundleInfo, const int32_t userId, 86 std::vector<ResourceInfo> &resourceInfos); 87 88 static bool CheckIsNeedProcessAbilityResource(const InnerBundleInfo &innerBundleInfo); 89 90 static bool GetOverlayModuleHapPaths(const InnerBundleInfo &innerBundleInfo, const std::string &moduleName, 91 int32_t userId, std::vector<std::string> &overlayHapPaths); 92 93 static void ChangeDynamicIcon( 94 std::vector<ResourceInfo> &resourceInfos, const ResourceInfo &resourceInfo); 95 96 static bool GetDynamicIcon( 97 const InnerBundleInfo &innerBundleInfo, const int32_t userId, ResourceInfo &resourceInfo); 98 99 static bool GetExternalOverlayHapState(const std::string &bundleName, 100 const std::string &moduleName, const int32_t userId, int32_t &state); 101 }; 102 } // AppExecFwk 103 } // OHOS 104 #endif // FOUNDATION_BUNDLEMANAGER_BUNDLE_FRAMEWORK_SERVICES_BUNDLEMGR_BUNDLE_RESOURCE_PROCESS_H 105