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