1 /*
2  * Copyright (c) 2023 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 #include "firmware_update_adapter.h"
17 
18 #include <ctime>
19 #include <cstdlib>
20 #include <fstream>
21 #include <iomanip>
22 #include <securec.h>
23 #include <sstream>
24 
25 #include "securec.h"
26 
27 #include "constant.h"
28 #include "config_parse.h"
29 #include "device_adapter.h"
30 #include "firmware_constant.h"
31 #include "firmware_file_utils.h"
32 #include "firmware_log.h"
33 #include "firmware_preferences_utils.h"
34 #include "firmware_task.h"
35 #include "time_utils.h"
36 
37 namespace OHOS {
38 namespace UpdateEngine {
GetBusinessDomain()39 std::string FirmwareUpdateAdapter::GetBusinessDomain()
40 {
41     return DelayedSingleton<ConfigParse>::GetInstance()->GetBusinessDomain();
42 }
43 
GetUpdateAction()44 std::string FirmwareUpdateAdapter::GetUpdateAction()
45 {
46     std::string action =
47         DelayedSingleton<FirmwarePreferencesUtil>::GetInstance()->ObtainString(Firmware::UPDATE_ACTION, "");
48     if (action.compare("recovery") == 0) {
49         return "recovery";
50     }
51     return "upgrade";
52 }
53 } // namespace UpdateEngine
54 } // namespace OHOS
55