• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_STANDBY_SERVICE_PROXY_H
17 #define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_STANDBY_SERVICE_PROXY_H
18 
19 #include <iremote_proxy.h>
20 #include <nocopyable.h>
21 
22 #include "istandby_service.h"
23 
24 namespace OHOS {
25 namespace DevStandbyMgr {
26 class StandbyServiceProxy final : public IRemoteProxy<IStandbyService> {
27 public:
28     explicit StandbyServiceProxy(const sptr<IRemoteObject>& impl);
29     ~StandbyServiceProxy() override;
30     DISALLOW_COPY_AND_MOVE(StandbyServiceProxy);
31 
32     /**
33      * @brief Subscribes standby state change event.
34      *
35      * @param subscriber Subscriber token.
36      * @return ERR_OK if success, else fail.
37      */
38     ErrCode SubscribeStandbyCallback(const sptr<IStandbyServiceSubscriber>& subscriber) override;
39 
40     /**
41      * @brief Unsubscribes standby state change event.
42      *
43      * @param subscriber Subscriber token.
44      * @return ERR_OK if success, else fail.
45      */
46     ErrCode UnsubscribeStandbyCallback(const sptr<IStandbyServiceSubscriber>& subscriber) override;
47 
48     /**
49      * @brief add allow list for some services or apps.
50      *
51      * @param resourceRequest resource to be added.
52      * @return ErrCode ERR_OK if success, others if fail.
53      */
54     ErrCode ApplyAllowResource(const sptr<ResourceRequest>& resourceRequest) override;
55 
56     /**
57      * @brief remove uid with allow type from allow list.
58      *
59      * @param resourceRequest resource to be removed.
60      * @return ErrCode ErrCode ERR_OK if success, others if fail.
61      */
62     ErrCode UnapplyAllowResource(const sptr<ResourceRequest>& resourceRequest) override;
63 
64     /**
65      * @brief Get the Allow List object.
66      *
67      * @param allowType the allow type to be retrieved.
68      * @param allowInfoList result represents allowed types and apps.
69      * @param isApp represents the reason why invoke the api.
70      * @return ErrCode ERR_OK if success, others if fail.
71      */
72     ErrCode GetAllowList(uint32_t allowType, std::vector<AllowInfo>& allowInfoList,
73         uint32_t reasonCode) override;
74 
75     /**
76      * @brief query if the device is in standby mode;
77      *
78      * @param isStandby true if device in standby, else false.
79      * @return ErrCode ERR_OK if success, others if fail.
80      */
81     ErrCode IsDeviceInStandby(bool& isStandby) override;
82 
83     /**
84      * @brief Construct a new Report Work Scheduler Status object.
85      *
86      * @param started true if the work is triggered, else false.
87      * @param uid uid of the applicatoin.
88      * @param bundleName bundleName of the application.
89      */
90     ErrCode ReportWorkSchedulerStatus(bool started, int32_t uid, const std::string& bundleName) override;
91 
92     /**
93      * @brief Get the Restrict List object.
94      *
95      * @param allowType the allow type to be retrieved.
96      * @param allowInfoList result represents allowed types and apps.
97      * @param reasonCode represents the reason why invoke the api.
98      * @return ErrCode ERR_OK if success, others if fail.
99      */
100     ErrCode GetRestrictList(uint32_t restrictType, std::vector<AllowInfo>& restrictInfoList,
101         uint32_t reasonCode) override;
102 
103     /**
104      * @brief Whether the restriction strategy enbaled or not.
105      *
106      * @param strategyName the strategy name.
107      * @param enabled true if the strategy is enabled.
108      */
109     ErrCode IsStrategyEnabled(const std::string& strategyName, bool& enabled) override;
110 
111     /**
112      * @brief Report event when device state change.
113      *
114      * @param type type of device state.
115      * @param enabled true if the device state is on.
116      */
117     ErrCode ReportDeviceStateChanged(DeviceStateType type, bool enabled) override;
118 private:
119     ErrCode InnerTransact(uint32_t code, MessageOption& flags, MessageParcel& data, MessageParcel& reply);
120 
121     static inline BrokerDelegator<StandbyServiceProxy> delegator_;
122 };
123 }  // namespace DevStandbyMgr
124 }  // namespace OHOS
125 #endif  // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_STANDBY_SERVICE_PROXY_H
126