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_KEEP_ALIVE_UTILS_H 17 #define OHOS_ABILITY_RUNTIME_KEEP_ALIVE_UTILS_H 18 19 #include "bundle_info.h" 20 21 namespace OHOS { 22 namespace AAFwk { 23 /** 24 * @class KeepAliveType 25 * defines what type of keep-alive. 26 */ 27 enum class KeepAliveType : int32_t { 28 UNSPECIFIED = -1, 29 RESIDENT_PROCESS = 0, 30 THIRD_PARTY = 1, 31 }; 32 33 /** 34 * @class KeepAliveUtils 35 * provides keep-alive utilities. 36 */ 37 class KeepAliveUtils final { 38 public: 39 /** 40 * NotifyDisableKeepAliveProcesses, notify disable keep-alive processes. 41 * 42 * @param bundleInfos The list of bundle info. 43 * @param userId User id. 44 * @return Whether or not the hap module has the main element. 45 */ 46 static void NotifyDisableKeepAliveProcesses(const std::vector<AppExecFwk::BundleInfo> &bundleInfos, 47 int32_t userId); 48 49 /** 50 * IsKeepAliveBundle, check if bundle is keep-alive. 51 * 52 * @param bundleInfo The bundle info. 53 * @param userId User id. 54 * @param type The returned type of keep-alive. 55 * @return Whether or not the bundle is keep-alive. 56 */ 57 static bool IsKeepAliveBundle(const AppExecFwk::BundleInfo &bundleInfo, int32_t userId, KeepAliveType &type); 58 }; 59 } // namespace AAFwk 60 } // namespace OHOS 61 #endif // OHOS_ABILITY_RUNTIME_KEEP_ALIVE_UTILS_H 62