• 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 ProxyRunningLock(bool isProxied, pid_t pid, pid_t uid) override;
52     virtual bool ProxyRunningLocks(bool isProxied,
53         const std::vector<std::pair<pid_t, pid_t>>& processInfos) override;
54     virtual bool ResetRunningLocks() override;
55     virtual bool IsUsed(const sptr<IRemoteObject>& remoteObj) override;
56     // Use for PowerStateMachine
57     virtual PowerErrors SuspendDevice(int64_t callTimeMs, SuspendDeviceType reason, bool suspendImmed) override;
58     virtual PowerErrors WakeupDevice(int64_t callTimeMs, WakeupDeviceType reason, const std::string& details) override;
59     virtual bool RefreshActivity(int64_t callTimeMs, UserActivityType type, bool needChangeBacklight) override;
60     virtual bool OverrideScreenOffTime(int64_t timeout) override;
61     virtual bool RestoreScreenOffTime() override;
62     virtual PowerState GetState() override;
63     virtual bool IsScreenOn() override;
64     virtual bool ForceSuspendDevice(int64_t callTimeMs) override;
65     virtual PowerErrors RebootDevice(const std::string& reason) override;
66     virtual PowerErrors RebootDeviceForDeprecated(const std::string& reason) override;
67     virtual PowerErrors ShutDownDevice(const std::string& reason) override;
68     virtual bool RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) override;
69     virtual bool UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) override;
70     virtual bool RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
71     virtual bool UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
72     virtual bool SetDisplaySuspend(bool enable) override;
73     virtual PowerErrors SetDeviceMode(const PowerMode& mode) override;
74     virtual PowerMode GetDeviceMode() override;
75     virtual std::string ShellDump(const std::vector<std::string>& args, uint32_t argc) override;
76     virtual PowerErrors IsStandby(bool& isStandby) override;
77 
78     void RegisterShutdownCallback(const sptr<ITakeOverShutdownCallback>& callback, ShutdownPriority priority) override;
79     void UnRegisterShutdownCallback(const sptr<ITakeOverShutdownCallback>& callback) override;
80     void RegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback, ShutdownPriority priority) override;
81     void UnRegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback) override;
82     void RegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback, ShutdownPriority priority) override;
83     void UnRegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback) override;
84 
85 private:
86     static inline BrokerDelegator<PowerMgrProxy> delegator_;
87 };
88 } // namespace PowerMgr
89 } // namespace OHOS
90 #endif // POWERMGR_SERVICES_IPOWER_MANAGER_PROXY_H
91