125c1cde8Sopenharmony_ci/* 225c1cde8Sopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd. 325c1cde8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 425c1cde8Sopenharmony_ci * you may not use this file except in compliance with the License. 525c1cde8Sopenharmony_ci * You may obtain a copy of the License at 625c1cde8Sopenharmony_ci * 725c1cde8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 825c1cde8Sopenharmony_ci * 925c1cde8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1025c1cde8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1125c1cde8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1225c1cde8Sopenharmony_ci * See the License for the specific language governing permissions and 1325c1cde8Sopenharmony_ci * limitations under the License. 1425c1cde8Sopenharmony_ci */ 1525c1cde8Sopenharmony_ci 1625c1cde8Sopenharmony_ci#include "opkey_version_ability.h" 1725c1cde8Sopenharmony_ci 1825c1cde8Sopenharmony_ci#include "core_service_client.h" 1925c1cde8Sopenharmony_ci#include "data_storage_log_wrapper.h" 2025c1cde8Sopenharmony_ci#include "new" 2125c1cde8Sopenharmony_ci#include "opkey_version_result_set_bridge.h" 2225c1cde8Sopenharmony_ci#include "rdb_errno.h" 2325c1cde8Sopenharmony_ci#include "telephony_datashare_stub_impl.h" 2425c1cde8Sopenharmony_ci#include "telephony_errors.h" 2525c1cde8Sopenharmony_ci#include "uri.h" 2625c1cde8Sopenharmony_ci#include "utility" 2725c1cde8Sopenharmony_ci 2825c1cde8Sopenharmony_cinamespace OHOS { 2925c1cde8Sopenharmony_cinamespace Telephony { 3025c1cde8Sopenharmony_ciOpkeyVersionAbility::OpkeyVersionAbility() : DataShareExtAbility() {} 3125c1cde8Sopenharmony_ci 3225c1cde8Sopenharmony_ciOpkeyVersionAbility::~OpkeyVersionAbility() {} 3325c1cde8Sopenharmony_ci 3425c1cde8Sopenharmony_ciOpkeyVersionAbility* OpkeyVersionAbility::Create() 3525c1cde8Sopenharmony_ci{ 3625c1cde8Sopenharmony_ci auto self = new OpkeyVersionAbility(); 3725c1cde8Sopenharmony_ci return self; 3825c1cde8Sopenharmony_ci} 3925c1cde8Sopenharmony_ci 4025c1cde8Sopenharmony_cistd::shared_ptr<DataShare::DataShareResultSet> OpkeyVersionAbility::Query(const Uri &uri, 4125c1cde8Sopenharmony_ci const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns, 4225c1cde8Sopenharmony_ci DataShare::DatashareBusinessError &businessError) 4325c1cde8Sopenharmony_ci{ 4425c1cde8Sopenharmony_ci DATA_STORAGE_LOGD("start"); 4525c1cde8Sopenharmony_ci std::string versionInfo; 4625c1cde8Sopenharmony_ci int32_t ret = DelayedRefSingleton<CoreServiceClient>::GetInstance().GetOpkeyVersion(versionInfo); 4725c1cde8Sopenharmony_ci if (ret != TELEPHONY_ERR_SUCCESS) { 4825c1cde8Sopenharmony_ci DATA_STORAGE_LOGE("get versionInfo failed!"); 4925c1cde8Sopenharmony_ci return nullptr; 5025c1cde8Sopenharmony_ci } 5125c1cde8Sopenharmony_ci std::shared_ptr<DataShare::ResultSetBridge> resultSet = 5225c1cde8Sopenharmony_ci std::make_shared<OpkeyVersionResultSetBridge>(versionInfo); 5325c1cde8Sopenharmony_ci std::shared_ptr<DataShare::DataShareResultSet> sharedPtrResult = 5425c1cde8Sopenharmony_ci std::make_shared<DataShare::DataShareResultSet>(resultSet); 5525c1cde8Sopenharmony_ci return sharedPtrResult; 5625c1cde8Sopenharmony_ci} 5725c1cde8Sopenharmony_ci} // Telephony 5825c1cde8Sopenharmony_ci} // OHOS