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 SECURITY_GUARD_CONFIG_DATABASE_HELPER_H 17 #define SECURITY_GUARD_CONFIG_DATABASE_HELPER_H 18 19 #include "database.h" 20 #include "config_define.h" 21 22 namespace OHOS::Security::SecurityGuard { 23 class ConfigDatabaseHelper : public Database { 24 public: 25 explicit ConfigDatabaseHelper(std::string dbTable); 26 ~ConfigDatabaseHelper() = default; 27 virtual int Init(); 28 virtual int InsertAppInfo(const AppInfo& info); 29 virtual int QueryAllAppInfo(std::vector<AppInfo> &infos); 30 virtual int QueryAppInfosByName(const std::string &appName, std::vector<AppInfo> &infos); 31 virtual int DeleteAppInfoByNameAndGlobbalFlag(const std::string &appName, int isGlobalApp); 32 virtual int QueryAppInfoByAttribute(const std::string attr, std::vector<AppInfo> &infos); 33 virtual int DeleteAppInfoByIsGlobalApp(int isGlobalApp); 34 virtual int InsertAllAppInfo(const std::vector<AppInfo> &infos); 35 protected: 36 int32_t QueryAppInfoBase(const NativeRdb::RdbPredicates &predicates, std::vector<AppInfo> &infos); 37 int32_t GetResultSetTableInfo(const std::shared_ptr<NativeRdb::ResultSet> &resultSet, AppInfoTableInfo &table); 38 void SetValuesBucket(const AppInfo &event, NativeRdb::ValuesBucket &values); 39 std::string CreateTable(); 40 std::string dbPath_{}; 41 std::string dbTable_{}; 42 }; 43 } // namespace OHOS::Security::SecurityGuard { 44 #endif // SECURITY_GUARD_DATABASE_HELPER_H