1885b47fbSopenharmony_ci/* 2885b47fbSopenharmony_ci * Copyright (C) 2024-2024 Huawei Device Co., Ltd. 3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License. 5885b47fbSopenharmony_ci * You may obtain a copy of the License at 6885b47fbSopenharmony_ci * 7885b47fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8885b47fbSopenharmony_ci * 9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and 13885b47fbSopenharmony_ci * limitations under the License. 14885b47fbSopenharmony_ci */ 15885b47fbSopenharmony_ci 16885b47fbSopenharmony_ci#include "accessibility_datashare_helper.h" 17885b47fbSopenharmony_ci 18885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 19885b47fbSopenharmony_ci#include "datashare_errno.h" 20885b47fbSopenharmony_ci#include "datashare_predicates.h" 21885b47fbSopenharmony_ci#include "datashare_result_set.h" 22885b47fbSopenharmony_ci#include "datashare_values_bucket.h" 23885b47fbSopenharmony_ci#endif 24885b47fbSopenharmony_ci#include "hilog_wrapper.h" 25885b47fbSopenharmony_ci#include "ipc_skeleton.h" 26885b47fbSopenharmony_ci#include "iservice_registry.h" 27885b47fbSopenharmony_ci#include "system_ability_definition.h" 28885b47fbSopenharmony_ci#include "uri.h" 29885b47fbSopenharmony_ci#include "utils.h" 30885b47fbSopenharmony_ci 31885b47fbSopenharmony_cinamespace OHOS { 32885b47fbSopenharmony_cinamespace Accessibility { 33885b47fbSopenharmony_ciffrt::mutex AccessibilityDatashareHelper::observerMutex_; 34885b47fbSopenharmony_cinamespace { 35885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 36885b47fbSopenharmony_ci constexpr int32_t INDEX = 0; 37885b47fbSopenharmony_ci const std::string SETTING_COLUMN_KEYWORD = "KEYWORD"; 38885b47fbSopenharmony_ci const std::string SETTING_COLUMN_VALUE = "VALUE"; 39885b47fbSopenharmony_ci#endif 40885b47fbSopenharmony_ci constexpr int32_t DECIMAL_NOTATION = 10; 41885b47fbSopenharmony_ci const std::string SETTINGS_DATA_EXT_URI = "datashare_ext"; 42885b47fbSopenharmony_ci const std::string SETTING_GLOBAL_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA"; 43885b47fbSopenharmony_ci const std::string SETTING_SYSTEM_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/USER_SETTINGSDATA_"; 44885b47fbSopenharmony_ci const std::string SETTING_SECURE_URI = 45885b47fbSopenharmony_ci "datashare:///com.ohos.settingsdata/entry/settingsdata/USER_SETTINGSDATA_SECURE_"; 46885b47fbSopenharmony_ci} 47885b47fbSopenharmony_ci 48885b47fbSopenharmony_ciAccessibilityDatashareHelper::AccessibilityDatashareHelper(DATASHARE_TYPE type, int32_t accountId) 49885b47fbSopenharmony_ci :type_(type), accountId_(accountId) 50885b47fbSopenharmony_ci{ 51885b47fbSopenharmony_ci HILOG_DEBUG(); 52885b47fbSopenharmony_ci} 53885b47fbSopenharmony_ci 54885b47fbSopenharmony_ciAccessibilityDatashareHelper::~AccessibilityDatashareHelper() 55885b47fbSopenharmony_ci{ 56885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 57885b47fbSopenharmony_ci if (dataShareHelper_ != nullptr) { 58885b47fbSopenharmony_ci DestoryDatashareHelper(dataShareHelper_); 59885b47fbSopenharmony_ci dataShareHelper_ = nullptr; 60885b47fbSopenharmony_ci } 61885b47fbSopenharmony_ci#endif 62885b47fbSopenharmony_ci} 63885b47fbSopenharmony_ci 64885b47fbSopenharmony_cistd::string AccessibilityDatashareHelper::GetStringValue(const std::string& key, const std::string& defaultValue) 65885b47fbSopenharmony_ci{ 66885b47fbSopenharmony_ci std::string resultStr = defaultValue; 67885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 68885b47fbSopenharmony_ci std::string callingIdentity = IPCSkeleton::ResetCallingIdentity(); 69885b47fbSopenharmony_ci std::shared_ptr<DataShare::DataShareResultSet> resultSet = nullptr; 70885b47fbSopenharmony_ci do { 71885b47fbSopenharmony_ci std::vector<std::string> columns = { SETTING_COLUMN_VALUE }; 72885b47fbSopenharmony_ci DataShare::DataSharePredicates predicates; 73885b47fbSopenharmony_ci Uri uri(AssembleUri(key)); 74885b47fbSopenharmony_ci int32_t count = 0; 75885b47fbSopenharmony_ci predicates.EqualTo(SETTING_COLUMN_KEYWORD, key); 76885b47fbSopenharmony_ci if (dataShareHelper_ == nullptr) { 77885b47fbSopenharmony_ci break; 78885b47fbSopenharmony_ci } 79885b47fbSopenharmony_ci resultSet = dataShareHelper_->Query(uri, predicates, columns); 80885b47fbSopenharmony_ci if (resultSet == nullptr) { 81885b47fbSopenharmony_ci break; 82885b47fbSopenharmony_ci } 83885b47fbSopenharmony_ci resultSet->GetRowCount(count); 84885b47fbSopenharmony_ci if (count == 0) { 85885b47fbSopenharmony_ci RetError ret = PutStringValue(key, defaultValue); 86885b47fbSopenharmony_ci if (ret != RET_OK) { 87885b47fbSopenharmony_ci HILOG_WARN("put default key failed key = %{public}s", key.c_str()); 88885b47fbSopenharmony_ci } 89885b47fbSopenharmony_ci break; 90885b47fbSopenharmony_ci } 91885b47fbSopenharmony_ci resultSet->GoToRow(INDEX); 92885b47fbSopenharmony_ci int32_t rtn = resultSet->GetString(INDEX, resultStr); 93885b47fbSopenharmony_ci if (rtn != DataShare::E_OK) { 94885b47fbSopenharmony_ci break; 95885b47fbSopenharmony_ci } 96885b47fbSopenharmony_ci } while (0); 97885b47fbSopenharmony_ci if (resultSet != nullptr) { 98885b47fbSopenharmony_ci resultSet->Close(); 99885b47fbSopenharmony_ci resultSet = nullptr; 100885b47fbSopenharmony_ci } 101885b47fbSopenharmony_ci IPCSkeleton::SetCallingIdentity(callingIdentity); 102885b47fbSopenharmony_ci#endif 103885b47fbSopenharmony_ci return resultStr; 104885b47fbSopenharmony_ci} 105885b47fbSopenharmony_ci 106885b47fbSopenharmony_ciint64_t AccessibilityDatashareHelper::GetLongValue(const std::string& key, const int64_t& defaultValue) 107885b47fbSopenharmony_ci{ 108885b47fbSopenharmony_ci int64_t result = defaultValue; 109885b47fbSopenharmony_ci std::string valueStr = GetStringValue(key, std::to_string(result)); 110885b47fbSopenharmony_ci if (valueStr != "") { 111885b47fbSopenharmony_ci result = static_cast<int64_t>(std::strtoll(valueStr.c_str(), nullptr, DECIMAL_NOTATION)); 112885b47fbSopenharmony_ci } 113885b47fbSopenharmony_ci return result; 114885b47fbSopenharmony_ci} 115885b47fbSopenharmony_ci 116885b47fbSopenharmony_ciint32_t AccessibilityDatashareHelper::GetIntValue(const std::string& key, const int32_t& defaultValue) 117885b47fbSopenharmony_ci{ 118885b47fbSopenharmony_ci int64_t valueLong = GetLongValue(key, defaultValue); 119885b47fbSopenharmony_ci return static_cast<int32_t>(valueLong); 120885b47fbSopenharmony_ci} 121885b47fbSopenharmony_ci 122885b47fbSopenharmony_cibool AccessibilityDatashareHelper::GetBoolValue(const std::string& key, const bool& defaultValue) 123885b47fbSopenharmony_ci{ 124885b47fbSopenharmony_ci bool result = defaultValue; 125885b47fbSopenharmony_ci std::string valueStr = GetStringValue(key, result ? "1" : "0"); 126885b47fbSopenharmony_ci if (valueStr != "") { 127885b47fbSopenharmony_ci result = (valueStr == "1" || valueStr == "true"); 128885b47fbSopenharmony_ci } 129885b47fbSopenharmony_ci return result; 130885b47fbSopenharmony_ci} 131885b47fbSopenharmony_ci 132885b47fbSopenharmony_cifloat AccessibilityDatashareHelper::GetFloatValue(const std::string& key, const float& defaultValue) 133885b47fbSopenharmony_ci{ 134885b47fbSopenharmony_ci float result = defaultValue; 135885b47fbSopenharmony_ci std::string valueStr = GetStringValue(key, std::to_string(result)); 136885b47fbSopenharmony_ci if (valueStr != "") { 137885b47fbSopenharmony_ci result = std::stof(valueStr); 138885b47fbSopenharmony_ci } 139885b47fbSopenharmony_ci return result; 140885b47fbSopenharmony_ci} 141885b47fbSopenharmony_ci 142885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::PutStringValue(const std::string& key, const std::string& value, bool needNotify) 143885b47fbSopenharmony_ci{ 144885b47fbSopenharmony_ci std::string callingIdentity = IPCSkeleton::ResetCallingIdentity(); 145885b47fbSopenharmony_ci RetError rtn = RET_OK; 146885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 147885b47fbSopenharmony_ci do { 148885b47fbSopenharmony_ci if (dataShareHelper_ == nullptr) { 149885b47fbSopenharmony_ci rtn = RET_ERR_NULLPTR; 150885b47fbSopenharmony_ci break; 151885b47fbSopenharmony_ci } 152885b47fbSopenharmony_ci DataShare::DataShareValueObject keyObj(key); 153885b47fbSopenharmony_ci DataShare::DataShareValueObject valueObj(value); 154885b47fbSopenharmony_ci DataShare::DataShareValuesBucket bucket; 155885b47fbSopenharmony_ci bucket.Put(SETTING_COLUMN_KEYWORD, keyObj); 156885b47fbSopenharmony_ci bucket.Put(SETTING_COLUMN_VALUE, valueObj); 157885b47fbSopenharmony_ci DataShare::DataSharePredicates predicates; 158885b47fbSopenharmony_ci predicates.EqualTo(SETTING_COLUMN_KEYWORD, key); 159885b47fbSopenharmony_ci Uri uri(AssembleUri(key)); 160885b47fbSopenharmony_ci if (dataShareHelper_->Update(uri, predicates, bucket) <= 0) { 161885b47fbSopenharmony_ci HILOG_DEBUG("no data exist, insert one row"); 162885b47fbSopenharmony_ci auto ret = dataShareHelper_->Insert(uri, bucket); 163885b47fbSopenharmony_ci HILOG_INFO("helper insert %{public}s ret(%{public}d).", key.c_str(), static_cast<int>(ret)); 164885b47fbSopenharmony_ci } 165885b47fbSopenharmony_ci if (needNotify) { 166885b47fbSopenharmony_ci dataShareHelper_->NotifyChange(AssembleUri(key)); 167885b47fbSopenharmony_ci } 168885b47fbSopenharmony_ci } while (0); 169885b47fbSopenharmony_ci IPCSkeleton::SetCallingIdentity(callingIdentity); 170885b47fbSopenharmony_ci#endif 171885b47fbSopenharmony_ci return rtn; 172885b47fbSopenharmony_ci} 173885b47fbSopenharmony_ci 174885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::PutIntValue(const std::string& key, int32_t value, bool needNotify) 175885b47fbSopenharmony_ci{ 176885b47fbSopenharmony_ci return PutStringValue(key, std::to_string(value), needNotify); 177885b47fbSopenharmony_ci} 178885b47fbSopenharmony_ci 179885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::PutLongValue(const std::string& key, int64_t value, bool needNotify) 180885b47fbSopenharmony_ci{ 181885b47fbSopenharmony_ci return PutStringValue(key, std::to_string(value), needNotify); 182885b47fbSopenharmony_ci} 183885b47fbSopenharmony_ci 184885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::PutBoolValue(const std::string& key, bool value, bool needNotify) 185885b47fbSopenharmony_ci{ 186885b47fbSopenharmony_ci std::string valueStr = value ? "1" : "0"; 187885b47fbSopenharmony_ci return PutStringValue(key, valueStr, needNotify); 188885b47fbSopenharmony_ci} 189885b47fbSopenharmony_ci 190885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::PutFloatValue(const std::string& key, float value, bool needNotify) 191885b47fbSopenharmony_ci{ 192885b47fbSopenharmony_ci return PutStringValue(key, std::to_string(value), needNotify); 193885b47fbSopenharmony_ci} 194885b47fbSopenharmony_ci 195885b47fbSopenharmony_civoid AccessibilityDatashareHelper::Initialize(int32_t systemAbilityId) 196885b47fbSopenharmony_ci{ 197885b47fbSopenharmony_ci auto systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); 198885b47fbSopenharmony_ci if (systemAbilityManager == nullptr) { 199885b47fbSopenharmony_ci HILOG_ERROR("get sam return nullptr"); 200885b47fbSopenharmony_ci return; 201885b47fbSopenharmony_ci } 202885b47fbSopenharmony_ci auto remoteObj = systemAbilityManager->GetSystemAbility(systemAbilityId); 203885b47fbSopenharmony_ci if (remoteObj == nullptr) { 204885b47fbSopenharmony_ci HILOG_ERROR("Get remoteObj return nullptr, systemAbilityId=%{public}d", systemAbilityId); 205885b47fbSopenharmony_ci return; 206885b47fbSopenharmony_ci } 207885b47fbSopenharmony_ci remoteObj_ = remoteObj; 208885b47fbSopenharmony_ci switch (type_) { 209885b47fbSopenharmony_ci case DATASHARE_TYPE::GLOBAL: 210885b47fbSopenharmony_ci uriProxyStr_ = SETTING_GLOBAL_URI + "?Proxy=true"; 211885b47fbSopenharmony_ci break; 212885b47fbSopenharmony_ci case DATASHARE_TYPE::SYSTEM: 213885b47fbSopenharmony_ci uriProxyStr_ = SETTING_SYSTEM_URI + std::to_string(accountId_) + "?Proxy=true"; 214885b47fbSopenharmony_ci break; 215885b47fbSopenharmony_ci case DATASHARE_TYPE::SECURE: 216885b47fbSopenharmony_ci uriProxyStr_ = SETTING_SECURE_URI + std::to_string(accountId_) + "?Proxy=true"; 217885b47fbSopenharmony_ci break; 218885b47fbSopenharmony_ci default: 219885b47fbSopenharmony_ci uriProxyStr_ = SETTING_GLOBAL_URI + "?Proxy=true"; 220885b47fbSopenharmony_ci HILOG_WARN("undefined DATASHARE_TYPE, use global table"); 221885b47fbSopenharmony_ci break; 222885b47fbSopenharmony_ci } 223885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 224885b47fbSopenharmony_ci dataShareHelper_ = CreateDatashareHelper(); 225885b47fbSopenharmony_ci if (dataShareHelper_ == nullptr) { 226885b47fbSopenharmony_ci HILOG_ERROR("create dataShareHelper_ failed"); 227885b47fbSopenharmony_ci } 228885b47fbSopenharmony_ci#endif 229885b47fbSopenharmony_ci} 230885b47fbSopenharmony_ci 231885b47fbSopenharmony_cisptr<AccessibilitySettingObserver> AccessibilityDatashareHelper::CreateObserver(const std::string& key, 232885b47fbSopenharmony_ci AccessibilitySettingObserver::UpdateFunc& func) 233885b47fbSopenharmony_ci{ 234885b47fbSopenharmony_ci sptr<AccessibilitySettingObserver> observer = new AccessibilitySettingObserver(); 235885b47fbSopenharmony_ci observer->SetKey(key); 236885b47fbSopenharmony_ci observer->SetUpdateFunc(func); 237885b47fbSopenharmony_ci return observer; 238885b47fbSopenharmony_ci} 239885b47fbSopenharmony_ci 240885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::RegisterObserver(const sptr<AccessibilitySettingObserver>& observer) 241885b47fbSopenharmony_ci{ 242885b47fbSopenharmony_ci std::string callingIdentity = IPCSkeleton::ResetCallingIdentity(); 243885b47fbSopenharmony_ci auto uri = AssembleUri(observer->GetKey()); 244885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 245885b47fbSopenharmony_ci if (dataShareHelper_ == nullptr) { 246885b47fbSopenharmony_ci IPCSkeleton::SetCallingIdentity(callingIdentity); 247885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 248885b47fbSopenharmony_ci } 249885b47fbSopenharmony_ci dataShareHelper_->RegisterObserver(uri, observer); 250885b47fbSopenharmony_ci#endif 251885b47fbSopenharmony_ci IPCSkeleton::SetCallingIdentity(callingIdentity); 252885b47fbSopenharmony_ci HILOG_DEBUG("succeed to register observer of uri=%{public}s", uri.ToString().c_str()); 253885b47fbSopenharmony_ci return RET_OK; 254885b47fbSopenharmony_ci} 255885b47fbSopenharmony_ci 256885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::RegisterObserver(const std::string& key, 257885b47fbSopenharmony_ci AccessibilitySettingObserver::UpdateFunc& func) 258885b47fbSopenharmony_ci{ 259885b47fbSopenharmony_ci sptr<AccessibilitySettingObserver> observer = CreateObserver(key, func); 260885b47fbSopenharmony_ci if (observer == nullptr) { 261885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 262885b47fbSopenharmony_ci } 263885b47fbSopenharmony_ci auto iter = settingObserverMap_.find(key); 264885b47fbSopenharmony_ci if (iter != settingObserverMap_.end() && iter->second != nullptr) { 265885b47fbSopenharmony_ci HILOG_INFO("observer of key = %{public}s already exist", key.c_str()); 266885b47fbSopenharmony_ci return RET_OK; 267885b47fbSopenharmony_ci } 268885b47fbSopenharmony_ci if (RegisterObserver(observer) != ERR_OK) { 269885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 270885b47fbSopenharmony_ci } 271885b47fbSopenharmony_ci std::lock_guard<ffrt::mutex> lock(observerMutex_); 272885b47fbSopenharmony_ci settingObserverMap_.insert(std::make_pair(key, observer)); 273885b47fbSopenharmony_ci return RET_OK; 274885b47fbSopenharmony_ci} 275885b47fbSopenharmony_ci 276885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::UnregisterObserver(const sptr<AccessibilitySettingObserver>& observer) 277885b47fbSopenharmony_ci{ 278885b47fbSopenharmony_ci std::string callingIdentity = IPCSkeleton::ResetCallingIdentity(); 279885b47fbSopenharmony_ci auto uri = AssembleUri(observer->GetKey()); 280885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 281885b47fbSopenharmony_ci if (dataShareHelper_ == nullptr) { 282885b47fbSopenharmony_ci IPCSkeleton::SetCallingIdentity(callingIdentity); 283885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 284885b47fbSopenharmony_ci } 285885b47fbSopenharmony_ci dataShareHelper_->UnregisterObserver(uri, observer); 286885b47fbSopenharmony_ci#endif 287885b47fbSopenharmony_ci IPCSkeleton::SetCallingIdentity(callingIdentity); 288885b47fbSopenharmony_ci HILOG_DEBUG("succeed to unregister observer of uri=%{public}s", uri.ToString().c_str()); 289885b47fbSopenharmony_ci return RET_OK; 290885b47fbSopenharmony_ci} 291885b47fbSopenharmony_ci 292885b47fbSopenharmony_ciRetError AccessibilityDatashareHelper::UnregisterObserver(const std::string& key) 293885b47fbSopenharmony_ci{ 294885b47fbSopenharmony_ci std::lock_guard<ffrt::mutex> lock(observerMutex_); 295885b47fbSopenharmony_ci auto iter = settingObserverMap_.find(key); 296885b47fbSopenharmony_ci if (iter != settingObserverMap_.end() && iter->second != nullptr) { 297885b47fbSopenharmony_ci sptr<AccessibilitySettingObserver> observer = iter->second; 298885b47fbSopenharmony_ci if (UnregisterObserver(observer) == ERR_OK) { 299885b47fbSopenharmony_ci settingObserverMap_.erase(iter); 300885b47fbSopenharmony_ci HILOG_DEBUG("succeed to unregister observer of key %{public}s", key.c_str()); 301885b47fbSopenharmony_ci return RET_OK; 302885b47fbSopenharmony_ci } else { 303885b47fbSopenharmony_ci settingObserverMap_.erase(iter); 304885b47fbSopenharmony_ci HILOG_WARN("failed to unregister observer of key %{public}s", key.c_str()); 305885b47fbSopenharmony_ci return RET_ERR_FAILED; 306885b47fbSopenharmony_ci } 307885b47fbSopenharmony_ci } 308885b47fbSopenharmony_ci HILOG_WARN("failed to find the key %{public}s", key.c_str()); 309885b47fbSopenharmony_ci return RET_ERR_FAILED; 310885b47fbSopenharmony_ci} 311885b47fbSopenharmony_ci 312885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DATA_SHARE 313885b47fbSopenharmony_cistd::shared_ptr<DataShare::DataShareHelper> AccessibilityDatashareHelper::CreateDatashareHelper() 314885b47fbSopenharmony_ci{ 315885b47fbSopenharmony_ci if (remoteObj_ == nullptr) { 316885b47fbSopenharmony_ci return nullptr; 317885b47fbSopenharmony_ci } 318885b47fbSopenharmony_ci std::pair<int, std::shared_ptr<DataShare::DataShareHelper>> ret = DataShare::DataShareHelper::Create(remoteObj_, 319885b47fbSopenharmony_ci uriProxyStr_, SETTINGS_DATA_EXT_URI); 320885b47fbSopenharmony_ci HILOG_INFO("create helper ret = %{public}d, uri=%{public}s", ret.first, uriProxyStr_.c_str()); 321885b47fbSopenharmony_ci if (ret.second == nullptr) { 322885b47fbSopenharmony_ci Utils::RecordUnavailableEvent(A11yUnavailableEvent::READ_EVENT, A11yError::ERROR_READ_FAILED); 323885b47fbSopenharmony_ci return nullptr; 324885b47fbSopenharmony_ci } 325885b47fbSopenharmony_ci return ret.second; 326885b47fbSopenharmony_ci} 327885b47fbSopenharmony_ci 328885b47fbSopenharmony_cibool AccessibilityDatashareHelper::DestoryDatashareHelper(std::shared_ptr<DataShare::DataShareHelper>& helper) 329885b47fbSopenharmony_ci{ 330885b47fbSopenharmony_ci if (helper && !helper->Release()) { 331885b47fbSopenharmony_ci HILOG_WARN("release helper fail."); 332885b47fbSopenharmony_ci return false; 333885b47fbSopenharmony_ci } 334885b47fbSopenharmony_ci return true; 335885b47fbSopenharmony_ci} 336885b47fbSopenharmony_ci#endif 337885b47fbSopenharmony_ci 338885b47fbSopenharmony_ciUri AccessibilityDatashareHelper::AssembleUri(const std::string& key) 339885b47fbSopenharmony_ci{ 340885b47fbSopenharmony_ci Uri uri(uriProxyStr_ + "&key=" + key); 341885b47fbSopenharmony_ci return uri; 342885b47fbSopenharmony_ci} 343885b47fbSopenharmony_ci 344885b47fbSopenharmony_ci} // namespace Accessibility 345885b47fbSopenharmony_ci} // namespace OHOS 346885b47fbSopenharmony_ci 347