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 #ifndef SAMGR_INTERFACES_INNERKITS_SAMGR_PROXY_SYSTEM_ABILITY_ON_DEMAND_EVENT_H 17 #define SAMGR_INTERFACES_INNERKITS_SAMGR_PROXY_SYSTEM_ABILITY_ON_DEMAND_EVENT_H 18 19 #include <string> 20 #include <vector> 21 22 #include "message_parcel.h" 23 24 namespace OHOS { 25 enum class OnDemandPolicyType { 26 START_POLICY = 0, 27 STOP_POLICY = 1, 28 }; 29 30 enum class OnDemandEventId { 31 DEVICE_ONLINE = 1, 32 SETTING_SWITCH = 2, 33 PARAM = 3, 34 COMMON_EVENT = 4, 35 TIMED_EVENT = 5, 36 }; 37 38 struct SystemAbilityOnDemandCondition { 39 OnDemandEventId eventId; 40 std::string name; 41 std::string value; 42 }; 43 44 struct SystemAbilityOnDemandEvent { 45 OnDemandEventId eventId; 46 std::string name; 47 std::string value; 48 bool persistence = false; 49 std::vector<SystemAbilityOnDemandCondition> conditions; 50 bool enableOnce = false; 51 }; 52 53 class OnDemandEventToParcel { 54 public: 55 static bool WriteOnDemandEventsToParcel(const std::vector<SystemAbilityOnDemandEvent>& abilityOnDemandEvents, 56 MessageParcel& data); 57 static bool WriteOnDemandEventToParcel(const SystemAbilityOnDemandEvent& event, MessageParcel& data); 58 static bool WriteOnDemandConditionToParcel(const SystemAbilityOnDemandCondition& condition, MessageParcel& data); 59 static bool ReadOnDemandEventsFromParcel(std::vector<SystemAbilityOnDemandEvent>& abilityOnDemandEvents, 60 MessageParcel& reply); 61 static bool ReadOnDemandEventFromParcel(SystemAbilityOnDemandEvent& event, MessageParcel& reply); 62 static bool ReadOnDemandConditionFromParcel(SystemAbilityOnDemandCondition& condition, MessageParcel& reply); 63 }; 64 } 65 #endif /* SAMGR_INTERFACES_INNERKITS_SAMGR_PROXY_SYSTEM_ABILITY_ON_DEMAND_EVENT_H */