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 UNREF_EVENT = 6, 37 }; 38 39 struct SystemAbilityOnDemandCondition { 40 OnDemandEventId eventId; 41 std::string name; 42 std::string value; 43 }; 44 45 struct SystemAbilityOnDemandEvent { 46 OnDemandEventId eventId; 47 std::string name; 48 std::string value; 49 bool persistence = false; 50 std::vector<SystemAbilityOnDemandCondition> conditions; 51 bool enableOnce = false; 52 }; 53 54 class OnDemandEventToParcel { 55 public: 56 static bool WriteOnDemandEventsToParcel(const std::vector<SystemAbilityOnDemandEvent>& abilityOnDemandEvents, 57 MessageParcel& data); 58 static bool WriteOnDemandEventToParcel(const SystemAbilityOnDemandEvent& event, MessageParcel& data); 59 static bool WriteOnDemandConditionToParcel(const SystemAbilityOnDemandCondition& condition, MessageParcel& data); 60 static bool ReadOnDemandEventsFromParcel(std::vector<SystemAbilityOnDemandEvent>& abilityOnDemandEvents, 61 MessageParcel& reply); 62 static bool ReadOnDemandEventFromParcel(SystemAbilityOnDemandEvent& event, MessageParcel& reply); 63 static bool ReadOnDemandConditionFromParcel(SystemAbilityOnDemandCondition& condition, MessageParcel& reply); 64 }; 65 } 66 #endif /* SAMGR_INTERFACES_INNERKITS_SAMGR_PROXY_SYSTEM_ABILITY_ON_DEMAND_EVENT_H */