• 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_SERVICES_IPOWER_MANAGER_PROXY_H
17 #define POWERMGR_SERVICES_IPOWER_MANAGER_PROXY_H
18 
19 #include <cstdint>
20 #include <sys/types.h>
21 #include <functional>
22 #include <iosfwd>
23 #include <vector>
24 #include <iremote_proxy.h>
25 #include <nocopyable.h>
26 #include "refbase.h"
27 #include "iremote_broker.h"
28 #include "iremote_object.h"
29 #include "ipower_mode_callback.h"
30 #include "ipower_state_callback.h"
31 #include "ipower_mgr.h"
32 #include "running_lock_info.h"
33 #include "power_state_machine_info.h"
34 #include "power_errors.h"
35 
36 namespace OHOS {
37 namespace PowerMgr {
38 class PowerMgrProxy : public IRemoteProxy<IPowerMgr> {
39 public:
PowerMgrProxy(const sptr<IRemoteObject> & impl)40     explicit PowerMgrProxy(const sptr<IRemoteObject>& impl)
41         : IRemoteProxy<IPowerMgr>(impl) {}
42     ~PowerMgrProxy() = default;
43     DISALLOW_COPY_AND_MOVE(PowerMgrProxy);
44 
45     virtual PowerErrors CreateRunningLock(const sptr<IRemoteObject>& remoteObj,
46         const RunningLockInfo& runningLockInfo) override;
47     virtual bool ReleaseRunningLock(const sptr<IRemoteObject>& remoteObj) override;
48     virtual bool IsRunningLockTypeSupported(RunningLockType type) override;
49     virtual bool Lock(const sptr<IRemoteObject>& remoteObj, int32_t timeOutMs) override;
50     virtual bool UnLock(const sptr<IRemoteObject>& remoteObj) override;
51     virtual bool QueryRunningLockLists(std::map<std::string, RunningLockInfo>& runningLockLists) override;
52     virtual bool ProxyRunningLock(bool isProxied, pid_t pid, pid_t uid) override;
53     virtual bool ProxyRunningLocks(bool isProxied,
54         const std::vector<std::pair<pid_t, pid_t>>& processInfos) override;
55     virtual bool ResetRunningLocks() override;
56     virtual bool IsUsed(const sptr<IRemoteObject>& remoteObj) override;
57     // Use for PowerStateMachine
58     virtual PowerErrors SuspendDevice(int64_t callTimeMs, SuspendDeviceType reason, bool suspendImmed) override;
59     virtual PowerErrors WakeupDevice(int64_t callTimeMs, WakeupDeviceType reason, const std::string& details) override;
60     virtual bool RefreshActivity(int64_t callTimeMs, UserActivityType type, bool needChangeBacklight) override;
61     virtual bool OverrideScreenOffTime(int64_t timeout) override;
62     virtual bool RestoreScreenOffTime() override;
63     virtual PowerState GetState() override;
64     virtual bool IsScreenOn() override;
65     virtual bool ForceSuspendDevice(int64_t callTimeMs) override;
66     virtual PowerErrors RebootDevice(const std::string& reason) override;
67     virtual PowerErrors RebootDeviceForDeprecated(const std::string& reason) override;
68     virtual PowerErrors ShutDownDevice(const std::string& reason) override;
69     virtual bool RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) override;
70     virtual bool UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) override;
71     virtual bool RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
72     virtual bool UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
73     virtual bool SetDisplaySuspend(bool enable) override;
74     virtual PowerErrors SetDeviceMode(const PowerMode& mode) override;
75     virtual PowerMode GetDeviceMode() override;
76     virtual std::string ShellDump(const std::vector<std::string>& args, uint32_t argc) override;
77     virtual PowerErrors IsStandby(bool& isStandby) override;
78 
79     void RegisterShutdownCallback(const sptr<ITakeOverShutdownCallback>& callback, ShutdownPriority priority) override;
80     void UnRegisterShutdownCallback(const sptr<ITakeOverShutdownCallback>& callback) override;
81     void RegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback, ShutdownPriority priority) override;
82     void UnRegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback) override;
83     void RegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback, ShutdownPriority priority) override;
84     void UnRegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback) override;
85 
86     virtual bool RegisterSyncSleepCallback(const sptr<ISyncSleepCallback>& callback, SleepPriority priority) override;
87     virtual bool UnRegisterSyncSleepCallback(const sptr<ISyncSleepCallback>& callback) override;
88 
89 private:
90     static inline BrokerDelegator<PowerMgrProxy> delegator_;
91 };
92 } // namespace PowerMgr
93 } // namespace OHOS
94 #endif // POWERMGR_SERVICES_IPOWER_MANAGER_PROXY_H
95