1 /* 2 * Copyright (c) 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_MAIN_ELEMENT_UTILS_H 17 #define OHOS_ABILITY_RUNTIME_MAIN_ELEMENT_UTILS_H 18 19 #include "bundle_info.h" 20 21 namespace OHOS { 22 namespace AAFwk { 23 /** 24 * @class MainElementUtils 25 * provides main element utilities. 26 */ 27 class MainElementUtils final { 28 public: 29 /** 30 * CheckMainElement, check main element. 31 * 32 * @param hapModuleInfo The hap module info. 33 * @param processName The process name. 34 * @param mainElement The returned main element. 35 * @param isDataAbility The returned flag indicates whether the module contains data ability. 36 * @param uri Returned URI of the data ability. 37 * @param userId User id. 38 * @return Whether or not the hap module has the main element. 39 */ 40 static bool CheckMainElement(const AppExecFwk::HapModuleInfo &hapModuleInfo, 41 const std::string &processName, std::string &mainElement, bool &isDataAbility, 42 std::string &uriStr, int32_t userId = 0); 43 44 /** 45 * UpdateMainElement, update main element. 46 * 47 * @param bundleName The bundle name. 48 * @param moduleName The modle name. 49 * @param mainElement The returned main element. 50 * @param updateEnable Flag indicated whether update is enabled. 51 * @param userId User id. 52 */ 53 static void UpdateMainElement(const std::string &bundleName, const std::string &moduleName, 54 const std::string &mainElement, bool updateEnable, int32_t userId); 55 56 /** 57 * CheckMainUIAbility, check if bundle has main UIAbility. 58 * 59 * @param bundleInfo The bundle info. 60 * @param mainElementName The returned main element name. 61 * @return Whether or not the bundle has the main element. 62 */ 63 static bool CheckMainUIAbility(const AppExecFwk::BundleInfo &bundleInfo, std::string& mainElementName); 64 65 /** 66 * CheckStatusBarAbility, check if bundle has status bar ability. 67 * 68 * @param bundleInfo The bundle info. 69 * @return Whether or not the bundle has a status bar ability. 70 */ 71 static bool CheckStatusBarAbility(const AppExecFwk::BundleInfo &bundleInfo); 72 }; 73 } // namespace AAFwk 74 } // namespace OHOS 75 #endif // OHOS_ABILITY_RUNTIME_MAIN_ELEMENT_UTILS_H 76