1 /* 2 * Copyright (c) 2021 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 #ifndef FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_TIMER_TASK_H 16 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_TIMER_TASK_H 17 18 namespace OHOS { 19 namespace AppExecFwk { 20 /** 21 * @enum UpdateType 22 * Update type. 23 */ 24 enum UpdateType { 25 TYPE_INTERVAL_CHANGE, 26 TYPE_ATTIME_CHANGE, 27 TYPE_INTERVAL_TO_ATTIME, 28 TYPE_ATTIME_TO_INTERVAL, 29 TYPE_INTERVAL_ONCE, 30 }; 31 /** 32 * @class FormTimer 33 * form timer task. 34 */ 35 class FormTimer { 36 public: 37 int64_t formId; 38 int32_t userId; 39 int64_t period; 40 int hour; 41 int min; 42 bool isUpdateAt; 43 int64_t refreshTime; 44 bool isEnable = true; 45 bool isCountTimer; 46 UpdateType type = UpdateType::TYPE_INTERVAL_CHANGE; 47 FormTimer()48 FormTimer() 49 { 50 formId = -1; 51 userId = -1; 52 period = -1; 53 hour = -1; 54 min = -1; 55 isUpdateAt = false; 56 isCountTimer = false; 57 refreshTime = INT64_MAX; 58 type = UpdateType::TYPE_INTERVAL_CHANGE; 59 } 60 61 FormTimer(int64_t id, bool countTimer, int32_t uId = 0) 62 { 63 formId = id; 64 userId = uId; 65 period = -1; 66 hour = -1; 67 min = -1; 68 isUpdateAt = false; 69 isCountTimer = countTimer; 70 refreshTime = INT64_MAX; 71 type = UpdateType::TYPE_INTERVAL_CHANGE; 72 } 73 74 FormTimer(int64_t id, long repeatTime, int32_t uId = 0) 75 { 76 formId = id; 77 userId = uId; 78 period = repeatTime; 79 hour = -1; 80 min = -1; 81 isUpdateAt = false; 82 isCountTimer = true; 83 refreshTime = INT64_MAX; 84 type = UpdateType::TYPE_INTERVAL_CHANGE; 85 } 86 87 FormTimer(int64_t id, int hourTime, int minTime, int32_t uId = 0) 88 { 89 formId = id; 90 userId = uId; 91 hour = hourTime; 92 min = minTime; 93 period = -1; 94 isUpdateAt = true; 95 isCountTimer = false; 96 refreshTime = INT64_MAX; 97 type = UpdateType::TYPE_INTERVAL_CHANGE; 98 } ~FormTimer(void)99 ~FormTimer(void){ 100 } 101 }; 102 /** 103 * @class UpdateAtItem 104 * Update item at time. 105 */ 106 class UpdateAtItem { 107 public: 108 long updateAtTime = -1; 109 FormTimer refreshTask; 110 }; 111 /** 112 * @class DynamicRefreshItem 113 * Dynamic refresh item. 114 */ 115 class DynamicRefreshItem { 116 public: 117 int64_t formId = 0L; 118 int64_t settedTime = INT64_MAX; 119 int32_t userId = -1; DynamicRefreshItem()120 DynamicRefreshItem(){} 121 122 DynamicRefreshItem(int64_t id, int64_t time, int32_t uId = 0) 123 { 124 formId = id; 125 settedTime = time; 126 userId = uId; 127 } ~DynamicRefreshItem(void)128 ~DynamicRefreshItem(void){ 129 } 130 }; 131 /** 132 * @struct LimitInfo 133 * Limit info about a form. 134 */ 135 struct LimitInfo { 136 int refreshCount = 0; 137 bool isReported = false; 138 bool remindFlag = false; 139 }; 140 141 /** 142 * @struct FormTimerCfg 143 * Form timer config info. 144 */ 145 struct FormTimerCfg { 146 bool enableUpdate = false; 147 int64_t updateDuration = 0L; 148 int updateAtHour = -1; 149 int updateAtMin = -1; 150 }; 151 } // namespace AppExecFwk 152 } // namespace OHOS 153 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_TIMER_TASK_H 154