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 #ifndef FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_PROVISION_INFO_MANAGER_RDB_H 16 #define FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_PROVISION_INFO_MANAGER_RDB_H 17 18 #include <string> 19 #include <unordered_set> 20 21 #include "appexecfwk_errors.h" 22 #include "app_provision_info.h" 23 #include "rdb_data_manager.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class AppProvisionInfoManagerRdb { 28 public: 29 AppProvisionInfoManagerRdb(); 30 ~AppProvisionInfoManagerRdb(); 31 bool AddAppProvisionInfo(const std::string &bundleName, const AppProvisionInfo &appProvisionInfo); 32 bool DeleteAppProvisionInfo(const std::string &bundleName); 33 bool GetAppProvisionInfo(const std::string &bundleName, AppProvisionInfo &appProvisionInfo); 34 bool GetAllAppProvisionInfoBundleName(std::unordered_set<std::string> &bundleNames); 35 36 bool SetSpecifiedDistributionType(const std::string &bundleName, const std::string &specifiedDistributionType); 37 bool GetSpecifiedDistributionType(const std::string &bundleName, std::string &specifiedDistributionType); 38 bool SetAdditionalInfo(const std::string &bundleName, const std::string &additionalInfo); 39 bool GetAdditionalInfo(const std::string &bundleName, std::string &additionalInfo); 40 41 private: 42 bool ConvertToAppProvision(const std::shared_ptr<NativeRdb::ResultSet> &absSharedResultSet, 43 AppProvisionInfo &appProvisionInfo); 44 std::shared_ptr<RdbDataManager> rdbDataManager_; 45 46 #define CHECK_RDB_RESULT_RETURN_IF_FAIL(errcode, errmsg) \ 47 do { \ 48 if ((errcode) != NativeRdb::E_OK) { \ 49 APP_LOGE(errmsg, errcode); \ 50 return false; \ 51 } \ 52 } while (0) 53 }; 54 } // namespace AppExecFwk 55 } // namespace OHOS 56 #endif // FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_PROVISION_INFO_MANAGER_RDB_H 57