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 #ifndef FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_CONDITION_H 16 #define FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_CONDITION_H 17 18 #include <time.h> 19 20 namespace OHOS { 21 namespace WorkScheduler { 22 class WorkCondition { 23 public: 24 virtual ~WorkCondition() = default; 25 26 enum Type { 27 NETWORK = 0, 28 CHARGER, 29 BATTERY_STATUS, 30 BATTERY_LEVEL, 31 STORAGE, 32 TIMER, // uint32_t intervalTime, int32_t cycle, bool repeat 33 UNKNOWN, 34 }; 35 36 enum Network { 37 NETWORK_TYPE_ANY = 0, 38 NETWORK_TYPE_MOBILE, 39 NETWORK_TYPE_WIFI, 40 NETWORK_TYPE_BLUETOOTH, 41 NETWORK_TYPE_WIFI_P2P, 42 NETWORK_TYPE_ETHERNET, 43 NETWORK_UNKNOWN 44 }; 45 46 enum Charger { 47 CHARGING_PLUGGED_ANY = 0, 48 CHARGING_PLUGGED_AC, 49 CHARGING_PLUGGED_USB, 50 CHARGING_PLUGGED_WIRELESS, 51 CHARGING_UNPLUGGED, 52 CHARGING_UNKNOWN, 53 }; 54 55 enum BatteryStatus { 56 BATTERY_STATUS_LOW = 0, 57 BATTERY_STATUS_OKAY, 58 BATTERY_STATUS_LOW_OR_OKAY, 59 BATTERY_UNKNOWN 60 }; 61 62 enum Storage { 63 STORAGE_LEVEL_LOW = 0, 64 STORAGE_LEVEL_OKAY, 65 STORAGE_LEVEL_LOW_OR_OKAY, 66 STORAGE_UNKNOWN 67 }; 68 }; 69 70 struct Condition { 71 int enumVal; 72 int32_t intVal; 73 int64_t longVal; 74 uint32_t uintVal; 75 time_t timeVal; 76 bool boolVal; 77 }; 78 } // namespace WorkScheduler 79 } // namespace OHOS 80 #endif // FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_CONDITION_H