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 POWERMGR_POWER_MANAGER_POWER_H 17#define POWERMGR_POWER_MANAGER_POWER_H 18 19#include "napi/native_api.h" 20#include "napi/native_common.h" 21#include "napi/native_node_api.h" 22 23#include "power_mode_info.h" 24 25namespace OHOS { 26namespace PowerMgr { 27struct PowerAsyncCallbackInfo { 28 napi_env env; 29 napi_async_work asyncWork = nullptr; 30 napi_ref callbackRef = nullptr; 31 napi_deferred deferred = nullptr; 32 bool screenOn = false; 33 uint32_t powerMode = static_cast<uint32_t>(PowerMode::NORMAL_MODE); 34}; 35 36class Power { 37public: 38 static napi_value ShutdownDevice(napi_env env, napi_callback_info info); 39 static napi_value RebootDevice(napi_env env, napi_callback_info info); 40 static napi_value IsScreenOn(napi_env env, napi_callback_info info); 41 static napi_value WakeupDevice(napi_env env, napi_callback_info info); 42 static napi_value SuspendDevice(napi_env env, napi_callback_info info); 43 44private: 45 static napi_value RebootOrShutdown(napi_env env, napi_callback_info info, bool isReboot); 46 static void IsScreenOnCallBack(napi_env env, std::unique_ptr<PowerAsyncCallbackInfo>& asCallbackInfoPtr); 47}; 48} // namespace PowerMgr 49} // namespace OHOS 50 51#endif // POWERMGR_POWER_MANAGER_POWER_H 52