1 /* 2 * Copyright (c) 2021 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_IPOWER_MANAGER_H 17 #define POWERMGR_IPOWER_MANAGER_H 18 19 #include <string> 20 #include <vector> 21 22 #include <iremote_broker.h> 23 #include <iremote_object.h> 24 25 #include "ipower_state_callback.h" 26 #include "ishutdown_callback.h" 27 #include "ipower_mode_callback.h" 28 #include "power_state_machine_info.h" 29 #include "running_lock_info.h" 30 31 namespace OHOS { 32 namespace PowerMgr { 33 class IPowerMgr : public IRemoteBroker { 34 public: 35 enum { 36 CREATE_RUNNINGLOCK = 0, 37 RELEASE_RUNNINGLOCK, 38 IS_RUNNINGLOCK_TYPE_SUPPORTED, 39 RUNNINGLOCK_LOCK, 40 RUNNINGLOCK_UNLOCK, 41 RUNNINGLOCK_SET_WORK_TRIGGER_LIST, 42 RUNNINGLOCK_ISUSED, 43 PROXY_RUNNINGLOCK, 44 WAKEUP_DEVICE, 45 SUSPEND_DEVICE, 46 REFRESH_ACTIVITY, 47 GET_STATE, 48 IS_SCREEN_ON, 49 FORCE_DEVICE_SUSPEND, 50 REBOOT_DEVICE, 51 SHUTDOWN_DEVICE, 52 REG_POWER_STATE_CALLBACK, 53 UNREG_POWER_STATE_CALLBACK, 54 REG_SHUTDOWN_CALLBACK, 55 UNREG_SHUTDOWN_CALLBACK, 56 REG_POWER_MODE_CALLBACK, 57 UNREG_POWER_MODE_CALLBACK, 58 SET_DISPLAY_SUSPEND, 59 SETMODE_DEVICE, 60 GETMODE_DEVICE, 61 SHELL_DUMP 62 }; 63 64 virtual void CreateRunningLock(const sptr<IRemoteObject>& token, const RunningLockInfo& runningLockInfo) = 0; 65 virtual void ReleaseRunningLock(const sptr<IRemoteObject>& token) = 0; 66 virtual bool IsRunningLockTypeSupported(uint32_t type) = 0; 67 virtual void Lock(const sptr<IRemoteObject>& token, const RunningLockInfo& runningLockInfo, 68 uint32_t timeOutMs) = 0; 69 virtual void UnLock(const sptr<IRemoteObject>& token) = 0; 70 virtual bool IsUsed(const sptr<IRemoteObject>& token) = 0; 71 virtual void SetWorkTriggerList(const sptr<IRemoteObject>& token, const WorkTriggerList& workTriggerList) = 0; 72 virtual void ProxyRunningLock(bool proxyLock, pid_t uid, pid_t pid) = 0; 73 74 // Used for power state machine. 75 virtual void RebootDevice(const std::string& reason) = 0; 76 virtual void ShutDownDevice(const std::string& reason) = 0; 77 virtual void SuspendDevice(int64_t callTimeMs, SuspendDeviceType reason, bool suspendImmed) = 0; 78 virtual void WakeupDevice(int64_t callTimeMs, WakeupDeviceType reason, const std::string& details) = 0; 79 virtual void RefreshActivity(int64_t callTimeMs, UserActivityType type, bool needChangeBacklight) = 0; 80 virtual PowerState GetState() = 0; 81 virtual bool IsScreenOn() = 0; 82 virtual bool ForceSuspendDevice(int64_t callTimeMs) = 0; 83 virtual void RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) = 0; 84 virtual void UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback) = 0; 85 86 // Used for callback registration upon shutdown. 87 virtual void RegisterShutdownCallback(IShutdownCallback::ShutdownPriority priority, 88 const sptr<IShutdownCallback>& callback) = 0; 89 virtual void UnRegisterShutdownCallback(const sptr<IShutdownCallback>& callback) = 0; 90 91 // Used for callback registration upon power mode. 92 virtual void RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) = 0; 93 virtual void UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback) = 0; 94 95 virtual void SetDisplaySuspend(bool enable) = 0; 96 virtual void SetDeviceMode(const uint32_t& mode) = 0; 97 virtual uint32_t GetDeviceMode() = 0; 98 virtual std::string ShellDump(const std::vector<std::string>& args, uint32_t argc) = 0; 99 100 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.powermgr.IPowerMgr"); 101 }; 102 } // namespace PowerMgr 103 } // namespace OHOS 104 #endif // POWERMGR_IPOWER_MANAGER_H 105