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_STUB_H 17 #define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_STANDBY_SERVICE_STUB_H 18 19 #include <map> 20 21 #include <iremote_stub.h> 22 #include <nocopyable.h> 23 24 #include "istandby_service.h" 25 26 namespace OHOS { 27 namespace DevStandbyMgr { 28 class StandbyServiceStub : public IRemoteStub<IStandbyService> { 29 public: 30 StandbyServiceStub(bool serialInvokeFlag = true) : IRemoteStub(serialInvokeFlag) {}; 31 ~StandbyServiceStub() override = default; 32 DISALLOW_COPY_AND_MOVE(StandbyServiceStub); 33 34 /** 35 * @brief Request service code and service data. 36 * 37 * @param code Service request code. 38 * @param data MessageParcel object. 39 * @param reply Local service response. 40 * @param option Point out async or sync. 41 * @return ERR_OK if success, else fail. 42 */ 43 int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 44 45 private: 46 static const std::map<uint32_t, 47 std::function<ErrCode(StandbyServiceStub*, MessageParcel&, MessageParcel&)>> interfaces_; 48 ErrCode HandleSubscribeStandbyCallback(MessageParcel& data, MessageParcel& reply); 49 ErrCode HandleUnsubscribeStandbyCallback(MessageParcel& data, MessageParcel& reply); 50 ErrCode HandleApplyAllowResource(MessageParcel& data, MessageParcel& reply); 51 ErrCode HandleUnapplyAllowResource(MessageParcel& data, MessageParcel& reply); 52 ErrCode HandleGetAllowList(MessageParcel& data, MessageParcel& reply); 53 ErrCode HandleIsDeviceInStandby(MessageParcel& data, MessageParcel& reply); 54 ErrCode HandleReportWorkSchedulerStatus(MessageParcel& data, MessageParcel& reply); 55 ErrCode HandleGetRestrictList(MessageParcel& data, MessageParcel& reply); 56 ErrCode HandleIsStrategyEnabled(MessageParcel& data, MessageParcel& reply); 57 ErrCode HandleReportDeviceStateChanged(MessageParcel& data, MessageParcel& reply); 58 ErrCode HandleCommonEvent(MessageParcel& data, MessageParcel& reply); 59 ErrCode HandleSetNatInterval(MessageParcel& data, MessageParcel& reply); 60 ErrCode HandleReportPowerOverused(MessageParcel& data, MessageParcel& reply); 61 }; 62 } // namespace DevStandbyMgr 63 } // namespace OHOS 64 #endif // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_FRAMEWORKS_INCLUDE_STANDBY_SERVICE_STUB_H