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_INTERFACE_INCLUDE_STANDBY_SERVICE_SUBSCRIBER_STUB_H
17 #define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACE_INCLUDE_STANDBY_SERVICE_SUBSCRIBER_STUB_H
18 
19 #include <iremote_stub.h>
20 
21 #include "istandby_service_subscriber.h"
22 #include "standby_service_errors.h"
23 
24 namespace OHOS {
25 namespace DevStandbyMgr {
26 class StandbyServiceSubscriberStub : public IRemoteStub<IStandbyServiceSubscriber> {
27 public:
28     StandbyServiceSubscriberStub(bool serialInvokeFlag = true) : IRemoteStub(serialInvokeFlag) {};
29     ~StandbyServiceSubscriberStub() override;
30     DISALLOW_COPY_AND_MOVE(StandbyServiceSubscriberStub);
31 
32     /**
33      * @brief Request service code and service data.
34      *
35      * @param code Service request code.
36      * @param data MessageParcel object.
37      * @param reply Local service response.
38      * @param option Point out async or sync.
39      * @return ERR_OK if success, else fail.
40      */
41     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
42     void OnDeviceIdleMode(bool napped, bool sleeping) override;
43     void OnAllowListChanged(int32_t uid, const std::string& name, uint32_t allowType, bool added) override;
44     void OnPowerOverused(const std::string& module, uint32_t level) override;
45 
46 private:
47     ErrCode HandleOnDeviceIdleMode(MessageParcel& data);
48     ErrCode HandleOnAllowListChanged(MessageParcel& data);
49     ErrCode HandleOnPowerOverused(MessageParcel& data);
50 
51     ErrCode OnRemoteRequestInner(uint32_t code,
52         MessageParcel& data, MessageParcel& reply, MessageOption& option);
53 };
54 }  // namespace DevStandbyMgr
55 }  // namespace OHOS
56 #endif  // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACE_INCLUDE_STANDBY_SERVICE_SUBSCRIBER_STUB_H