15ccb8f90Sopenharmony_ci/*
25ccb8f90Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
35ccb8f90Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45ccb8f90Sopenharmony_ci * you may not use this file except in compliance with the License.
55ccb8f90Sopenharmony_ci * You may obtain a copy of the License at
65ccb8f90Sopenharmony_ci *
75ccb8f90Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
85ccb8f90Sopenharmony_ci *
95ccb8f90Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105ccb8f90Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115ccb8f90Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125ccb8f90Sopenharmony_ci * See the License for the specific language governing permissions and
135ccb8f90Sopenharmony_ci * limitations under the License.
145ccb8f90Sopenharmony_ci */
155ccb8f90Sopenharmony_ci
165ccb8f90Sopenharmony_ci#ifndef POWERMGR_SERVICES_IPOWER_MANAGER_PROXY_H
175ccb8f90Sopenharmony_ci#define POWERMGR_SERVICES_IPOWER_MANAGER_PROXY_H
185ccb8f90Sopenharmony_ci
195ccb8f90Sopenharmony_ci#include <cstdint>
205ccb8f90Sopenharmony_ci#include <sys/types.h>
215ccb8f90Sopenharmony_ci#include <functional>
225ccb8f90Sopenharmony_ci#include <iosfwd>
235ccb8f90Sopenharmony_ci#include <vector>
245ccb8f90Sopenharmony_ci#include <iremote_proxy.h>
255ccb8f90Sopenharmony_ci#include <nocopyable.h>
265ccb8f90Sopenharmony_ci#include "refbase.h"
275ccb8f90Sopenharmony_ci#include "iremote_broker.h"
285ccb8f90Sopenharmony_ci#include "iremote_object.h"
295ccb8f90Sopenharmony_ci#include "ipower_mode_callback.h"
305ccb8f90Sopenharmony_ci#include "ipower_state_callback.h"
315ccb8f90Sopenharmony_ci#include "ipower_runninglock_callback.h"
325ccb8f90Sopenharmony_ci#include "ipower_mgr.h"
335ccb8f90Sopenharmony_ci#include "iscreen_off_pre_callback.h"
345ccb8f90Sopenharmony_ci#include "running_lock_info.h"
355ccb8f90Sopenharmony_ci#include "power_state_machine_info.h"
365ccb8f90Sopenharmony_ci#include "power_errors.h"
375ccb8f90Sopenharmony_ci
385ccb8f90Sopenharmony_cinamespace OHOS {
395ccb8f90Sopenharmony_cinamespace PowerMgr {
405ccb8f90Sopenharmony_ciclass PowerMgrProxy : public IRemoteProxy<IPowerMgr> {
415ccb8f90Sopenharmony_cipublic:
425ccb8f90Sopenharmony_ci    explicit PowerMgrProxy(const sptr<IRemoteObject>& impl)
435ccb8f90Sopenharmony_ci        : IRemoteProxy<IPowerMgr>(impl) {}
445ccb8f90Sopenharmony_ci    ~PowerMgrProxy() = default;
455ccb8f90Sopenharmony_ci    DISALLOW_COPY_AND_MOVE(PowerMgrProxy);
465ccb8f90Sopenharmony_ci
475ccb8f90Sopenharmony_ci    virtual PowerErrors CreateRunningLock(const sptr<IRemoteObject>& remoteObj,
485ccb8f90Sopenharmony_ci        const RunningLockInfo& runningLockInfo) override;
495ccb8f90Sopenharmony_ci    virtual bool ReleaseRunningLock(const sptr<IRemoteObject>& remoteObj, const std::string& name = "") override;
505ccb8f90Sopenharmony_ci    virtual bool IsRunningLockTypeSupported(RunningLockType type) override;
515ccb8f90Sopenharmony_ci    virtual bool UpdateWorkSource(const sptr<IRemoteObject>& remoteObj,
525ccb8f90Sopenharmony_ci        const std::map<int32_t, std::string>& workSources) override;
535ccb8f90Sopenharmony_ci    virtual PowerErrors Lock(const sptr<IRemoteObject>& remoteObj, int32_t timeOutMs = -1) override;
545ccb8f90Sopenharmony_ci    virtual PowerErrors UnLock(const sptr<IRemoteObject>& remoteObj, const std::string& name = "") override;
555ccb8f90Sopenharmony_ci    virtual bool QueryRunningLockLists(std::map<std::string, RunningLockInfo>& runningLockLists) override;
565ccb8f90Sopenharmony_ci    virtual bool ProxyRunningLock(bool isProxied, pid_t pid, pid_t uid) override;
575ccb8f90Sopenharmony_ci    virtual bool ProxyRunningLocks(bool isProxied,
585ccb8f90Sopenharmony_ci        const std::vector<std::pair<pid_t, pid_t>>& processInfos) override;
595ccb8f90Sopenharmony_ci    virtual bool ResetRunningLocks() override;
605ccb8f90Sopenharmony_ci    virtual bool IsUsed(const sptr<IRemoteObject>& remoteObj) override;
615ccb8f90Sopenharmony_ci    // Use for PowerStateMachine
625ccb8f90Sopenharmony_ci    virtual PowerErrors SuspendDevice(int64_t callTimeMs, SuspendDeviceType reason, bool suspendImmed) override;
635ccb8f90Sopenharmony_ci    virtual PowerErrors WakeupDevice(int64_t callTimeMs, WakeupDeviceType reason, const std::string& details) override;
645ccb8f90Sopenharmony_ci    virtual void WakeupDeviceAsync(int64_t callTimeMs, WakeupDeviceType reason, const std::string& details) override;
655ccb8f90Sopenharmony_ci    virtual bool RefreshActivity(int64_t callTimeMs, UserActivityType type, bool needChangeBacklight) override;
665ccb8f90Sopenharmony_ci    virtual PowerErrors OverrideScreenOffTime(int64_t timeout) override;
675ccb8f90Sopenharmony_ci    virtual PowerErrors RestoreScreenOffTime() override;
685ccb8f90Sopenharmony_ci    virtual PowerState GetState() override;
695ccb8f90Sopenharmony_ci    virtual bool IsScreenOn(bool needPrintLog = true) override;
705ccb8f90Sopenharmony_ci    virtual bool IsFoldScreenOn() override;
715ccb8f90Sopenharmony_ci    virtual bool IsCollaborationScreenOn() override;
725ccb8f90Sopenharmony_ci    virtual PowerErrors ForceSuspendDevice(int64_t callTimeMs) override;
735ccb8f90Sopenharmony_ci    virtual PowerErrors RebootDevice(const std::string& reason) override;
745ccb8f90Sopenharmony_ci    virtual PowerErrors RebootDeviceForDeprecated(const std::string& reason) override;
755ccb8f90Sopenharmony_ci    virtual PowerErrors ShutDownDevice(const std::string& reason) override;
765ccb8f90Sopenharmony_ci    virtual PowerErrors SetSuspendTag(const std::string& tag) override;
775ccb8f90Sopenharmony_ci    virtual bool RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback, bool isSync = true) override;
785ccb8f90Sopenharmony_ci    virtual bool UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) override;
795ccb8f90Sopenharmony_ci    virtual bool RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
805ccb8f90Sopenharmony_ci    virtual bool UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) override;
815ccb8f90Sopenharmony_ci    virtual bool RegisterScreenStateCallback(int32_t remainTime, const sptr<IScreenOffPreCallback>& callback) override;
825ccb8f90Sopenharmony_ci    virtual bool UnRegisterScreenStateCallback(const sptr<IScreenOffPreCallback>& callback) override;
835ccb8f90Sopenharmony_ci    virtual bool RegisterRunningLockCallback(const sptr<IPowerRunninglockCallback>& callback) override;
845ccb8f90Sopenharmony_ci    virtual bool UnRegisterRunningLockCallback(const sptr<IPowerRunninglockCallback>& callback) override;
855ccb8f90Sopenharmony_ci    virtual bool SetDisplaySuspend(bool enable) override;
865ccb8f90Sopenharmony_ci    virtual PowerErrors Hibernate(bool clearMemory) override;
875ccb8f90Sopenharmony_ci    virtual PowerErrors SetDeviceMode(const PowerMode& mode) override;
885ccb8f90Sopenharmony_ci    virtual PowerMode GetDeviceMode() override;
895ccb8f90Sopenharmony_ci    virtual std::string ShellDump(const std::vector<std::string>& args, uint32_t argc) override;
905ccb8f90Sopenharmony_ci    virtual PowerErrors IsStandby(bool& isStandby) override;
915ccb8f90Sopenharmony_ci
925ccb8f90Sopenharmony_ci    virtual PowerErrors SetForceTimingOut(bool enabled, const sptr<IRemoteObject>& token) override;
935ccb8f90Sopenharmony_ci    virtual PowerErrors LockScreenAfterTimingOut(
945ccb8f90Sopenharmony_ci        bool enabledLockScreen, bool checkLock, bool sendScreenOffEvent, const sptr<IRemoteObject>& token) override;
955ccb8f90Sopenharmony_ci
965ccb8f90Sopenharmony_ci    void RegisterShutdownCallback(const sptr<ITakeOverShutdownCallback>& callback, ShutdownPriority priority) override;
975ccb8f90Sopenharmony_ci    void UnRegisterShutdownCallback(const sptr<ITakeOverShutdownCallback>& callback) override;
985ccb8f90Sopenharmony_ci    void RegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback, ShutdownPriority priority) override;
995ccb8f90Sopenharmony_ci    void UnRegisterShutdownCallback(const sptr<IAsyncShutdownCallback>& callback) override;
1005ccb8f90Sopenharmony_ci    void RegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback, ShutdownPriority priority) override;
1015ccb8f90Sopenharmony_ci    void UnRegisterShutdownCallback(const sptr<ISyncShutdownCallback>& callback) override;
1025ccb8f90Sopenharmony_ci
1035ccb8f90Sopenharmony_ci    virtual bool RegisterSyncHibernateCallback(const sptr<ISyncHibernateCallback>& callback) override;
1045ccb8f90Sopenharmony_ci    virtual bool UnRegisterSyncHibernateCallback(const sptr<ISyncHibernateCallback>& callback) override;
1055ccb8f90Sopenharmony_ci    virtual bool RegisterSyncSleepCallback(const sptr<ISyncSleepCallback>& callback, SleepPriority priority) override;
1065ccb8f90Sopenharmony_ci    virtual bool UnRegisterSyncSleepCallback(const sptr<ISyncSleepCallback>& callback) override;
1075ccb8f90Sopenharmony_ci
1085ccb8f90Sopenharmony_ciprivate:
1095ccb8f90Sopenharmony_ci    static inline BrokerDelegator<PowerMgrProxy> delegator_;
1105ccb8f90Sopenharmony_ci};
1115ccb8f90Sopenharmony_ci} // namespace PowerMgr
1125ccb8f90Sopenharmony_ci} // namespace OHOS
1135ccb8f90Sopenharmony_ci#endif // POWERMGR_SERVICES_IPOWER_MANAGER_PROXY_H
114