1 /* 2 * Copyright (c) 2023-2024 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_SERVICE_ROUTER_FRAMEWORK_SERVICES_INCLUDE_INNER_BUNDLE_INFO_H 17 #define OHOS_ABILITY_RUNTIME_SERVICE_ROUTER_FRAMEWORK_SERVICES_INCLUDE_INNER_BUNDLE_INFO_H 18 19 #include "application_info.h" 20 #include "bundle_info.h" 21 #include "hilog_tag_wrapper.h" 22 #include "service_info.h" 23 #include "want.h" 24 25 namespace OHOS { 26 namespace AbilityRuntime { 27 using namespace OHOS::AppExecFwk; 28 29 class InnerServiceInfo { 30 public: 31 InnerServiceInfo() = default; 32 ~InnerServiceInfo() = default; 33 /** 34 * @brief Find serviceInfo of list by service type. 35 * @param businessType Indicates the business type. 36 * @param businessAbilityInfos Indicates the business ability infos to be find. 37 * @return 38 */ 39 void FindBusinessAbilityInfos(const BusinessType &businessType, 40 std::vector<BusinessAbilityInfo> &businessAbilityInfos) const; 41 42 /** 43 * @brief Find purposeInfo by purposeName. 44 * @param purposeName Indicates the purposeName. 45 * @param purposeInfos Indicates the PurposeInfos to be find. 46 * @return 47 */ 48 void FindPurposeInfos(const std::string &purposeName, std::vector<PurposeInfo> &purposeInfos) const; 49 50 /** 51 * @brief Update inner service info. 52 * @param purposeInfos Indicates the PurposeInfos object to be update. 53 * @param businessAbilityInfos Indicates the business ability infos to be update. 54 * @return 55 */ UpdateInnerServiceInfo(std::vector<PurposeInfo> & purposeInfos,std::vector<BusinessAbilityInfo> & businessAbilityInfos)56 void UpdateInnerServiceInfo(std::vector<PurposeInfo> &purposeInfos, 57 std::vector<BusinessAbilityInfo> &businessAbilityInfos) 58 { 59 UpdatePurposeInfos(purposeInfos); 60 UpdateBusinessAbilityInfos(businessAbilityInfos); 61 } 62 63 /** 64 * @brief Update app info. 65 * @param applicationInfo Indicates the ApplicationInfo to be update. 66 * @return 67 */ UpdateAppInfo(const ApplicationInfo & applicationInfo)68 void UpdateAppInfo(const ApplicationInfo &applicationInfo) 69 { 70 appInfo_.bundleName = applicationInfo.bundleName; 71 appInfo_.iconId = applicationInfo.iconId; 72 appInfo_.labelId = applicationInfo.labelId; 73 appInfo_.descriptionId = applicationInfo.descriptionId; 74 } 75 76 /** 77 * @brief Update business ability infos. 78 * @param businessAbilityInfos Indicates the business ability infos to be add. 79 * @return 80 */ UpdateBusinessAbilityInfos(const std::vector<BusinessAbilityInfo> & businessAbilityInfos)81 void UpdateBusinessAbilityInfos(const std::vector<BusinessAbilityInfo> &businessAbilityInfos) 82 { 83 if (businessAbilityInfos.size() == 0) { 84 TAG_LOGW(AAFwkTag::SER_ROUTER, "serviceInfos size: 0"); 85 businessAbilityInfos_.clear(); 86 return; 87 } 88 businessAbilityInfos_.assign(businessAbilityInfos.begin(), businessAbilityInfos.end()); 89 } 90 91 /** 92 * @brief Update purposeInfos. 93 * @param purposeInfos Indicates the PurposeInfos to be add. 94 * @return 95 */ UpdatePurposeInfos(const std::vector<PurposeInfo> & purposeInfos)96 void UpdatePurposeInfos(const std::vector<PurposeInfo> &purposeInfos) 97 { 98 if (purposeInfos.size() == 0) { 99 TAG_LOGW(AAFwkTag::SER_ROUTER, "purposeInfos size: 0"); 100 purposeInfos_.clear(); 101 return; 102 } 103 purposeInfos_.assign(purposeInfos.begin(), purposeInfos.end()); 104 } 105 106 /** 107 * @brief Get bundle name. 108 * @return Return bundle name 109 */ GetAppInfo()110 const AppInfo GetAppInfo() const 111 { 112 return appInfo_; 113 } 114 115 /** 116 * @brief Get bundle name. 117 * @return Return bundle name 118 */ GetBundleName()119 const std::string GetBundleName() const 120 { 121 return appInfo_.bundleName; 122 } 123 private: 124 AppInfo appInfo_; 125 std::vector<BusinessAbilityInfo> businessAbilityInfos_; 126 std::vector<PurposeInfo> purposeInfos_; 127 }; 128 } // namespace AbilityRuntime 129 } // namespace OHOS 130 #endif // OHOS_ABILITY_RUNTIME_SERVICE_ROUTER_FRAMEWORK_SERVICES_INCLUDE_INNER_BUNDLE_INFO_H 131