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 #include "background_task_helper.h"
17 #include "background_task_mgr_helper.h"
18 #include "standby_service_log.h"
19 
20 namespace OHOS {
21 namespace DevStandbyMgr {
22 IMPLEMENT_SINGLE_INSTANCE(BackgroundTaskHelper);
23 
BackgroundTaskHelper()24 BackgroundTaskHelper::BackgroundTaskHelper()
25 {
26 }
27 
~BackgroundTaskHelper()28 BackgroundTaskHelper::~BackgroundTaskHelper()
29 {
30 }
31 
GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> & list)32 bool WEAK_FUNC BackgroundTaskHelper::GetContinuousTaskApps(
33     std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list)
34 {
35     #ifdef ENABLE_BACKGROUND_TASK_MGR
36     if (BackgroundTaskMgrHelper::GetContinuousTaskApps(list) != OHOS::ERR_OK) {
37         STANDBYSERVICE_LOGW("Get continuous task failed");
38         return false;
39     }
40     #endif
41     return true;
42 }
43 
GetTransientTaskApps(std::vector<std::shared_ptr<TransientTaskAppInfo>> & list)44 bool WEAK_FUNC BackgroundTaskHelper::GetTransientTaskApps(std::vector<std::shared_ptr<TransientTaskAppInfo>> &list)
45 {
46     #ifdef ENABLE_BACKGROUND_TASK_MGR
47     if (BackgroundTaskMgrHelper::GetTransientTaskApps(list) != OHOS::ERR_OK) {
48         STANDBYSERVICE_LOGE("Get transient task failed");
49         return false;
50     }
51     #endif
52     return true;
53 }
54 } // OHOS
55 } // DevStandbyMgr