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 OHOS_FILEMGMT_BATTERY_STATUS_H 17 #define OHOS_FILEMGMT_BATTERY_STATUS_H 18 19 #include <cstdint> 20 #include <atomic> 21 22 #ifdef SUPPORT_POWER 23 #include "battery_info.h" 24 #include "battery_srv_client.h" 25 #endif 26 27 namespace OHOS::FileManagement::CloudSync { 28 class BatteryStatus { 29 public: 30 enum CapacityLevel { 31 LEVEL_NORMAL, 32 LEVEL_LOW, 33 LEVEL_TOO_LOW, 34 }; 35 static bool IsAllowUpload(bool forceFlag); 36 static bool IsBatteryCapcityOkay(); 37 static CapacityLevel GetCapacityLevel(); 38 static void GetInitChargingStatus(); 39 static void SetChargingStatus(bool status); 40 static bool IsCharging(); 41 private: 42 static int32_t GetCapacity(); 43 static inline CapacityLevel level_{LEVEL_NORMAL}; 44 static inline std::atomic_bool isCharging_{false}; 45 }; 46 } // namespace OHOS::FileManagement::CloudSync 47 48 #endif // OHOS_FILEMGMT_BATTERY_STATUS_H