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 UPDATER_PREPROCESS_H 16 #define UPDATER_PREPROCESS_H 17 18 #include "macros_updater.h" 19 #include "pkg_manager.h" 20 #include "package/packages_info.h" 21 #include "updater/updater.h" 22 23 namespace Updater { 24 typedef int32_t (*PreProcessFunc)(UpdaterParams &upParams, Hpackage::PkgManager::PkgManagerPtr pkgManager); 25 typedef int32_t (*AuthFunc)(std::string &path); 26 typedef int32_t (*ClearFunc)(void); 27 28 int CheckBoardId(Hpackage::PkgManager::PkgManagerPtr pkgManager, PackagesInfoPtr pkginfomanager); 29 int CheckVersion(Hpackage::PkgManager::PkgManagerPtr pkgManager, PackagesInfoPtr pkginfomanager); 30 int32_t UpdatePreProcess(UpdaterParams &upParams, Hpackage::PkgManager::PkgManagerPtr pkgManager); 31 int32_t UpdateAuth(std::string &path); 32 int32_t UpdateClear(void); 33 34 class PreProcess { 35 DISALLOW_COPY_MOVE(PreProcess); 36 public: 37 void RegisterHelper(PreProcessFunc ptr); 38 void AuthHelper(AuthFunc ptr); 39 void ClearHelper(ClearFunc ptr); 40 static PreProcess &GetInstance(); 41 int32_t DoUpdatePreProcess(UpdaterParams &upParams, Hpackage::PkgManager::PkgManagerPtr pkgManager); 42 int32_t DoUpdateAuth(std::string path); 43 int32_t DoUpdateClear(void); 44 private: 45 PreProcess() = default; 46 ~PreProcess() = default; 47 PreProcessFunc helper_ {}; 48 AuthFunc authHelper_ {}; 49 ClearFunc clearHelper_ {}; 50 }; 51 } // namespace Updater 52 53 #endif 54