• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FIRMWARE_TASK_OPERATOR_H
17 #define FIRMWARE_TASK_OPERATOR_H
18 
19 #include "singleton.h"
20 
21 #include "firmware_common.h"
22 #include "firmware_database.h"
23 #include "firmware_task_table.h"
24 #include "firmware_task.h"
25 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
26 #include "table_base_operator.h"
27 #endif
28 
29 namespace OHOS {
30 namespace UpdateEngine {
31 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
32 class FirmwareTaskOperator final : public TableBaseOperator<FirmwareTaskTable, FirmwareTask> {
33 #else
34 class FirmwareTaskOperator final {
35 #endif
36 public:
37 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
FirmwareTaskOperator()38     FirmwareTaskOperator() : TableBaseOperator(DelayedSingleton<FirmwareDatabase>::GetInstance()) {}
39 #else
40     FirmwareTaskOperator() = default;
41     bool Insert(const FirmwareTask &value);
42     bool DeleteAll();
43 #endif
44     ~FirmwareTaskOperator() = default;
45     void QueryTask(FirmwareTask &task);
46     bool UpdateProgressByTaskId(const std::string &taskId, UpgradeStatus status, int32_t progress);
47     bool UpdateErrMsgByTaskId(const std::string &taskId, int errorCode, const std::string &errorMsg);
48     bool UpdateDownloadTaskIdByTaskId(const std::string &taskId, const std::string &downloadTaskId);
49     bool UpdateCombinationTypeByTaskId(const std::string &taskId,
50         const CombinationType &combinationType);
51 
52     bool UpdateDownloadModeByTaskId(const std::string &taskId, DownloadMode downloadMode);
53     bool UpdateDownloadAllowNetworkByTaskId(const std::string &taskId, NetType downloadAllowNetwork);
54     bool UpdateDownloadOrderByTaskId(const std::string &taskId, Order downloadOrder);
55     bool UpdateDownloadOptionByTaskId(const std::string &taskId,
56         DownloadMode downloadMode, NetType downloadAllowNetwork, Order downloadOrder);
57 
58     bool UpdateUpgradeModeByTaskId(const std::string &taskId, UpgradeMode upgradeMode);
59     bool UpdateUpgradeOrderByTaskId(const std::string &taskId, Order upgradeOrder);
60 
61 private:
62 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
63     bool UpdateByTaskId(const std::string &taskId, const NativeRdb::ValuesBucket &values);
64 #endif
65 };
66 } // namespace UpdateEngine
67 } // namespace OHOS
68 #endif // FIRMWARE_TASK_OPERATOR_H