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 needEraseIndexSet The returned set of indices that need to be erased.
36      * @param bundleInfoIndex The index of the bundle info.
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, const std::string &processName,
41         std::string &mainElement, std::set<uint32_t> &needEraseIndexSet, size_t bundleInfoIndex, int32_t userId = 0);
42 
43     /**
44      * UpdateMainElement, update main element.
45      *
46      * @param bundleName The bundle name.
47      * @param moduleName The modle name.
48      * @param mainElement The returned main element.
49      * @param updateEnable Flag indicated whether update is enabled.
50      * @param userId User id.
51      */
52     static void UpdateMainElement(const std::string &bundleName, const std::string &moduleName,
53         const std::string &mainElement, bool updateEnable, int32_t userId);
54 };
55 }  // namespace AAFwk
56 }  // namespace OHOS
57 #endif  // OHOS_ABILITY_RUNTIME_MAIN_ELEMENT_UTILS_H
58