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 enum { 35 START_WORK = 0, 36 STOP_WORK, 37 STOP_AND_CANCEL_WORK, 38 STOP_AND_CLEAR_WORKS, 39 IS_LAST_WORK_TIMEOUT, 40 OBTAIN_ALL_WORKS, 41 GET_WORK_STATUS, 42 }; 43 44 /** 45 * @brief Start work. 46 * 47 * @param workInfo The info of work. 48 * @return The errcode. ERR_OK on success, others on failure. 49 */ 50 virtual int32_t StartWork(WorkInfo& workInfo) = 0; 51 /** 52 * @brief Stop work. 53 * 54 * @param workInfo The info of work. 55 * @return The errcode. ERR_OK on success, others on failure. 56 */ 57 virtual int32_t StopWork(WorkInfo& workInfo) = 0; 58 /** 59 * @brief Stop and cancel work. 60 * 61 * @param workInfo The info of work. 62 * @return The errcode. ERR_OK on success, others on failure. 63 */ 64 virtual int32_t StopAndCancelWork(WorkInfo& workInfo) = 0; 65 /** 66 * @brief Stop and clear works. 67 * 68 * @return The errcode. ERR_OK on success, others on failure. 69 */ 70 virtual int32_t StopAndClearWorks() = 0; 71 /** 72 * @brief Check whether last work executed time out. 73 * 74 * @param workId The id of work. 75 * @param result True if the work executed time out, else false. 76 * @return The errcode. ERR_OK on success, others on failure. 77 */ 78 virtual int32_t IsLastWorkTimeout(int32_t workId, bool &result) = 0; 79 /** 80 * @brief Obtain all works. 81 * 82 * @param uid The uid. 83 * @param pid The pid. 84 * @param workInfos The infos of work. 85 * @return The errcode. ERR_OK on success, others on failure. 86 */ 87 virtual int32_t ObtainAllWorks(int32_t &uid, int32_t &pid, 88 std::list<std::shared_ptr<WorkInfo>>& workInfos) = 0; 89 /** 90 * @brief Check whether last work executed time out. 91 * 92 * @param uid The uid. 93 * @param workId The id of work. 94 * @param workInfo The info of work. 95 * @return The errcode. ERR_OK on success, others on failure. 96 */ 97 virtual int32_t GetWorkStatus(int32_t &uid, int32_t &workId, std::shared_ptr<WorkInfo>& workInfo) = 0; 98 99 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.workscheduler.iworkschedservice"); 100 }; 101 } // namespace WorkScheduler 102 } // namespace OHOS 103 #endif // FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_IWORK_SCHED_SERVICE_H