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 16 #ifndef POWERMGR_POWER_MANAGE_H 17 #define POWERMGR_POWER_MANAGE_H 18 19 #include <ohos_types.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif // __cplusplus 24 25 typedef enum { 26 SUSPEND_DEVICE_REASON_MIN = 0, 27 SUSPEND_DEVICE_REASON_APPLICATION = SUSPEND_DEVICE_REASON_MIN, 28 SUSPEND_DEVICE_REASON_DEVICE_ADMIN = 1, 29 SUSPEND_DEVICE_REASON_TIMEOUT = 2, 30 SUSPEND_DEVICE_REASON_LID_SWITCH = 3, 31 SUSPEND_DEVICE_REASON_POWER_BUTTON = 4, 32 SUSPEND_DEVICE_REASON_HDMI = 5, 33 SUSPEND_DEVICE_REASON_SLEEP_BUTTON = 6, 34 SUSPEND_DEVICE_REASON_ACCESSIBILITY = 7, 35 SUSPEND_DEVICE_REASON_FORCE_SUSPEND = 8, 36 SUSPEND_DEVICE_REASON_MAX = SUSPEND_DEVICE_REASON_FORCE_SUSPEND, 37 } SuspendDeviceType; 38 39 typedef enum { 40 WAKEUP_DEVICE_UNKNOWN = 0, 41 WAKEUP_DEVICE_POWER_BUTTON = 1, 42 WAKEUP_DEVICE_APPLICATION = 2, 43 WAKEUP_DEVICE_PLUGGED_IN = 3, 44 WAKEUP_DEVICE_GESTURE = 4, 45 WAKEUP_DEVICE_CAMERA_LAUNCH = 5, 46 WAKEUP_DEVICE_WAKE_KEY = 6, 47 WAKEUP_DEVICE_WAKE_MOTION = 7, 48 WAKEUP_DEVICE_HDMI = 8, 49 WAKEUP_DEVICE_LID = 9, 50 } WakeupDeviceType; 51 52 /** 53 * Suspend device. 54 * 55 * @param reason The reason why will you suspend the device. 56 * @param suspendImmed The flag indicating whether the system will suspend immediately. 57 */ 58 void SuspendDevice(SuspendDeviceType reason, BOOL suspendImmed); 59 60 /** 61 * Wake up the device. 62 * 63 * @param reason The reason for waking up the device. 64 * @param details Details of the wakeup reason. 65 */ 66 void WakeupDevice(WakeupDeviceType reason, const char* details); 67 68 #ifdef __cplusplus 69 } 70 #endif // __cplusplus 71 #endif // POWERMGR_POWER_MANAGE_H 72