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_TABLE_H 17 #define FIRMWARE_COMPONENT_TABLE_H 18 19 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE 20 #include "values_bucket.h" 21 22 #include "itable.h" 23 #endif 24 #include "firmware_component.h" 25 26 namespace OHOS { 27 namespace UpdateService { 28 const std::string FIRMWARE_TABLE_COMPONENT = "component"; 29 const std::string COLUMN_COMPONENT_VERSION_ID = "versionId"; 30 const std::string COLUMN_COMPONENT_VERSION_PACKAGE_TYPE = "versionPackageType"; 31 const std::string COLUMN_COMPONENT_OTA_MODE = "otaType"; 32 const std::string COLUMN_COMPONENT_PACKAGE_INDEX = "packageIndex"; 33 const std::string COLUMN_COMPONENT_TARGET_BL_DISPLAY_VERSION_NUMBER = "targetBlDisplayVersionNumber"; 34 const std::string COLUMN_COMPONENT_TARGET_BL_VERSION_NUMBER = "targetBlVersionNumber"; 35 const std::string COLUMN_COMPONENT_VERSION_NUMBER = "versionNumber"; 36 const std::string COLUMN_COMPONENT_BL_VERSION_INFO = "blVersionInfo"; 37 const std::string COLUMN_COMPONENT_DESCRIPT_PACKAGE_ID = "descriptPackageId"; 38 const std::string COLUMN_COMPONENT_COMPONENT_ID = "componentId"; 39 const std::string COLUMN_COMPONENT_CHANGELOG_URL = "changelogUrl"; 40 const std::string COLUMN_COMPONENT_BL_VERSION_TYPE = "blVersionType"; 41 const std::string COLUMN_COMPONENT_IS_NEED_RESTART = "isNeedRestart"; 42 const std::string COLUMN_COMPONENT_PATCH_TYPE = "patchType"; 43 const std::string COLUMN_COMPONENT_DOWNLOAD_URL = "url"; 44 const std::string COLUMN_COMPONENT_RESERVE_URL = "reserveUrl"; 45 const std::string COLUMN_COMPONENT_STORAGE_TYPE = "storageType"; 46 const std::string COLUMN_COMPONENT_VERIFY_INFO = "verifyInfo"; 47 const std::string COLUMN_COMPONENT_SIZE = "size"; 48 const std::string COLUMN_COMPONENT_FILENAME = "fileName"; 49 const std::string COLUMN_COMPONENT_SPATH = "spath"; 50 const std::string COLUMN_COMPONENT_STATUS = "status"; 51 const std::string COLUMN_COMPONENT_PROGRESS = "progress"; 52 const std::string COLUMN_COMPONENT_RECORD_POINT = "recordPoint"; 53 // 预留6个字段 54 const std::string COLUMN_COMPONENT_EXTENDS1 = "extends1"; 55 const std::string COLUMN_COMPONENT_EXTENDS2 = "extends2"; 56 const std::string COLUMN_COMPONENT_EXTENDS3 = "extends3"; 57 const std::string COLUMN_COMPONENT_EXTENDS4 = "extends4"; 58 const std::string COLUMN_COMPONENT_EXTENDS5 = "extends5"; 59 const std::string COLUMN_COMPONENT_EXTENDS6 = "extends6"; 60 61 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE 62 class FirmwareComponentTable final: public ITable<FirmwareComponent> { 63 #else 64 class FirmwareComponentTable final { 65 #endif 66 public: 67 FirmwareComponentTable() = default; 68 ~FirmwareComponentTable() = default; 69 #ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE 70 std::string GetTableName() final; 71 std::string GetTableCreateSql() final; 72 void ParseDbValue(ResultSet *resultSet, FirmwareComponent &value) final; 73 void BuildDbValue(const FirmwareComponent &value, NativeRdb::ValuesBucket &dbValue) final; 74 #else 75 std::string GetTableName(); 76 std::string GetTableCreateSql(); 77 #endif 78 }; 79 } // namespace UpdateService 80 } // namespace OHOS 81 #endif // FIRMWARE_COMPONENT_TABLE_H 82