1 /* 2 * Copyright (c) 2022 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 #ifndef FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_SCHEDULER_SERVICE_STUB_H 16 #define FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_SCHEDULER_SERVICE_STUB_H 17 18 #include <iremote_stub.h> 19 #include <nocopyable.h> 20 #include <list> 21 #include <memory> 22 23 #include "iwork_sched_service.h" 24 25 namespace OHOS { 26 namespace WorkScheduler { 27 class WorkSchedServiceStub : public IRemoteStub<IWorkSchedService> { 28 public: 29 WorkSchedServiceStub() = default; 30 virtual ~WorkSchedServiceStub() = default; 31 DISALLOW_COPY_AND_MOVE(WorkSchedServiceStub); 32 33 /** 34 * @brief The OnRemoteRequest callback. 35 * 36 * @param code The code. 37 * @param data The data. 38 * @param reply The reply. 39 * @param option The option. 40 * @return ERR_OK on success, others on failure. 41 */ 42 int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 43 44 /** 45 * @brief Start work stub. 46 * 47 * @param data The data. 48 * @return error code, ERR_OK if success. 49 */ 50 int32_t StartWorkStub(MessageParcel& data); 51 /** 52 * @brief Stop work stub. 53 * 54 * @param data The data. 55 * @return error code, ERR_OK if success. 56 */ 57 int32_t StopWorkStub(MessageParcel& data); 58 /** 59 * @brief Stop and cancel work stub. 60 * 61 * @param data The data. 62 * @return error code, ERR_OK if success. 63 */ 64 int32_t StopAndCancelWorkStub(MessageParcel& data); 65 /** 66 * @brief Stop and clear works stub. 67 * 68 * @param data The data. 69 * @return error code, ERR_OK if success. 70 */ 71 int32_t StopAndClearWorksStub(MessageParcel& data); 72 /** 73 * @brief The last work time out stub. 74 * 75 * @param data The data. 76 * @param result True if the work executed time out, else false. 77 * @return error code, ERR_OK if success. 78 */ 79 int32_t IsLastWorkTimeoutStub(MessageParcel& data, bool &result); 80 /** 81 * @brief Obtain all works stub. 82 * 83 * @param data The data. 84 * @param workInfos The infos of work. 85 * @return error code, ERR_OK if success. 86 */ 87 int32_t ObtainAllWorksStub(MessageParcel& data, std::list<std::shared_ptr<WorkInfo>>& workInfos); 88 /** 89 * @brief Get work status stub. 90 * 91 * @param data The data. 92 * @param workInfo The info of work. 93 * @return error code, ERR_OK if success. 94 */ 95 int32_t GetWorkStatusStub(MessageParcel& data, std::shared_ptr<WorkInfo>& workInfo); 96 }; 97 } // namespace WorkScheduler 98 } // namespace OHOS 99 #endif // FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_SCHEDULER_SERVICE_STUB_H