• 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 "ishutdown_callback.h"
30 #include "ipower_mode_callback.h"
31 #include "ipower_state_callback.h"
32 #include "ipower_mgr.h"
33 #include "running_lock_info.h"
34 #include "power_state_machine_info.h"
35 #include "power_errors.h"
36 
37 namespace OHOS {
38 namespace PowerMgr {
39 class PowerMgrProxy : public IRemoteProxy<IPowerMgr> {
40 public:
PowerMgrProxy(const sptr<IRemoteObject> & impl)41     explicit PowerMgrProxy(const sptr<IRemoteObject>& impl)
42         : IRemoteProxy<IPowerMgr>(impl) {}
43     ~PowerMgrProxy() = default;
44     DISALLOW_COPY_AND_MOVE(PowerMgrProxy);
45 
46     virtual PowerErrors CreateRunningLock(const sptr<IRemoteObject>& remoteObj,
47         const RunningLockInfo& runningLockInfo) override;
48     virtual bool ReleaseRunningLock(const sptr<IRemoteObject>& remoteObj) override;
49     virtual bool IsRunningLockTypeSupported(uint32_t type) override;
50     virtual bool Lock(const sptr<IRemoteObject>& remoteObj, const RunningLockInfo& runningLockInfo,
51         uint32_t timeOutMs) override;
52     virtual bool UnLock(const sptr<IRemoteObject>& remoteObj) override;
53     virtual bool SetWorkTriggerList(const sptr<IRemoteObject>& remoteObj,
54         const WorkTriggerList& workTriggerList) override;
55     virtual bool ProxyRunningLock(bool proxyLock, pid_t uid, pid_t pid) 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 RegisterShutdownCallback(IShutdownCallback::ShutdownPriority priority,
72         const sptr<IShutdownCallback>& callback) override;
73     virtual bool UnRegisterShutdownCallback(const sptr<IShutdownCallback>& callback) override;
74     virtual bool RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
75     virtual bool UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
76     virtual bool SetDisplaySuspend(bool enable) override;
77     virtual PowerErrors SetDeviceMode(const PowerMode& mode) override;
78     virtual PowerMode GetDeviceMode() override;
79     virtual std::string ShellDump(const std::vector<std::string>& args, uint32_t argc) override;
80 private:
81     static inline BrokerDelegator<PowerMgrProxy> delegator_;
82 };
83 } // namespace PowerMgr
84 } // namespace OHOS
85 #endif // POWERMGR_SERVICES_IPOWER_MANAGER_PROXY_H
86