• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 "ability_keep_alive_service.h"
17 
18 namespace OHOS {
19 namespace AbilityRuntime {
20 using namespace OHOS::AAFwk;
21 int32_t AbilityKeepAliveService::callSetResult = ERR_OK;
22 int32_t AbilityKeepAliveService::callQueryResult = ERR_OK;
23 bool AbilityKeepAliveService::callIsKeepAliveResult = false;
24 int32_t AbilityKeepAliveService::callGetResult = ERR_OK;
25 int32_t AbilityKeepAliveService::callSetAppServiceExtensionResult = ERR_OK;
26 int32_t AbilityKeepAliveService::callQueryAppServiceExtensionResult = ERR_OK;
27 int32_t AbilityKeepAliveService::callClearKeepAliveAppServiceExtensionResult = ERR_OK;
28 bool AbilityKeepAliveService::getInfoList = true;
29 int32_t AbilityKeepAliveService::callIsKeepAliveTimes = 0;
30 
GetInstance()31 AbilityKeepAliveService &AbilityKeepAliveService::GetInstance()
32 {
33     static AbilityKeepAliveService instance;
34     return instance;
35 }
36 
AbilityKeepAliveService()37 AbilityKeepAliveService::AbilityKeepAliveService() {}
38 
~AbilityKeepAliveService()39 AbilityKeepAliveService::~AbilityKeepAliveService() {}
40 
SetApplicationKeepAlive(KeepAliveInfo & info,bool flag)41 int32_t AbilityKeepAliveService::SetApplicationKeepAlive(KeepAliveInfo &info, bool flag)
42 {
43     return callSetResult;
44 }
45 
QueryKeepAliveApplications(int32_t userId,int32_t appType,std::vector<KeepAliveInfo> & infoList)46 int32_t AbilityKeepAliveService::QueryKeepAliveApplications(int32_t userId,
47     int32_t appType, std::vector<KeepAliveInfo> &infoList)
48 {
49     return callQueryResult;
50 }
51 
IsKeepAliveApp(const std::string & bundleName,int32_t userId)52 bool AbilityKeepAliveService::IsKeepAliveApp(const std::string &bundleName, int32_t userId)
53 {
54     callIsKeepAliveTimes++;
55     return callIsKeepAliveResult;
56 }
57 
GetKeepAliveApplications(int32_t userId,std::vector<KeepAliveInfo> & infoList)58 int32_t AbilityKeepAliveService::GetKeepAliveApplications(int32_t userId, std::vector<KeepAliveInfo> &infoList)
59 {
60     if (getInfoList) {
61         KeepAliveInfo info;
62         info.bundleName = "mockTestBundle";
63         infoList.push_back(info);
64     }
65     return callGetResult;
66 }
67 
SetAppServiceExtensionKeepAlive(KeepAliveInfo & info,bool flag)68 int32_t AbilityKeepAliveService::SetAppServiceExtensionKeepAlive(KeepAliveInfo &info, bool flag)
69 {
70     return callSetAppServiceExtensionResult;
71 }
72 
QueryKeepAliveAppServiceExtensions(std::vector<KeepAliveInfo> & infoList)73 int32_t AbilityKeepAliveService::QueryKeepAliveAppServiceExtensions(std::vector<KeepAliveInfo> &infoList)
74 {
75     return callQueryAppServiceExtensionResult;
76 }
77 
ClearKeepAliveAppServiceExtension(const KeepAliveInfo & info)78 int32_t AbilityKeepAliveService::ClearKeepAliveAppServiceExtension(const KeepAliveInfo &info)
79 {
80     return callClearKeepAliveAppServiceExtensionResult;
81 }
82 } // namespace AbilityRuntime
83 } // namespace OHOS
84