1 /* 2 * Copyright (c) 2022 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 FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_EVENT_INFO_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_EVENT_INFO_H 18 19 #include <string> 20 #include <vector> 21 22 #include <refbase.h> 23 24 #include "common_event_manager.h" 25 #include "common_event_support.h" 26 #include "want.h" 27 28 #include "event_info.h" 29 30 namespace OHOS { 31 namespace BackgroundTaskMgr { 32 enum EventId { 33 EVENT_APP_RUN_FRONT = 1, 34 EVENT_SCREEN_ON, 35 EVENT_SCREEN_OFF, 36 EVENT_SCREEN_UNLOCK, 37 EVENT_BATTERY_LOW, 38 EVENT_BATTERY_OKAY, 39 EVENT_MAX, 40 }; 41 42 class EventInfo { 43 public: EventInfo()44 EventInfo() {} 45 virtual ~EventInfo() = default; 46 SetEventId(const int32_t & eventId)47 inline void SetEventId(const int32_t& eventId) 48 { 49 eventId_ = eventId; 50 } 51 GetEventId()52 inline const int32_t& GetEventId() const 53 { 54 return eventId_; 55 } 56 SetIntArgs(const std::vector<int32_t> args)57 inline void SetIntArgs(const std::vector<int32_t> args) 58 { 59 intArgs_ = args; 60 } 61 GetIntArgs()62 inline const std::vector<int32_t>& GetIntArgs() const 63 { 64 return intArgs_; 65 } 66 SetStringArgs(const std::vector<std::string> args)67 inline void SetStringArgs(const std::vector<std::string> args) 68 { 69 stringArgs_ = args; 70 } 71 GetStringArgs()72 inline const std::vector<std::string>& GetStringArgs() const 73 { 74 return stringArgs_; 75 } 76 ToString()77 virtual inline const std::string ToString() const 78 { 79 std::string ret = "eventId : " + std::to_string(eventId_) + " intArgs_ : ["; 80 for_each(intArgs_.cbegin(), intArgs_.cend(), 81 [&ret](const int32_t& val)->void { ret += ("" + std::to_string(val));}); 82 ret += "], stringArgs_ : ["; 83 for_each(stringArgs_.cbegin(), stringArgs_.cend(), 84 [&ret](const std::string& val)->void { ret += ("" + val);}); 85 ret += "]"; 86 return ret; 87 } 88 89 private: 90 int32_t eventId_ {0}; 91 std::vector<int32_t> intArgs_; 92 std::vector<std::string> stringArgs_; 93 }; 94 } // namespace BackgroundTaskMgr 95 } // namespace OHOS 96 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_EVENT_INFO_H