1 /* 2 * Copyright (c) 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 #ifndef SERVICES_EDM_INCLUDE_UTILS_MANAGE_KEEP_ALIVE_APPS_SERIALIZER_H 17 #define SERVICES_EDM_INCLUDE_UTILS_MANAGE_KEEP_ALIVE_APPS_SERIALIZER_H 18 19 #include "edm_errors.h" 20 #include "ipolicy_serializer.h" 21 #include "singleton.h" 22 #include "manage_keep_alive_apps_info.h" 23 24 namespace OHOS { 25 namespace EDM { 26 27 /* 28 * Policy data serializer of type std::vector<ManageKeepAliveAppInfo>. 29 */ 30 class ManageKeepAliveAppsSerializer : public IPolicySerializer<std::vector<ManageKeepAliveAppInfo>>, 31 public DelayedSingleton<ManageKeepAliveAppsSerializer> { 32 public: 33 std::vector<ManageKeepAliveAppInfo> SetUnionPolicyData(std::vector<ManageKeepAliveAppInfo> &data, 34 std::vector<ManageKeepAliveAppInfo> ¤tData); 35 36 std::vector<ManageKeepAliveAppInfo> SetDifferencePolicyData(std::vector<ManageKeepAliveAppInfo> &data, 37 std::vector<ManageKeepAliveAppInfo> ¤tData); 38 39 std::vector<ManageKeepAliveAppInfo> SetIntersectionPolicyData(std::vector<std::string> &data, 40 std::vector<ManageKeepAliveAppInfo> ¤tData); 41 42 std::vector<ManageKeepAliveAppInfo> SetNeedRemoveMergePolicyData(std::vector<ManageKeepAliveAppInfo> &mergeData, 43 std::vector<ManageKeepAliveAppInfo> &data); 44 45 bool Deserialize(const std::string &policy, std::vector<ManageKeepAliveAppInfo> &dataObj) override; 46 47 bool Serialize(const std::vector<ManageKeepAliveAppInfo> &dataObj, std::string &policy) override; 48 49 bool GetPolicy(MessageParcel &data, std::vector<ManageKeepAliveAppInfo> &result) override; 50 51 bool WritePolicy(MessageParcel &reply, std::vector<ManageKeepAliveAppInfo> &result) override; 52 53 bool MergePolicy(std::vector<std::vector<ManageKeepAliveAppInfo>> &data, 54 std::vector<ManageKeepAliveAppInfo> &result) override; 55 56 bool UpdateByMergePolicy(std::vector<ManageKeepAliveAppInfo> &data, std::vector<ManageKeepAliveAppInfo> &mergeData); 57 }; 58 } // namespace EDM 59 } // namespace OHOS 60 61 #endif //SERVICES_EDM_INCLUDE_UTILS_MANAGE_KEEP_ALIVE_APPS_SERIALIZER_H