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_IWORK_SCHED_SERVICE_H 16 #define FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_IWORK_SCHED_SERVICE_H 17 18 #include <string> 19 #include <vector> 20 21 #include <iremote_broker.h> 22 #include <iremote_object.h> 23 24 #include "work_info.h" 25 26 namespace OHOS { 27 namespace WorkScheduler { 28 class IWorkSchedService : public IRemoteBroker { 29 public: 30 IWorkSchedService() = default; 31 ~IWorkSchedService() override = default; 32 DISALLOW_COPY_AND_MOVE(IWorkSchedService); 33 34 /** 35 * @brief Start work. 36 * 37 * @param workInfo The info of work. 38 * @return The errcode. ERR_OK on success, others on failure. 39 */ 40 virtual int32_t StartWork(WorkInfo& workInfo) = 0; 41 /** 42 * @brief Stop work. 43 * 44 * @param workInfo The info of work. 45 * @return The errcode. ERR_OK on success, others on failure. 46 */ 47 virtual int32_t StopWork(WorkInfo& workInfo) = 0; 48 /** 49 * @brief Stop and cancel work. 50 * 51 * @param workInfo The info of work. 52 * @return The errcode. ERR_OK on success, others on failure. 53 */ 54 virtual int32_t StopAndCancelWork(WorkInfo& workInfo) = 0; 55 /** 56 * @brief Stop and clear works. 57 * 58 * @return The errcode. ERR_OK on success, others on failure. 59 */ 60 virtual int32_t StopAndClearWorks() = 0; 61 /** 62 * @brief Check whether last work executed time out. 63 * 64 * @param workId The id of work. 65 * @param result True if the work executed time out, else false. 66 * @return The errcode. ERR_OK on success, others on failure. 67 */ 68 virtual int32_t IsLastWorkTimeout(int32_t workId, bool &result) = 0; 69 /** 70 * @brief Obtain all works. 71 * 72 * @param uid The uid. 73 * @param pid The pid. 74 * @param workInfos The infos of work. 75 * @return The errcode. ERR_OK on success, others on failure. 76 */ 77 virtual int32_t ObtainAllWorks(int32_t &uid, int32_t &pid, 78 std::list<std::shared_ptr<WorkInfo>>& workInfos) = 0; 79 /** 80 * @brief Check whether last work executed time out. 81 * 82 * @param uid The uid. 83 * @param workId The id of work. 84 * @param workInfo The info of work. 85 * @return The errcode. ERR_OK on success, others on failure. 86 */ 87 virtual int32_t GetWorkStatus(int32_t &uid, int32_t &workId, std::shared_ptr<WorkInfo>& workInfo) = 0; 88 89 /** 90 * @brief Get the Running Work Scheduler Work object 91 * 92 * @param workInfos The infos of work. 93 * @return ErrCode ERR_OK on success, others on failure 94 */ 95 virtual int32_t GetAllRunningWorks(std::list<std::shared_ptr<WorkInfo>>& workInfos) = 0; 96 97 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.workscheduler.iworkschedservice"); 98 }; 99 } // namespace WorkScheduler 100 } // namespace OHOS 101 #endif // FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_IWORK_SCHED_SERVICE_H