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 #include "ability_keep_alive_data_manager.h" 17 18 #include "ability_manager_errors.h" 19 20 namespace OHOS { 21 namespace AbilityRuntime { 22 int32_t AbilityKeepAliveDataManager::callSetResult = ERR_OK; 23 int32_t AbilityKeepAliveDataManager::callInsertResult = ERR_OK; 24 int32_t AbilityKeepAliveDataManager::callDeleteResult = ERR_OK; 25 int32_t AbilityKeepAliveDataManager::callDeleteBySetterIdResult = ERR_OK; 26 int32_t AbilityKeepAliveDataManager::callQueryDataResult = ERR_OK; 27 int32_t AbilityKeepAliveDataManager::callQueryApplicationResult = ERR_OK; 28 KeepAliveSetter AbilityKeepAliveDataManager::queryDataSetter = KeepAliveSetter::UNSPECIFIED; 29 std::vector<KeepAliveInfo> AbilityKeepAliveDataManager::returnInfoList; 30 int32_t AbilityKeepAliveDataManager::queryDataSetterId = -1; 31 KeepAlivePolicy AbilityKeepAliveDataManager::queryDataPolicy = KeepAlivePolicy::UNSPECIFIED; 32 GetInstance()33AbilityKeepAliveDataManager &AbilityKeepAliveDataManager::GetInstance() 34 { 35 static AbilityKeepAliveDataManager instance; 36 return instance; 37 } 38 AbilityKeepAliveDataManager()39AbilityKeepAliveDataManager::AbilityKeepAliveDataManager() {} 40 ~AbilityKeepAliveDataManager()41AbilityKeepAliveDataManager::~AbilityKeepAliveDataManager() {} 42 InsertKeepAliveData(const KeepAliveInfo & info)43int32_t AbilityKeepAliveDataManager::InsertKeepAliveData(const KeepAliveInfo &info) 44 { 45 return callInsertResult; 46 } 47 DeleteKeepAliveData(const KeepAliveInfo & info)48int32_t AbilityKeepAliveDataManager::DeleteKeepAliveData(const KeepAliveInfo &info) 49 { 50 return callDeleteResult; 51 } 52 QueryKeepAliveData(const KeepAliveInfo & info)53KeepAliveStatus AbilityKeepAliveDataManager::QueryKeepAliveData(const KeepAliveInfo &info) 54 { 55 KeepAliveStatus kaStatus; 56 kaStatus.code = callQueryDataResult; 57 kaStatus.setter = queryDataSetter; 58 kaStatus.setterId = queryDataSetterId; 59 kaStatus.policy = queryDataPolicy; 60 return kaStatus; 61 } 62 QueryKeepAliveApplications(const KeepAliveInfo & queryParam,std::vector<KeepAliveInfo> & infoList)63int32_t AbilityKeepAliveDataManager::QueryKeepAliveApplications( 64 const KeepAliveInfo &queryParam, std::vector<KeepAliveInfo> &infoList) 65 { 66 infoList = returnInfoList; 67 return callQueryApplicationResult; 68 } 69 DeleteKeepAliveDataWithSetterId(const KeepAliveInfo & info)70int32_t AbilityKeepAliveDataManager::DeleteKeepAliveDataWithSetterId(const KeepAliveInfo &info) 71 { 72 return callDeleteBySetterIdResult; 73 } 74 } // namespace AbilityRuntime 75 } // namespace OHOS 76