• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_NAPI_H
17 #define POWERMGR_POWER_MANAGER_POWER_NAPI_H
18 
19 #include "napi/native_api.h"
20 #include "napi/native_common.h"
21 #include "napi/native_node_api.h"
22 
23 #include "async_callback_info.h"
24 namespace OHOS {
25 namespace PowerMgr {
26 class PowerNapi {
27 public:
28     static napi_value Shutdown(napi_env env, napi_callback_info info);
29     static napi_value Reboot(napi_env env, napi_callback_info info);
30     static napi_value IsActive(napi_env env, napi_callback_info info);
31     static napi_value Wakeup(napi_env env, napi_callback_info info);
32     static napi_value Suspend(napi_env env, napi_callback_info info);
33     static napi_value SetPowerMode(napi_env env, napi_callback_info info);
34     static napi_value GetPowerMode(napi_env env, napi_callback_info info);
35 
36 private:
37     static napi_value RebootOrShutdown(napi_env env, napi_callback_info info, bool isReboot);
38     static napi_value SetPowerModeCallback(
39         napi_env& env, napi_value argv[], std::unique_ptr<AsyncCallbackInfo>& asyncInfo);
40     static napi_value SetPowerModePromise(
41         napi_env& env, napi_value argv[], std::unique_ptr<AsyncCallbackInfo>& asyncInfo);
42     static void AsyncWork(napi_env& env, std::unique_ptr<AsyncCallbackInfo>& asyncInfo, const std::string resourceName,
43         napi_async_execute_callback execute, napi_async_complete_callback complete);
44 };
45 } // namespace PowerMgr
46 } // namespace OHOS
47 
48 #endif // POWERMGR_POWER_MANAGER_POWER_NAPI_H
49