• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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_SERVICE_TEST_PROXY_H
17 #define POWERMGR_SERVICE_TEST_PROXY_H
18 
19 #include <cstdint>
20 #include <sys/types.h>
21 #include <functional>
22 #include <iosfwd>
23 #include <vector>
24 
25 #include "iremote_object.h"
26 #include "ipower_mode_callback.h"
27 #include "ipower_state_callback.h"
28 #include "ipower_mgr.h"
29 #include "running_lock_info.h"
30 #include "power_errors.h"
31 #include "power_mgr_service.h"
32 #include "power_state_machine_info.h"
33 
34 namespace OHOS {
35 namespace PowerMgr {
36 class PowerMgrServiceTestProxy {
37 public:
38     PowerMgrServiceTestProxy(const sptr<PowerMgrService>& service);
39     ~PowerMgrServiceTestProxy() = default;
40 
41     PowerErrors CreateRunningLock(const sptr<IRemoteObject>& remoteObj, const RunningLockInfo& runningLockInfo);
42     bool ReleaseRunningLock(const sptr<IRemoteObject>& remoteObj);
43     bool IsRunningLockTypeSupported(RunningLockType type);
44     bool Lock(const sptr<IRemoteObject>& remoteObj, int32_t timeOutMs);
45     bool UnLock(const sptr<IRemoteObject>& remoteObj);
46     bool ProxyRunningLock(bool isProxied, pid_t pid, pid_t uid);
47     bool ProxyRunningLocks(bool isProxied,
48         const std::vector<std::pair<pid_t, pid_t>>& processInfos);
49     bool ResetRunningLocks();
50     bool IsUsed(const sptr<IRemoteObject>& remoteObj);
51     PowerErrors SuspendDevice(int64_t callTimeMs,
52         SuspendDeviceType reason = SuspendDeviceType::SUSPEND_DEVICE_REASON_APPLICATION,
53         bool suspendImmed = false);
54     PowerErrors WakeupDevice(int64_t callTimeMs, WakeupDeviceType reason = WakeupDeviceType::WAKEUP_DEVICE_APPLICATION,
55         const std::string& detail = std::string("app call"));
56     bool RefreshActivity(int64_t callTimeMs, UserActivityType type = UserActivityType::USER_ACTIVITY_TYPE_OTHER,
57         bool needChangeBacklight = true);
58     bool OverrideScreenOffTime(int64_t timeout);
59     bool RestoreScreenOffTime();
60     PowerState GetState();
61     bool IsScreenOn();
62     bool ForceSuspendDevice(int64_t callTimeMs);
63     PowerErrors RebootDevice(const std::string& reason);
64     PowerErrors RebootDeviceForDeprecated(const std::string& reason);
65     PowerErrors ShutDownDevice(const std::string& reason);
66     bool RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback);
67     bool UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback);
68     bool RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback);
69     bool UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback);
70     bool SetDisplaySuspend(bool enable);
71     PowerErrors SetDeviceMode(const PowerMode& mode);
72     PowerMode GetDeviceMode();
73     std::string ShellDump(const std::vector<std::string>& args, uint32_t argc);
74     PowerErrors IsStandby(bool& isStandby);
75 private:
76     sptr<PowerMgrStub> stub_ {nullptr};
77 };
78 } // namespace PowerMgr
79 } // namespace OHOS
80 #endif // POWERMGR_SERVICE_TEST_PROXY_H
81