• 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_COMPONENT_OPERATOR_H
17 #define FIRMWARE_COMPONENT_OPERATOR_H
18 
19 #include "singleton.h"
20 
21 #include "firmware_component.h"
22 #include "firmware_component_table.h"
23 #include "firmware_database.h"
24 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
25 #include "table_base_operator.h"
26 #endif
27 #include "update_helper.h"
28 
29 namespace OHOS {
30 namespace UpdateEngine {
31 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
32 class FirmwareComponentOperator final : public TableBaseOperator<FirmwareComponentTable, FirmwareComponent> {
33 #else
34 class FirmwareComponentOperator final {
35 #endif
36 public:
37 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
FirmwareComponentOperator()38     FirmwareComponentOperator() : TableBaseOperator(DelayedSingleton<FirmwareDatabase>::GetInstance()) {}
39 #else
40     FirmwareComponentOperator() = default;
41     bool QueryAll(const std::vector<FirmwareComponent> &results);
42     bool Insert(const std::vector<FirmwareComponent> &values);
43     bool DeleteAll();
44 #endif
45     ~FirmwareComponentOperator() = default;
46     bool UpdateProgressByUrl(const std::string &url, UpgradeStatus status, int32_t progress);
47     bool UpdateUrlByVersionId(const std::string &versionId, const std::string &url);
48     bool QueryByVersionId(const std::string &versionId, FirmwareComponent &component);
49     bool QueryByUrl(const std::string &url, FirmwareComponent &component);
50 };
51 } // namespace UpdateEngine
52 } // namespace OHOS
53 #endif // FIRMWARE_COMPONENT_OPERATOR_H