• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 POWERMGR_IPOWER_MANAGER_H
17 #define POWERMGR_IPOWER_MANAGER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include <iremote_broker.h>
23 #include <iremote_object.h>
24 
25 #include "ipower_mode_callback.h"
26 #include "ipower_state_callback.h"
27 #include "ishutdown_callback.h"
28 #include "power_errors.h"
29 #include "power_state_machine_info.h"
30 #include "running_lock_info.h"
31 
32 namespace OHOS {
33 namespace PowerMgr {
34 class IPowerMgr : public IRemoteBroker {
35 public:
36     enum {
37         CREATE_RUNNINGLOCK = 0,
38         RELEASE_RUNNINGLOCK,
39         IS_RUNNINGLOCK_TYPE_SUPPORTED,
40         RUNNINGLOCK_LOCK,
41         RUNNINGLOCK_UNLOCK,
42         RUNNINGLOCK_SET_WORK_TRIGGER_LIST,
43         RUNNINGLOCK_ISUSED,
44         PROXY_RUNNINGLOCK,
45         WAKEUP_DEVICE,
46         SUSPEND_DEVICE,
47         REFRESH_ACTIVITY,
48         OVERRIDE_DISPLAY_OFF_TIME,
49         RESTORE_DISPLAY_OFF_TIME,
50         GET_STATE,
51         IS_SCREEN_ON,
52         FORCE_DEVICE_SUSPEND,
53         REBOOT_DEVICE,
54         REBOOT_DEVICE_FOR_DEPRECATED,
55         SHUTDOWN_DEVICE,
56         REG_POWER_STATE_CALLBACK,
57         UNREG_POWER_STATE_CALLBACK,
58         REG_SHUTDOWN_CALLBACK,
59         UNREG_SHUTDOWN_CALLBACK,
60         REG_POWER_MODE_CALLBACK,
61         UNREG_POWER_MODE_CALLBACK,
62         SET_DISPLAY_SUSPEND,
63         SETMODE_DEVICE,
64         GETMODE_DEVICE,
65         SHELL_DUMP
66     };
67 
68     virtual PowerErrors CreateRunningLock(const sptr<IRemoteObject>& remoteObj,
69         const RunningLockInfo& runningLockInfo) = 0;
70     virtual bool ReleaseRunningLock(const sptr<IRemoteObject>& remoteObj) = 0;
71     virtual bool IsRunningLockTypeSupported(uint32_t type) = 0;
72     virtual bool Lock(const sptr<IRemoteObject>& remoteObj, const RunningLockInfo& runningLockInfo,
73         uint32_t timeOutMs) = 0;
74     virtual bool UnLock(const sptr<IRemoteObject>& remoteObj) = 0;
75     virtual bool IsUsed(const sptr<IRemoteObject>& remoteObj) = 0;
76     virtual bool SetWorkTriggerList(const sptr<IRemoteObject>& remoteObj, const WorkTriggerList& workTriggerList) = 0;
77     virtual bool ProxyRunningLock(bool proxyLock, pid_t uid, pid_t pid) = 0;
78 
79     // Used for power state machine.
80     virtual PowerErrors RebootDevice(const std::string& reason) = 0;
81     virtual PowerErrors RebootDeviceForDeprecated(const std::string& reason) = 0;
82     virtual PowerErrors ShutDownDevice(const std::string& reason) = 0;
83     virtual PowerErrors SuspendDevice(int64_t callTimeMs, SuspendDeviceType reason, bool suspendImmed) = 0;
84     virtual PowerErrors WakeupDevice(int64_t callTimeMs, WakeupDeviceType reason, const std::string& details) = 0;
85     virtual bool RefreshActivity(int64_t callTimeMs, UserActivityType type, bool needChangeBacklight) = 0;
86     virtual bool OverrideScreenOffTime(int64_t timeout) = 0;
87     virtual bool RestoreScreenOffTime() = 0;
88     virtual PowerState GetState() = 0;
89     virtual bool IsScreenOn() = 0;
90     virtual bool ForceSuspendDevice(int64_t callTimeMs) = 0;
91     virtual bool RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) = 0;
92     virtual bool UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) = 0;
93 
94     // Used for callback registration upon shutdown.
95     virtual bool RegisterShutdownCallback(IShutdownCallback::ShutdownPriority priority,
96         const sptr<IShutdownCallback>& callback) = 0;
97     virtual bool UnRegisterShutdownCallback(const sptr<IShutdownCallback>& callback) = 0;
98 
99     // Used for callback registration upon power mode.
100     virtual bool RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) = 0;
101     virtual bool UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) = 0;
102 
103     virtual bool SetDisplaySuspend(bool enable) = 0;
104     virtual PowerErrors SetDeviceMode(const PowerMode& mode) = 0;
105     virtual PowerMode GetDeviceMode() = 0;
106     virtual std::string ShellDump(const std::vector<std::string>& args, uint32_t argc) = 0;
107 
108     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.powermgr.IPowerMgr");
109 };
110 } // namespace PowerMgr
111 } // namespace OHOS
112 #endif // POWERMGR_IPOWER_MANAGER_H
113