• 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 
16 #ifndef UPDATER_UPDATER_H
17 #define UPDATER_UPDATER_H
18 #include <string>
19 #include "package/packages_info.h"
20 #include "package/pkg_manager.h"
21 
22 namespace updater {
23 enum UpdaterStatus {
24     UPDATE_ERROR = -1,
25     UPDATE_SUCCESS,
26     UPDATE_CORRUPT, /* package or verify failed, something is broken. */
27     UPDATE_SKIP, /* skip update because of condition is not satisfied, e.g, battery is low */
28     UPDATE_RETRY,
29     UPDATE_SPACE_NOTENOUGH,
30     UPDATE_UNKNOWN
31 };
32 
33 using PostMessageFunction = std::function<void(const char *cmd, const char *content)>;
34 
35 UpdaterStatus DoInstallUpdaterPackage(hpackage::PkgManager::PkgManagerPtr pkgManager,
36     const std::string &packagePath, int retryCount);
37 
38 UpdaterStatus StartUpdaterProc(hpackage::PkgManager::PkgManagerPtr pkgManager, const std::string &packagePath,
39     int retryCount, int &maxTemperature);
40 
41 int GetUpdatePackageInfo(hpackage::PkgManager::PkgManagerPtr pkgManager, const std::string& path);
42 
43 int UpdatePreProcess(hpackage::PkgManager::PkgManagerPtr pkgManager, const std::string& path);
44 
45 int ExecUpdate(hpackage::PkgManager::PkgManagerPtr pkgManager, int retry, PostMessageFunction postMessage);
46 
47 bool CopyUpdaterLogs(const std::string &sLog, const std::string &dLog);
48 
49 void CompressLogs(const std::string &name);
50 
51 int IsSpaceCapacitySufficient(const std::string &packagePath);
52 
53 bool IsSDCardExist(const std::string &sdcard_path);
54 
55 void PostUpdater(bool clearMisc);
56 
57 std::vector<std::string> ParseParams(int argc, char **argv);
58 
59 int GetBootMode(int &mode);
60 } // updater
61 #endif /* UPDATER_UPDATER_H */
62