• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.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 
27 int CheckBoardId(Hpackage::PkgManager::PkgManagerPtr pkgManager, PackagesInfoPtr pkginfomanager);
28 int CheckVersion(Hpackage::PkgManager::PkgManagerPtr pkgManager, PackagesInfoPtr pkginfomanager);
29 int32_t UpdatePreProcess(UpdaterParams &upParams, Hpackage::PkgManager::PkgManagerPtr pkgManager);
30 int32_t UpdateAuth(std::string &path);
31 
32 class PreProcess {
33     DISALLOW_COPY_MOVE(PreProcess);
34 public:
35     void RegisterHelper(PreProcessFunc ptr);
36     void AuthHelper(AuthFunc ptr);
37     static PreProcess &GetInstance();
38     int32_t DoUpdatePreProcess(UpdaterParams &upParams, Hpackage::PkgManager::PkgManagerPtr pkgManager);
39     int32_t DoUpdateAuth(std::string path);
40 private:
41     PreProcess() = default;
42     ~PreProcess() = default;
43     PreProcessFunc helper_ {};
44     AuthFunc authHelper_ {};
45 };
46 } // namespace Updater
47 
48 #endif
49