1 2 /* 3 * Copyright (c) 2024 Huawei Device Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MODULE_UPDATE_TASK_H 18 #define MODULE_UPDATE_TASK_H 19 20 #include "module_ipc_helper.h" 21 #include "singleton.h" 22 #include "thread_pool.h" 23 24 25 namespace OHOS { 26 namespace SysInstaller { 27 class ModuleUpdateTask { 28 public: 29 ModuleUpdateTask(const std::string &hmpName); 30 void SetHmpName(const std::string &hmpName); 31 std::string &GetHmpName(); 32 private: 33 std::string hmpName_; 34 }; 35 36 class ModuleUpdateTaskManager : public OHOS::Singleton<ModuleUpdateTaskManager> { 37 friend class OHOS::Singleton<ModuleUpdateTaskManager>; 38 public: ~ModuleUpdateTaskManager()39 ~ModuleUpdateTaskManager() override {} 40 void SetTaskResult(bool result); 41 bool GetTaskResult(); 42 bool AddTask(const std::string &hmpName); 43 void ClearTask(); 44 void Stop(); 45 void Start(); 46 size_t GetCurTaskNum(); 47 48 private: 49 static constexpr size_t MAX_TASK_NUM = 100; // 100 is max task number ModuleUpdateTaskManager()50 ModuleUpdateTaskManager() {} 51 ModuleUpdateTaskManager(const ModuleUpdateTaskManager&) = delete; 52 OHOS::ThreadPool pool_; 53 bool taskResult_ = true; 54 size_t taskNum_; 55 }; 56 } // SysInstaller 57 } // namespace OHOS 58 #endif // SYS_INSTALLER_MODULE_UPDATE_H