• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 PACKAGESINFO_H
16 #define PACKAGESINFO_H
17 
18 #include <cstdlib>
19 #include <cstdio>
20 #include <cstring>
21 #include <functional>
22 #include <iostream>
23 #include <memory>
24 #include <vector>
25 #include "pkg_manager.h"
26 
27 /**
28  * Constructor used to create a singleton PackagesInfo instance.
29  */
30 namespace Updater {
31 class PackagesInfo;
32 using PackagesInfoPtr = PackagesInfo *;
33 class PackagesInfo {
34 public:
~PackagesInfo()35     ~PackagesInfo() {}
36 
37     static PackagesInfoPtr GetPackagesInfoInstance();
38 
39     static void ReleasePackagesInfoInstance(PackagesInfoPtr pkginfomanager);
40 
41     /**
42      * Obtains the version information of the update package.
43      *
44      * @param packagePath       path of the update package
45      * @return                  version information of the update package
46      */
47     std::vector<std::string> GetOTAVersion(Hpackage::PkgManager::PkgManagerPtr manager,
48         const std::string &versionList, const std::string &versionPath);
49 
50    /**
51      * Get the Boardid information.
52      *
53      * @param packagePath       path of the update package
54      * @return                  Boardid information of the update package
55      */
56     std::vector<std::string> GetBoardID(Hpackage::PkgManager::PkgManagerPtr manager, const std::string &boardList,
57         const std::string &boardListPath);
58 
59     /**
60      * Gets information about files in the package. For an update package,
61      * you can convert the information into updater information for viewing.
62      *
63      * @param fileId            file ID
64      * @return                  information about files in the package
65      */
66     bool IsAllowRollback();
67 
68 private:
PackagesInfo()69     PackagesInfo() {}
70 };
71 }
72 #endif // PACKAGESINFO_H