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 #include "fs_manager/mount.h"
16 #include "flashd/flashd.h"
17 #include "log/log.h"
18 #include "misc_info/misc_info.h"
19 #include "updater/updater_const.h"
20 #include "updater_main.h"
21 #include "utils.h"
22
23 using namespace Updater;
24
main(int argc,char ** argv)25 int main(int argc, char **argv)
26 {
27 int mode = BOOT_UPDATER;
28 int ret = GetBootMode(mode);
29 if (ret != 0) {
30 printf("Failed to get boot mode, start updater mode \n");
31 mode = BOOT_UPDATER;
32 }
33
34 std::string modeStr = (mode == BOOT_FLASHD) ? "FLASHD" : "UPDATER";
35 InitUpdaterLogger(modeStr, TMP_LOG, TMP_STAGE_LOG, TMP_ERROR_CODE_PATH);
36 SetLogLevel(INFO);
37 LoadFstab();
38 STAGE(UPDATE_STAGE_OUT) << "Start " << ((mode == BOOT_FLASHD) ? "flashd" : "updater");
39 auto modePara = (mode == BOOT_FLASHD) ? "updater.flashd.configfs" : "updater.hdc.configfs";
40 Flashd::SetParameter(modePara, "1");
41
42 if (mode == BOOT_FLASHD) {
43 Utils::UsSleep(3000 * 1000); // 3000 * 1000 : wait 3s
44 return Flashd::flashd_main(argc, argv);
45 }
46 return Updater::UpdaterMain(argc, argv);
47 }
48