• 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_POWER_MGR_SERVICE_ADAPTER_H
17 #define POWERMGR_POWER_MGR_SERVICE_ADAPTER_H
18 
19 #include <iremote_object.h>
20 #include "ipower_mgr.h"
21 #include "power_mgr_stub.h"
22 
23 namespace OHOS {
24 namespace PowerMgr {
25 
26 class PowerMgrServiceAdapter : public PowerMgrStub {
27 public:
28     virtual int32_t RebootDeviceIpc(const std::string& reason, int32_t& powerError) override;
29     virtual int32_t RebootDeviceForDeprecatedIpc(const std::string& reason, int32_t& powerError) override;
30     virtual int32_t ShutDownDeviceIpc(const std::string& reason, int32_t& powerError) override;
31     virtual int32_t SetSuspendTagIpc(const std::string& tag, int32_t& powerError) override;
32     virtual int32_t SuspendDeviceIpc(int64_t callTimeMs, int32_t reasonValue, bool suspendImmed,
33         const std::string& apiVersion, int32_t& powerError) override;
34     virtual int32_t WakeupDeviceIpc(int64_t callTimeMs, int32_t reasonValue, const std::string& details,
35         const std::string& apiVersion, int32_t& powerError) override;
36     virtual int32_t WakeupDeviceAsyncIpc(int64_t callTimeMs, int32_t reasonValue, const std::string& details,
37         const std::string& apiVersion) override;
38     virtual int32_t RefreshActivityIpc(int64_t callTimeMs, int32_t activityType, bool needChangeBacklight) override;
39     virtual int32_t OverrideScreenOffTimeIpc(
40         int64_t timeout, const std::string& apiVersion, int32_t& powerError) override;
41     virtual int32_t RestoreScreenOffTimeIpc(const std::string& apiVersion, int32_t& powerError) override;
42     virtual int32_t GetStateIpc(int32_t& powerState) override;
43     virtual int32_t IsScreenOnIpc(bool needPrintLog, bool& isScreenOn) override;
44     virtual int32_t IsFoldScreenOnIpc(bool& isFoldScreenOn) override;
45     virtual int32_t IsCollaborationScreenOnIpc(bool& isCollaborationScreenOn) override;
46     virtual int32_t IsForceSleepingIpc(bool& isForceSleeping) override;
47     virtual int32_t ForceSuspendDeviceIpc(
48         int64_t callTimeMs, const std::string& apiVersion, const sptr<IPowerMgrAsync>& powerProxy) override;
49     virtual int32_t HibernateIpc(bool clearMemory, const std::string& reason,
50         const std::string& apiVersion, const sptr<IPowerMgrAsync>& powerProxy) override;
51     virtual int32_t CreateRunningLockIpc(
52         const sptr<IRemoteObject>& remoteObj, const RunningLockInfo& runningLockInfo, int32_t& powerError) override;
53     virtual int32_t ReleaseRunningLockIpc(const sptr<IRemoteObject>& remoteObj, const std::string& name = "") override;
54     virtual int32_t IsRunningLockTypeSupportedIpc(int32_t lockType, bool& lockSupported) override;
55     virtual int32_t UpdateWorkSourceIpc(const sptr<IRemoteObject>& remoteObj,
56         const std::vector<int32_t>& workSources) override;
57     virtual int32_t LockIpc(const sptr<IRemoteObject>& remoteObj, int32_t timeOutMs, int32_t& powerError) override;
58     virtual int32_t UnLockIpc(
59         const sptr<IRemoteObject>& remoteObj, const std::string& name, int32_t& powerError) override;
60     virtual int32_t QueryRunningLockListsIpc(std::map<std::string, RunningLockInfo>& runningLockLists) override;
61     virtual int32_t IsUsedIpc(const sptr<IRemoteObject>& remoteObj, bool& isUsed) override;
62     virtual int32_t ProxyRunningLockIpc(bool isProxied, pid_t pid, pid_t uid) override;
63     virtual int32_t ProxyRunningLocksIpc(bool isProxied, const VectorPair& vectorPairInfos) override;
64     virtual int32_t ResetRunningLocksIpc() override;
65     virtual int32_t RegisterPowerStateCallbackIpc(const sptr<IPowerStateCallback>& callback, bool isSync) override;
66     virtual int32_t UnRegisterPowerStateCallbackIpc(const sptr<IPowerStateCallback>& callback) override;
67 
68     virtual int32_t RegisterSyncSleepCallbackIpc(
69         const sptr<ISyncSleepCallback>& callback, int32_t priorityValue) override;
70     virtual int32_t UnRegisterSyncSleepCallbackIpc(const sptr<ISyncSleepCallback>& callback) override;
71     virtual int32_t RegisterSyncHibernateCallbackIpc(const sptr<ISyncHibernateCallback>& callback) override;
72     virtual int32_t UnRegisterSyncHibernateCallbackIpc(const sptr<ISyncHibernateCallback>& callback) override;
73 
74     virtual int32_t RegisterSuspendTakeoverCallbackIpc(
75         const sptr<ITakeOverSuspendCallback>& callback, int32_t priority) override;
76     virtual int32_t UnRegisterSuspendTakeoverCallbackIpc(const sptr<ITakeOverSuspendCallback>& callback) override;
77 
78     virtual int32_t RegisterPowerModeCallbackIpc(const sptr<IPowerModeCallback>& callback) override;
79     virtual int32_t UnRegisterPowerModeCallbackIpc(const sptr<IPowerModeCallback>& callback) override;
80 
81     virtual int32_t RegisterScreenStateCallbackIpc(
82         int32_t remainTime, const sptr<IScreenOffPreCallback>& callback) override;
83     virtual int32_t UnRegisterScreenStateCallbackIpc(const sptr<IScreenOffPreCallback>& callback) override;
84 
85     virtual int32_t RegisterRunningLockCallbackIpc(const sptr<IPowerRunninglockCallback>& callback) override;
86     virtual int32_t UnRegisterRunningLockCallbackIpc(const sptr<IPowerRunninglockCallback>& callback) override;
87     virtual int32_t SetDisplaySuspendIpc(bool enable) override;
88     virtual int32_t SetDeviceModeIpc(int32_t modeValue, int32_t& powerError) override;
89     virtual int32_t GetDeviceModeIpc(int32_t& powerMode) override;
90     virtual int32_t ShellDumpIpc(const std::vector<std::string>& args, uint32_t argc, std::string& returnDump) override;
91     virtual int32_t IsStandbyIpc(bool& isStandby, int32_t& powerError) override;
92     virtual int32_t SetForceTimingOutIpc(bool enabled, const sptr<IRemoteObject>& token, int32_t& powerError) override;
93     virtual int32_t LockScreenAfterTimingOutIpc(bool enabledLockScreen, bool checkLock, bool sendScreenOffEvent,
94         const sptr<IRemoteObject>& token, int32_t& powerError) override;
95     virtual int32_t IsRunningLockEnabledIpc(int32_t lockType, bool& result, int32_t& powerError) override;
96 
97     int32_t RegisterShutdownCallbackIpc(
98         const sptr<ITakeOverShutdownCallback>& callback, int32_t priorityValue) override;
99     int32_t UnRegisterShutdownCallbackIpc(const sptr<ITakeOverShutdownCallback>& callback) override;
100 
101     int32_t RegisterShutdownCallbackIpc(const sptr<IAsyncShutdownCallback>& callback, int32_t priorityValue) override;
102     int32_t UnRegisterShutdownCallbackIpc(const sptr<IAsyncShutdownCallback>& callback) override;
103     int32_t RegisterShutdownCallbackIpc(const sptr<ISyncShutdownCallback>& callback, int32_t priorityValue) override;
104     int32_t UnRegisterShutdownCallbackIpc(const sptr<ISyncShutdownCallback>& callback) override;
105     virtual int32_t RefreshActivityIpc(
106         int64_t callTimeMs, int32_t activityType, const std::string& refreshReason, int32_t& powerError) override;
107 
108     virtual PowerErrors RebootDevice(const std::string& reason) = 0;
109     virtual PowerErrors RebootDeviceForDeprecated(const std::string& reason) = 0;
110     virtual PowerErrors ShutDownDevice(const std::string& reason) = 0;
111     virtual PowerErrors SetSuspendTag(const std::string& tag) = 0;
112     virtual PowerErrors SuspendDevice(int64_t callTimeMs, SuspendDeviceType reason,
113         bool suspendImmed, const std::string& apiVersion = "-1") = 0;
114     virtual PowerErrors WakeupDevice(int64_t callTimeMs, WakeupDeviceType reason,
115         const std::string& details, const std::string& apiVersion = "-1") = 0;
116     virtual void WakeupDeviceAsync(int64_t callTimeMs, WakeupDeviceType reason, const std::string& details) = 0;
117     virtual bool RefreshActivity(int64_t callTimeMs, UserActivityType type, bool needChangeBacklight) = 0;
118     virtual PowerErrors OverrideScreenOffTime(int64_t timeout, const std::string& apiVersion = "-1") = 0;
119     virtual PowerErrors RestoreScreenOffTime(const std::string& apiVersion = "-1") = 0;
120     virtual PowerState GetState() = 0;
121     virtual bool IsScreenOn(bool needPrintLog = true) = 0;
122     virtual bool IsFoldScreenOn() = 0;
123     virtual bool IsCollaborationScreenOn() = 0;
124     virtual bool IsForceSleeping() = 0;
125     virtual PowerErrors ForceSuspendDevice(int64_t callTimeMs, const std::string& apiVersion = "-1") = 0;
126     virtual PowerErrors Hibernate(
127         bool clearMemory, const std::string& reason = "", const std::string& apiVersion = "-1") = 0;
128     virtual PowerErrors CreateRunningLock(
129         const sptr<IRemoteObject>& remoteObj, const RunningLockInfo& runningLockInfo) = 0;
130     virtual bool ReleaseRunningLock(const sptr<IRemoteObject>& remoteObj, const std::string& name = "") = 0;
131     virtual bool IsRunningLockTypeSupported(RunningLockType type) = 0;
132     virtual bool UpdateWorkSource(const sptr<IRemoteObject>& remoteObj,
133         const std::vector<int32_t>& workSources) = 0;
134     virtual PowerErrors Lock(const sptr<IRemoteObject>& remoteObj, int32_t timeOutMs = -1) = 0;
135     virtual PowerErrors UnLock(const sptr<IRemoteObject>& remoteObj, const std::string& name = "") = 0;
136     virtual bool QueryRunningLockLists(std::map<std::string, RunningLockInfo>& runningLockLists) = 0;
137     virtual bool IsUsed(const sptr<IRemoteObject>& remoteObj) = 0;
138     virtual bool ProxyRunningLock(bool isProxied, pid_t pid, pid_t uid) = 0;
139     virtual bool ProxyRunningLocks(bool isProxied,
140         const std::vector<std::pair<pid_t, pid_t>>& processInfos) = 0;
141     virtual bool ResetRunningLocks() = 0;
142     virtual bool RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback, bool isSync = true) = 0;
143     virtual bool UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) = 0;
144 
145     virtual bool RegisterSyncSleepCallback(const sptr<ISyncSleepCallback>& callback, SleepPriority priority) = 0;
146     virtual bool UnRegisterSyncSleepCallback(const sptr<ISyncSleepCallback>& callback) = 0;
147     virtual bool RegisterSyncHibernateCallback(const sptr<ISyncHibernateCallback>& callback) = 0;
148     virtual bool UnRegisterSyncHibernateCallback(const sptr<ISyncHibernateCallback>& callback) = 0;
149 
150     virtual bool RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) = 0;
151     virtual bool UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) = 0;
152 
153     virtual bool RegisterScreenStateCallback(int32_t remainTime, const sptr<IScreenOffPreCallback>& callback) = 0;
154     virtual bool UnRegisterScreenStateCallback(const sptr<IScreenOffPreCallback>& callback) = 0;
155 
156     virtual bool RegisterRunningLockCallback(const sptr<IPowerRunninglockCallback>& callback) = 0;
157     virtual bool UnRegisterRunningLockCallback(const sptr<IPowerRunninglockCallback>& callback) = 0;
158     virtual bool SetDisplaySuspend(bool enable) = 0;
159     virtual PowerErrors SetDeviceMode(const PowerMode& mode) = 0;
160     virtual PowerMode GetDeviceMode() = 0;
161     virtual std::string ShellDump(const std::vector<std::string>& args, uint32_t argc) = 0;
162     virtual PowerErrors IsStandby(bool& isStandby) = 0;
163     virtual PowerErrors SetForceTimingOut(bool enabled, const sptr<IRemoteObject>& token) = 0;
164     virtual PowerErrors LockScreenAfterTimingOut(
165         bool enabledLockScreen, bool checkLock, bool sendScreenOffEvent, const sptr<IRemoteObject>& token) = 0;
166     virtual PowerErrors IsRunningLockEnabled(const RunningLockType type, bool& result) = 0;
167     virtual PowerErrors RefreshActivity(
168         int64_t callTimeMs, UserActivityType type, const std::string& refreshReason) = 0;
169 
170     virtual void RegisterShutdownCallback(
171         const sptr<ITakeOverShutdownCallback>& callback, ShutdownPriority priority) = 0;
172     virtual void UnRegisterShutdownCallback(const sptr<ITakeOverShutdownCallback>& callback) = 0;
173 
174     virtual void RegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback, ShutdownPriority priority) = 0;
175     virtual void UnRegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback) = 0;
176     virtual void RegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback, ShutdownPriority priority) = 0;
177     virtual void UnRegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback) = 0;
178 
179     virtual bool RegisterSuspendTakeoverCallback(
180         const sptr<ITakeOverSuspendCallback>& callback, TakeOverSuspendPriority priority) = 0;
181     virtual bool UnRegisterSuspendTakeoverCallback(const sptr<ITakeOverSuspendCallback>& callback) = 0;
182 };
183 } // namespace PowerMgr
184 } // namespace OHOS
185 #endif // POWERMGR_POWER_MGR_SERVICE_ADAPTER_H