1885b47fbSopenharmony_ci/* 2885b47fbSopenharmony_ci * Copyright (C) 2023 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 <string> 17885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 18885b47fbSopenharmony_ci#include <hitrace_meter.h> 19885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 20885b47fbSopenharmony_ci#include "accessibility_account_data.h" 21885b47fbSopenharmony_ci#include "accessible_ability_manager_service.h" 22885b47fbSopenharmony_ci#include "accessibility_settings.h" 23885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_POWER_MANAGER 24885b47fbSopenharmony_ci#include "accessibility_power_manager.h" 25885b47fbSopenharmony_ci#endif 26885b47fbSopenharmony_ci#include "hilog_wrapper.h" 27885b47fbSopenharmony_ci#include "parameter.h" 28885b47fbSopenharmony_ci 29885b47fbSopenharmony_cinamespace OHOS { 30885b47fbSopenharmony_cinamespace Accessibility { 31885b47fbSopenharmony_cinamespace { 32885b47fbSopenharmony_ci const std::string GRAPHIC_ANIMATION_SCALE_NAME = "persist.sys.graphic.animationscale"; 33885b47fbSopenharmony_ci const std::string ARKUI_ANIMATION_SCALE_NAME = "persist.sys.arkui.animationscale"; 34885b47fbSopenharmony_ci const std::string SCREEN_READER_BUNDLE_ABILITY_NAME = "com.huawei.hmos.screenreader/AccessibilityExtAbility"; 35885b47fbSopenharmony_ci const int32_t SHORT_KEY_TIMEOUT_BEFORE_USE = 3000; // ms 36885b47fbSopenharmony_ci const int32_t SHORT_KEY_TIMEOUT_AFTER_USE = 1000; // ms 37885b47fbSopenharmony_ci const int32_t INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE = 2; 38885b47fbSopenharmony_ci} 39885b47fbSopenharmony_ci 40885b47fbSopenharmony_civoid AccessibilitySettings::RegisterSettingsHandler(const std::shared_ptr<AppExecFwk::EventHandler> &handler) 41885b47fbSopenharmony_ci{ 42885b47fbSopenharmony_ci HILOG_DEBUG(); 43885b47fbSopenharmony_ci handler_ = handler; 44885b47fbSopenharmony_ci} 45885b47fbSopenharmony_ci 46885b47fbSopenharmony_ciRetError AccessibilitySettings::SetScreenMagnificationState(const bool state) 47885b47fbSopenharmony_ci{ 48885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 49885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 50885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetScreenMagnificationState:" + std::to_string(state)); 51885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 52885b47fbSopenharmony_ci 53885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 54885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 55885b47fbSopenharmony_ci if (!accountData) { 56885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 57885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 58885b47fbSopenharmony_ci } 59885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetScreenMagnificationState(state); 60885b47fbSopenharmony_ci UpdateConfigState(); 61885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter(); 62885b47fbSopenharmony_ci return ret; 63885b47fbSopenharmony_ci} 64885b47fbSopenharmony_ci 65885b47fbSopenharmony_ciRetError AccessibilitySettings::SetShortKeyState(const bool state) 66885b47fbSopenharmony_ci{ 67885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 68885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 69885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortKeyState:" + std::to_string(state)); 70885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 71885b47fbSopenharmony_ci 72885b47fbSopenharmony_ci if (!handler_) { 73885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 74885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 75885b47fbSopenharmony_ci } 76885b47fbSopenharmony_ci 77885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 78885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 79885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, state]() { 80885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 81885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 82885b47fbSopenharmony_ci if (!accountData) { 83885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 84885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 85885b47fbSopenharmony_ci return; 86885b47fbSopenharmony_ci } 87885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetShortKeyState(state); 88885b47fbSopenharmony_ci syncPromise.set_value(ret); 89885b47fbSopenharmony_ci UpdateConfigState(); 90885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateShortKeyRegister(); 91885b47fbSopenharmony_ci }, "TASK_SET_SHORTKEY_STATE"); 92885b47fbSopenharmony_ci return syncFuture.get(); 93885b47fbSopenharmony_ci} 94885b47fbSopenharmony_ci 95885b47fbSopenharmony_ciRetError AccessibilitySettings::SetMouseKeyState(const bool state) 96885b47fbSopenharmony_ci{ 97885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 98885b47fbSopenharmony_ci 99885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 100885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 101885b47fbSopenharmony_ci if (!accountData) { 102885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 103885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 104885b47fbSopenharmony_ci } 105885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetMouseKeyState(state); 106885b47fbSopenharmony_ci UpdateConfigState(); 107885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter(); 108885b47fbSopenharmony_ci return ret; 109885b47fbSopenharmony_ci} 110885b47fbSopenharmony_ci 111885b47fbSopenharmony_ciRetError AccessibilitySettings::SetMouseAutoClick(const int32_t time) 112885b47fbSopenharmony_ci{ 113885b47fbSopenharmony_ci HILOG_INFO("time = [%{public}d]", time); 114885b47fbSopenharmony_ci if (!handler_) { 115885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 116885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 117885b47fbSopenharmony_ci } 118885b47fbSopenharmony_ci 119885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 120885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 121885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, time]() { 122885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 123885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 124885b47fbSopenharmony_ci if (!accountData) { 125885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 126885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 127885b47fbSopenharmony_ci return; 128885b47fbSopenharmony_ci } 129885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetMouseAutoClick(time); 130885b47fbSopenharmony_ci syncPromise.set_value(ret); 131885b47fbSopenharmony_ci UpdateMouseAutoClick(); 132885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter(); 133885b47fbSopenharmony_ci }, "TASK_SET_MOUSE_AUTOCLICK"); 134885b47fbSopenharmony_ci return syncFuture.get(); 135885b47fbSopenharmony_ci} 136885b47fbSopenharmony_ci 137885b47fbSopenharmony_ciRetError AccessibilitySettings::SetShortkeyTarget(const std::string &name) 138885b47fbSopenharmony_ci{ 139885b47fbSopenharmony_ci HILOG_INFO("name = [%{public}s]", name.c_str()); 140885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 141885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyTarget:" + name); 142885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 143885b47fbSopenharmony_ci 144885b47fbSopenharmony_ci if (!handler_) { 145885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 146885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 147885b47fbSopenharmony_ci } 148885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 149885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 150885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &name]() { 151885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 152885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 153885b47fbSopenharmony_ci if (!accountData) { 154885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 155885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 156885b47fbSopenharmony_ci return; 157885b47fbSopenharmony_ci } 158885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetShortkeyTarget(name); 159885b47fbSopenharmony_ci syncPromise.set_value(ret); 160885b47fbSopenharmony_ci UpdateShortkeyTarget(); 161885b47fbSopenharmony_ci }, "TASK_SET_SHORTKEY_TARGET"); 162885b47fbSopenharmony_ci return syncFuture.get(); 163885b47fbSopenharmony_ci} 164885b47fbSopenharmony_ci 165885b47fbSopenharmony_ciRetError AccessibilitySettings::SetShortkeyMultiTarget(const std::vector<std::string> &name) 166885b47fbSopenharmony_ci{ 167885b47fbSopenharmony_ci HILOG_DEBUG(); 168885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 169885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetShortkeyMultiTarget"); 170885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 171885b47fbSopenharmony_ci 172885b47fbSopenharmony_ci if (!handler_) { 173885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 174885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 175885b47fbSopenharmony_ci } 176885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 177885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 178885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &name]() { 179885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 180885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 181885b47fbSopenharmony_ci if (!accountData) { 182885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 183885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 184885b47fbSopenharmony_ci return; 185885b47fbSopenharmony_ci } 186885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetShortkeyMultiTarget(name); 187885b47fbSopenharmony_ci syncPromise.set_value(ret); 188885b47fbSopenharmony_ci UpdateShortkeyMultiTarget(); 189885b47fbSopenharmony_ci }, "TASK_SET_SHORTKEY_MULTI_TARGET"); 190885b47fbSopenharmony_ci return syncFuture.get(); 191885b47fbSopenharmony_ci} 192885b47fbSopenharmony_ci 193885b47fbSopenharmony_ciRetError AccessibilitySettings::SetHighContrastTextState(const bool state) 194885b47fbSopenharmony_ci{ 195885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 196885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 197885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetHighContrastTextState:" + std::to_string(state)); 198885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 199885b47fbSopenharmony_ci 200885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 201885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 202885b47fbSopenharmony_ci if (!accountData) { 203885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 204885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 205885b47fbSopenharmony_ci } 206885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetHighContrastTextState(state); 207885b47fbSopenharmony_ci UpdateConfigState(); 208885b47fbSopenharmony_ci return ret; 209885b47fbSopenharmony_ci} 210885b47fbSopenharmony_ci 211885b47fbSopenharmony_ciRetError AccessibilitySettings::SetDaltonizationState(const bool state) 212885b47fbSopenharmony_ci{ 213885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 214885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 215885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetDaltonizationState:" + std::to_string(state)); 216885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 217885b47fbSopenharmony_ci 218885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 219885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 220885b47fbSopenharmony_ci if (!accountData) { 221885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 222885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 223885b47fbSopenharmony_ci } 224885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetDaltonizationState(state); 225885b47fbSopenharmony_ci UpdateConfigState(); 226885b47fbSopenharmony_ci return ret; 227885b47fbSopenharmony_ci} 228885b47fbSopenharmony_ci 229885b47fbSopenharmony_ciRetError AccessibilitySettings::SetInvertColorState(const bool state) 230885b47fbSopenharmony_ci{ 231885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 232885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 233885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetInvertColorState:" + std::to_string(state)); 234885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 235885b47fbSopenharmony_ci 236885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 237885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 238885b47fbSopenharmony_ci if (!accountData) { 239885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 240885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 241885b47fbSopenharmony_ci } 242885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetInvertColorState(state); 243885b47fbSopenharmony_ci UpdateConfigState(); 244885b47fbSopenharmony_ci return ret; 245885b47fbSopenharmony_ci} 246885b47fbSopenharmony_ci 247885b47fbSopenharmony_ciRetError AccessibilitySettings::SetAnimationOffState(const bool state) 248885b47fbSopenharmony_ci{ 249885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 250885b47fbSopenharmony_ci 251885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 252885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 253885b47fbSopenharmony_ci if (!accountData) { 254885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 255885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 256885b47fbSopenharmony_ci } 257885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetAnimationOffState(state); 258885b47fbSopenharmony_ci UpdateConfigState(); 259885b47fbSopenharmony_ci int setGraphicParamRes = -1; 260885b47fbSopenharmony_ci int setArkuiParamRes = -1; 261885b47fbSopenharmony_ci if (state) { 262885b47fbSopenharmony_ci setGraphicParamRes = SetParameter(GRAPHIC_ANIMATION_SCALE_NAME.c_str(), "0"); 263885b47fbSopenharmony_ci setArkuiParamRes = SetParameter(ARKUI_ANIMATION_SCALE_NAME.c_str(), "0"); 264885b47fbSopenharmony_ci } else { 265885b47fbSopenharmony_ci setGraphicParamRes = SetParameter(GRAPHIC_ANIMATION_SCALE_NAME.c_str(), "1"); 266885b47fbSopenharmony_ci setArkuiParamRes = SetParameter(ARKUI_ANIMATION_SCALE_NAME.c_str(), "1"); 267885b47fbSopenharmony_ci } 268885b47fbSopenharmony_ci HILOG_INFO("SetParameter results are %{public}d and %{public}d", setGraphicParamRes, setArkuiParamRes); 269885b47fbSopenharmony_ci return ret; 270885b47fbSopenharmony_ci} 271885b47fbSopenharmony_ci 272885b47fbSopenharmony_ciRetError AccessibilitySettings::SetAudioMonoState(const bool state) 273885b47fbSopenharmony_ci{ 274885b47fbSopenharmony_ci HILOG_INFO("state = [%{public}s]", state ? "True" : "False"); 275885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 276885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetAudioMonoState:" + std::to_string(state)); 277885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 278885b47fbSopenharmony_ci 279885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 280885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 281885b47fbSopenharmony_ci if (!accountData) { 282885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 283885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 284885b47fbSopenharmony_ci } 285885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetAudioMonoState(state); 286885b47fbSopenharmony_ci UpdateConfigState(); 287885b47fbSopenharmony_ci return ret; 288885b47fbSopenharmony_ci} 289885b47fbSopenharmony_ci 290885b47fbSopenharmony_ciRetError AccessibilitySettings::SetDaltonizationColorFilter(const uint32_t filter) 291885b47fbSopenharmony_ci{ 292885b47fbSopenharmony_ci HILOG_INFO("filter = [%{public}u]", filter); 293885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 294885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetDaltonizationColorFilter:" + std::to_string(filter)); 295885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 296885b47fbSopenharmony_ci if (!handler_) { 297885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 298885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 299885b47fbSopenharmony_ci } 300885b47fbSopenharmony_ci 301885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 302885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 303885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, filter]() { 304885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 305885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 306885b47fbSopenharmony_ci if (!accountData) { 307885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 308885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 309885b47fbSopenharmony_ci return; 310885b47fbSopenharmony_ci } 311885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetDaltonizationColorFilter(filter); 312885b47fbSopenharmony_ci syncPromise.set_value(ret); 313885b47fbSopenharmony_ci UpdateDaltonizationColorFilter(); 314885b47fbSopenharmony_ci }, "TASK_SET_DALTONIZATION_COLORFILTER"); 315885b47fbSopenharmony_ci return syncFuture.get(); 316885b47fbSopenharmony_ci} 317885b47fbSopenharmony_ci 318885b47fbSopenharmony_ciRetError AccessibilitySettings::SetContentTimeout(const uint32_t time) 319885b47fbSopenharmony_ci{ 320885b47fbSopenharmony_ci HILOG_INFO("time = [%{public}u]", time); 321885b47fbSopenharmony_ci if (!handler_) { 322885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 323885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 324885b47fbSopenharmony_ci } 325885b47fbSopenharmony_ci 326885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 327885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 328885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, time]() { 329885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 330885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 331885b47fbSopenharmony_ci if (!accountData) { 332885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 333885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 334885b47fbSopenharmony_ci return; 335885b47fbSopenharmony_ci } 336885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetContentTimeout(time); 337885b47fbSopenharmony_ci syncPromise.set_value(ret); 338885b47fbSopenharmony_ci UpdateContentTimeout(); 339885b47fbSopenharmony_ci }, "TASK_SET_CONTENT_TIMEOUT"); 340885b47fbSopenharmony_ci return syncFuture.get(); 341885b47fbSopenharmony_ci} 342885b47fbSopenharmony_ci 343885b47fbSopenharmony_ciRetError AccessibilitySettings::SetBrightnessDiscount(const float discount) 344885b47fbSopenharmony_ci{ 345885b47fbSopenharmony_ci HILOG_INFO("discount = [%{public}f]", discount); 346885b47fbSopenharmony_ci if (!handler_) { 347885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 348885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 349885b47fbSopenharmony_ci } 350885b47fbSopenharmony_ci 351885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_POWER_MANAGER 352885b47fbSopenharmony_ci if (!Singleton<AccessibilityPowerManager>::GetInstance().DiscountBrightness(discount)) { 353885b47fbSopenharmony_ci HILOG_ERROR("Failed to set brightness discount"); 354885b47fbSopenharmony_ci return Accessibility::RET_ERR_FAILED; 355885b47fbSopenharmony_ci } 356885b47fbSopenharmony_ci#endif 357885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 358885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 359885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, discount]() { 360885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 361885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 362885b47fbSopenharmony_ci if (!accountData) { 363885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 364885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 365885b47fbSopenharmony_ci return; 366885b47fbSopenharmony_ci } 367885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetBrightnessDiscount(discount); 368885b47fbSopenharmony_ci syncPromise.set_value(ret); 369885b47fbSopenharmony_ci UpdateBrightnessDiscount(); 370885b47fbSopenharmony_ci }, "TASK_SET_BRIGHTNESS_DISCOUNT"); 371885b47fbSopenharmony_ci return syncFuture.get(); 372885b47fbSopenharmony_ci} 373885b47fbSopenharmony_ci 374885b47fbSopenharmony_ciRetError AccessibilitySettings::SetAudioBalance(const float balance) 375885b47fbSopenharmony_ci{ 376885b47fbSopenharmony_ci HILOG_INFO("balance = [%{public}f]", balance); 377885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 378885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetAudioBalance:" + std::to_string(balance)); 379885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 380885b47fbSopenharmony_ci 381885b47fbSopenharmony_ci if (!handler_) { 382885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 383885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 384885b47fbSopenharmony_ci } 385885b47fbSopenharmony_ci 386885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 387885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 388885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, balance]() { 389885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 390885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 391885b47fbSopenharmony_ci if (!accountData) { 392885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 393885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 394885b47fbSopenharmony_ci return; 395885b47fbSopenharmony_ci } 396885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetAudioBalance(balance); 397885b47fbSopenharmony_ci syncPromise.set_value(ret); 398885b47fbSopenharmony_ci UpdateAudioBalance(); 399885b47fbSopenharmony_ci }, "TASK_SET_AUDIO_BALANCE"); 400885b47fbSopenharmony_ci return syncFuture.get(); 401885b47fbSopenharmony_ci} 402885b47fbSopenharmony_ci 403885b47fbSopenharmony_ciRetError AccessibilitySettings::SetClickResponseTime(const uint32_t time) 404885b47fbSopenharmony_ci{ 405885b47fbSopenharmony_ci HILOG_INFO("click response time = [%{public}u]", time); 406885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 407885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetClickResponseTime:" + std::to_string(time)); 408885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 409885b47fbSopenharmony_ci 410885b47fbSopenharmony_ci if (!handler_) { 411885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 412885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 413885b47fbSopenharmony_ci } 414885b47fbSopenharmony_ci 415885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 416885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 417885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, time]() { 418885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 419885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 420885b47fbSopenharmony_ci if (!accountData) { 421885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 422885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 423885b47fbSopenharmony_ci return; 424885b47fbSopenharmony_ci } 425885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetClickResponseTime(time); 426885b47fbSopenharmony_ci syncPromise.set_value(ret); 427885b47fbSopenharmony_ci UpdateClickResponseTime(); 428885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter(); 429885b47fbSopenharmony_ci }, "TASK_SET_CLICK_RESPONSE_TIME"); 430885b47fbSopenharmony_ci return syncFuture.get(); 431885b47fbSopenharmony_ci} 432885b47fbSopenharmony_ci 433885b47fbSopenharmony_ciRetError AccessibilitySettings::SetIgnoreRepeatClickState(const bool state) 434885b47fbSopenharmony_ci{ 435885b47fbSopenharmony_ci HILOG_INFO("ignore repeat click state = [%{public}s]", state ? "True" : "False"); 436885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 437885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetIgnoreRepeatClickState:" + std::to_string(state)); 438885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 439885b47fbSopenharmony_ci 440885b47fbSopenharmony_ci if (!handler_) { 441885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 442885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 443885b47fbSopenharmony_ci } 444885b47fbSopenharmony_ci 445885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 446885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 447885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, state]() { 448885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 449885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 450885b47fbSopenharmony_ci if (!accountData) { 451885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 452885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 453885b47fbSopenharmony_ci return; 454885b47fbSopenharmony_ci } 455885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetIgnoreRepeatClickState(state); 456885b47fbSopenharmony_ci syncPromise.set_value(ret); 457885b47fbSopenharmony_ci UpdateConfigState(); 458885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter(); 459885b47fbSopenharmony_ci }, "TASK_SET_IGNORE_REPEAT_CLICK_STATE"); 460885b47fbSopenharmony_ci return syncFuture.get(); 461885b47fbSopenharmony_ci} 462885b47fbSopenharmony_ci 463885b47fbSopenharmony_ciRetError AccessibilitySettings::SetIgnoreRepeatClickTime(const uint32_t time) 464885b47fbSopenharmony_ci{ 465885b47fbSopenharmony_ci HILOG_INFO("click response time = [%{public}u]", time); 466885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_HITRACE 467885b47fbSopenharmony_ci HITRACE_METER_NAME(HITRACE_TAG_ACCESSIBILITY_MANAGER, "SetIgnoreRepeatClickTime:" + std::to_string(time)); 468885b47fbSopenharmony_ci#endif // OHOS_BUILD_ENABLE_HITRACE 469885b47fbSopenharmony_ci 470885b47fbSopenharmony_ci if (!handler_) { 471885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 472885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 473885b47fbSopenharmony_ci } 474885b47fbSopenharmony_ci 475885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 476885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 477885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, time]() { 478885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 479885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 480885b47fbSopenharmony_ci if (!accountData) { 481885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 482885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 483885b47fbSopenharmony_ci return; 484885b47fbSopenharmony_ci } 485885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetIgnoreRepeatClickTime(time); 486885b47fbSopenharmony_ci syncPromise.set_value(ret); 487885b47fbSopenharmony_ci UpdateIgnoreRepeatClickTime(); 488885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateInputFilter(); 489885b47fbSopenharmony_ci }, "TASK_SET_IGNORE_REPEAT_CLICK_TIME"); 490885b47fbSopenharmony_ci return syncFuture.get(); 491885b47fbSopenharmony_ci} 492885b47fbSopenharmony_ci 493885b47fbSopenharmony_civoid AccessibilitySettings::UpdateSettingsInAtoHosStatePart(ConfigValueAtoHosUpdate &atoHosValue) 494885b47fbSopenharmony_ci{ 495885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 496885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 497885b47fbSopenharmony_ci // set 498885b47fbSopenharmony_ci if (atoHosValue.daltonizationState) { 499885b47fbSopenharmony_ci accountData->GetConfig()->SetDaltonizationState(atoHosValue.daltonizationState); 500885b47fbSopenharmony_ci } 501885b47fbSopenharmony_ci if (atoHosValue.invertColor) { 502885b47fbSopenharmony_ci accountData->GetConfig()->SetInvertColorState(atoHosValue.invertColor); 503885b47fbSopenharmony_ci } 504885b47fbSopenharmony_ci if (atoHosValue.audioMono) { 505885b47fbSopenharmony_ci accountData->GetConfig()->SetAudioMonoState(atoHosValue.audioMono); 506885b47fbSopenharmony_ci } 507885b47fbSopenharmony_ci if (atoHosValue.highContrastText) { 508885b47fbSopenharmony_ci accountData->GetConfig()->SetHighContrastTextState(atoHosValue.highContrastText); 509885b47fbSopenharmony_ci } 510885b47fbSopenharmony_ci if (atoHosValue.ignoreRepeatClickState) { 511885b47fbSopenharmony_ci accountData->GetConfig()->SetIgnoreRepeatClickState(atoHosValue.ignoreRepeatClickState); 512885b47fbSopenharmony_ci } 513885b47fbSopenharmony_ci if (atoHosValue.shortcutEnabled) { 514885b47fbSopenharmony_ci accountData->GetConfig()->SetShortKeyState(atoHosValue.shortcutEnabled); 515885b47fbSopenharmony_ci } 516885b47fbSopenharmony_ci bool shortKeyOnLockScreenAutoOn = false; 517885b47fbSopenharmony_ci if (atoHosValue.shortcutTimeout == 1) { 518885b47fbSopenharmony_ci accountData->GetConfig()->SetShortKeyTimeout(SHORT_KEY_TIMEOUT_AFTER_USE); 519885b47fbSopenharmony_ci if (atoHosValue.shortcutOnLockScreen == INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE) { 520885b47fbSopenharmony_ci shortKeyOnLockScreenAutoOn = true; 521885b47fbSopenharmony_ci accountData->GetConfig()->SetShortKeyOnLockScreenState(true); 522885b47fbSopenharmony_ci } 523885b47fbSopenharmony_ci } else if (atoHosValue.shortcutTimeout == 0) { 524885b47fbSopenharmony_ci accountData->GetConfig()->SetShortKeyTimeout(SHORT_KEY_TIMEOUT_BEFORE_USE); 525885b47fbSopenharmony_ci } 526885b47fbSopenharmony_ci if (atoHosValue.shortcutOnLockScreen != INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE) { 527885b47fbSopenharmony_ci accountData->GetConfig()->SetShortKeyOnLockScreenState(atoHosValue.shortcutOnLockScreen == 1); 528885b47fbSopenharmony_ci } else if (!shortKeyOnLockScreenAutoOn) { 529885b47fbSopenharmony_ci accountData->GetConfig()->SetShortKeyOnLockScreenState(atoHosValue.shortcutEnabledOnLockScreen == 1); 530885b47fbSopenharmony_ci } 531885b47fbSopenharmony_ci if (atoHosValue.screenMagnificationState) { 532885b47fbSopenharmony_ci accountData->GetConfig()->SetScreenMagnificationState(atoHosValue.screenMagnificationState); 533885b47fbSopenharmony_ci } 534885b47fbSopenharmony_ci UpdateConfigState(); 535885b47fbSopenharmony_ci} 536885b47fbSopenharmony_ci 537885b47fbSopenharmony_civoid AccessibilitySettings::UpdateSettingsInAtoHos() 538885b47fbSopenharmony_ci{ 539885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 540885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 541885b47fbSopenharmony_ci ConfigValueAtoHosUpdate atoHosValue; 542885b47fbSopenharmony_ci accountData->GetConfigValueAtoHos(atoHosValue); 543885b47fbSopenharmony_ci 544885b47fbSopenharmony_ci HILOG_INFO("daltonizationState(%{public}d), invertColor(%{public}d), \ 545885b47fbSopenharmony_ci audioMono(%{public}d), audioBalance(%{public}f), highContrastText(%{public}d), \ 546885b47fbSopenharmony_ci isScreenReaderEnabled(%{public}d), ignoreRepeatClickState(%{public}d), \ 547885b47fbSopenharmony_ci clickResponseTime(%{public}d), ignoreRepeatClickTime(%{public}d), displayDaltonizer(%{public}d), \ 548885b47fbSopenharmony_ci shortcutEnabled(%{public}d), shortcutEnabledOnLockScreen(%{public}d), shortcutTimeout(%{public}d), \ 549885b47fbSopenharmony_ci screenMagnificationState(%{public}d).", 550885b47fbSopenharmony_ci atoHosValue.daltonizationState, atoHosValue.invertColor, atoHosValue.audioMono, atoHosValue.audioBalance, 551885b47fbSopenharmony_ci atoHosValue.highContrastText, atoHosValue.isScreenReaderEnabled, atoHosValue.ignoreRepeatClickState, 552885b47fbSopenharmony_ci atoHosValue.clickResponseTime, atoHosValue.ignoreRepeatClickTime, atoHosValue.displayDaltonizer, 553885b47fbSopenharmony_ci atoHosValue.shortcutEnabled, atoHosValue.shortcutEnabledOnLockScreen, atoHosValue.shortcutTimeout, 554885b47fbSopenharmony_ci atoHosValue.screenMagnificationState); 555885b47fbSopenharmony_ci 556885b47fbSopenharmony_ci UpdateSettingsInAtoHosStatePart(atoHosValue); 557885b47fbSopenharmony_ci 558885b47fbSopenharmony_ci if (atoHosValue.audioBalance != 0.0) { 559885b47fbSopenharmony_ci accountData->GetConfig()->SetAudioBalance(atoHosValue.audioBalance); 560885b47fbSopenharmony_ci UpdateAudioBalance(); 561885b47fbSopenharmony_ci } 562885b47fbSopenharmony_ci if (atoHosValue.clickResponseTime != 0) { 563885b47fbSopenharmony_ci accountData->GetConfig()->SetClickResponseTime(static_cast<uint32_t>(atoHosValue.clickResponseTime)); 564885b47fbSopenharmony_ci UpdateClickResponseTime(); 565885b47fbSopenharmony_ci } 566885b47fbSopenharmony_ci if (atoHosValue.ignoreRepeatClickTime != 0) { 567885b47fbSopenharmony_ci accountData->GetConfig()->SetIgnoreRepeatClickTime(static_cast<uint32_t>(atoHosValue.ignoreRepeatClickTime)); 568885b47fbSopenharmony_ci UpdateIgnoreRepeatClickTime(); 569885b47fbSopenharmony_ci } 570885b47fbSopenharmony_ci if (atoHosValue.displayDaltonizer != 0) { 571885b47fbSopenharmony_ci accountData->GetConfig()->SetDaltonizationColorFilter(static_cast<uint32_t>(atoHosValue.displayDaltonizer)); 572885b47fbSopenharmony_ci UpdateDaltonizationColorFilter(); 573885b47fbSopenharmony_ci } 574885b47fbSopenharmony_ci 575885b47fbSopenharmony_ci if (atoHosValue.isScreenReaderEnabled) { 576885b47fbSopenharmony_ci uint32_t capabilities = CAPABILITY_GESTURE | CAPABILITY_KEY_EVENT_OBSERVER | CAPABILITY_RETRIEVE | 577885b47fbSopenharmony_ci CAPABILITY_TOUCH_GUIDE | CAPABILITY_ZOOM; 578885b47fbSopenharmony_ci accountData->EnableAbility(SCREEN_READER_BUNDLE_ABILITY_NAME, capabilities); 579885b47fbSopenharmony_ci } 580885b47fbSopenharmony_ci accountData->GetConfig()->CloneShortkeyService(atoHosValue.isScreenReaderEnabled); 581885b47fbSopenharmony_ci 582885b47fbSopenharmony_ci accountData->GetConfig()->SetStartFromAtoHosState(false); 583885b47fbSopenharmony_ci} 584885b47fbSopenharmony_ci 585885b47fbSopenharmony_ciRetError AccessibilitySettings::GetScreenMagnificationState(bool &state) 586885b47fbSopenharmony_ci{ 587885b47fbSopenharmony_ci HILOG_DEBUG(); 588885b47fbSopenharmony_ci if (!handler_) { 589885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 590885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 591885b47fbSopenharmony_ci } 592885b47fbSopenharmony_ci 593885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 594885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 595885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 596885b47fbSopenharmony_ci HILOG_DEBUG(); 597885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 598885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 599885b47fbSopenharmony_ci if (!accountData) { 600885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 601885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 602885b47fbSopenharmony_ci return; 603885b47fbSopenharmony_ci } 604885b47fbSopenharmony_ci state = accountData->GetConfig()->GetScreenMagnificationState(); 605885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 606885b47fbSopenharmony_ci }, "TASK_GET_SCREENMAGNIFIER_STATE"); 607885b47fbSopenharmony_ci return syncFuture.get(); 608885b47fbSopenharmony_ci} 609885b47fbSopenharmony_ci 610885b47fbSopenharmony_ciRetError AccessibilitySettings::GetShortKeyState(bool &state) 611885b47fbSopenharmony_ci{ 612885b47fbSopenharmony_ci HILOG_DEBUG(); 613885b47fbSopenharmony_ci if (!handler_) { 614885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 615885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 616885b47fbSopenharmony_ci } 617885b47fbSopenharmony_ci 618885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 619885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 620885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 621885b47fbSopenharmony_ci HILOG_DEBUG(); 622885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 623885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 624885b47fbSopenharmony_ci if (!accountData) { 625885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 626885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 627885b47fbSopenharmony_ci return; 628885b47fbSopenharmony_ci } 629885b47fbSopenharmony_ci state = accountData->GetConfig()->GetShortKeyState(); 630885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 631885b47fbSopenharmony_ci }, "TASK_GET_SHORTKEY_STATE"); 632885b47fbSopenharmony_ci return syncFuture.get(); 633885b47fbSopenharmony_ci} 634885b47fbSopenharmony_ci 635885b47fbSopenharmony_ciRetError AccessibilitySettings::GetMouseKeyState(bool &state) 636885b47fbSopenharmony_ci{ 637885b47fbSopenharmony_ci HILOG_DEBUG(); 638885b47fbSopenharmony_ci if (!handler_) { 639885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 640885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 641885b47fbSopenharmony_ci } 642885b47fbSopenharmony_ci 643885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 644885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 645885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 646885b47fbSopenharmony_ci HILOG_DEBUG(); 647885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 648885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 649885b47fbSopenharmony_ci if (!accountData) { 650885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 651885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 652885b47fbSopenharmony_ci return; 653885b47fbSopenharmony_ci } 654885b47fbSopenharmony_ci state = accountData->GetConfig()->GetMouseKeyState(); 655885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 656885b47fbSopenharmony_ci }, "TASK_GET_MOUSEKEY_STATE"); 657885b47fbSopenharmony_ci return syncFuture.get(); 658885b47fbSopenharmony_ci} 659885b47fbSopenharmony_ci 660885b47fbSopenharmony_ciRetError AccessibilitySettings::GetMouseAutoClick(int32_t &time) 661885b47fbSopenharmony_ci{ 662885b47fbSopenharmony_ci HILOG_DEBUG(); 663885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 664885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 665885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &time]() { 666885b47fbSopenharmony_ci HILOG_DEBUG(); 667885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 668885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 669885b47fbSopenharmony_ci if (!accountData) { 670885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 671885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 672885b47fbSopenharmony_ci return; 673885b47fbSopenharmony_ci } 674885b47fbSopenharmony_ci time = accountData->GetConfig()->GetMouseAutoClick(); 675885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 676885b47fbSopenharmony_ci }, "TASK_GET_MOUSE_AUTOCLICK"); 677885b47fbSopenharmony_ci 678885b47fbSopenharmony_ci return syncFuture.get(); 679885b47fbSopenharmony_ci} 680885b47fbSopenharmony_ci 681885b47fbSopenharmony_ciRetError AccessibilitySettings::GetShortkeyTarget(std::string &name) 682885b47fbSopenharmony_ci{ 683885b47fbSopenharmony_ci HILOG_DEBUG(); 684885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 685885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 686885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &name]() { 687885b47fbSopenharmony_ci HILOG_DEBUG(); 688885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 689885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 690885b47fbSopenharmony_ci if (!accountData) { 691885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 692885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 693885b47fbSopenharmony_ci return; 694885b47fbSopenharmony_ci } 695885b47fbSopenharmony_ci name = accountData->GetConfig()->GetShortkeyTarget(); 696885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 697885b47fbSopenharmony_ci }, "TASK_GET_SHORTKEY_TARGET"); 698885b47fbSopenharmony_ci 699885b47fbSopenharmony_ci return syncFuture.get(); 700885b47fbSopenharmony_ci} 701885b47fbSopenharmony_ci 702885b47fbSopenharmony_ciRetError AccessibilitySettings::GetShortkeyMultiTarget(std::vector<std::string> &name) 703885b47fbSopenharmony_ci{ 704885b47fbSopenharmony_ci HILOG_DEBUG(); 705885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 706885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 707885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &name]() { 708885b47fbSopenharmony_ci HILOG_DEBUG(); 709885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 710885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 711885b47fbSopenharmony_ci if (!accountData) { 712885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 713885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 714885b47fbSopenharmony_ci return; 715885b47fbSopenharmony_ci } 716885b47fbSopenharmony_ci name = accountData->GetConfig()->GetShortkeyMultiTarget(); 717885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 718885b47fbSopenharmony_ci }, "TASK_GET_SHORTKEY_MULTI_TARGET"); 719885b47fbSopenharmony_ci 720885b47fbSopenharmony_ci return syncFuture.get(); 721885b47fbSopenharmony_ci} 722885b47fbSopenharmony_ci 723885b47fbSopenharmony_ciRetError AccessibilitySettings::GetHighContrastTextState(bool &state) 724885b47fbSopenharmony_ci{ 725885b47fbSopenharmony_ci HILOG_DEBUG(); 726885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 727885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 728885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 729885b47fbSopenharmony_ci HILOG_DEBUG(); 730885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 731885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 732885b47fbSopenharmony_ci if (!accountData) { 733885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 734885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 735885b47fbSopenharmony_ci return; 736885b47fbSopenharmony_ci } 737885b47fbSopenharmony_ci state = accountData->GetConfig()->GetHighContrastTextState(); 738885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 739885b47fbSopenharmony_ci }, "TASK_GET_HIGHCONTRASTTEXT_STATE"); 740885b47fbSopenharmony_ci 741885b47fbSopenharmony_ci return syncFuture.get(); 742885b47fbSopenharmony_ci} 743885b47fbSopenharmony_ci 744885b47fbSopenharmony_ciRetError AccessibilitySettings::GetDaltonizationState(bool &state) 745885b47fbSopenharmony_ci{ 746885b47fbSopenharmony_ci HILOG_DEBUG(); 747885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 748885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 749885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 750885b47fbSopenharmony_ci HILOG_DEBUG(); 751885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 752885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 753885b47fbSopenharmony_ci if (!accountData) { 754885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 755885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 756885b47fbSopenharmony_ci return; 757885b47fbSopenharmony_ci } 758885b47fbSopenharmony_ci state = accountData->GetConfig()->GetDaltonizationState(); 759885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 760885b47fbSopenharmony_ci }, "TASK_GET_DALTONIZATIONSTATE_STATE"); 761885b47fbSopenharmony_ci 762885b47fbSopenharmony_ci return syncFuture.get(); 763885b47fbSopenharmony_ci} 764885b47fbSopenharmony_ci 765885b47fbSopenharmony_ciRetError AccessibilitySettings::GetInvertColorState(bool &state) 766885b47fbSopenharmony_ci{ 767885b47fbSopenharmony_ci HILOG_DEBUG(); 768885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 769885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 770885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 771885b47fbSopenharmony_ci HILOG_DEBUG(); 772885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 773885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 774885b47fbSopenharmony_ci if (!accountData) { 775885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 776885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 777885b47fbSopenharmony_ci return; 778885b47fbSopenharmony_ci } 779885b47fbSopenharmony_ci state = accountData->GetConfig()->GetInvertColorState(); 780885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 781885b47fbSopenharmony_ci }, "TASK_GET_INVERTCOLOR_STATE"); 782885b47fbSopenharmony_ci 783885b47fbSopenharmony_ci return syncFuture.get(); 784885b47fbSopenharmony_ci} 785885b47fbSopenharmony_ci 786885b47fbSopenharmony_ciRetError AccessibilitySettings::GetAnimationOffState(bool &state) 787885b47fbSopenharmony_ci{ 788885b47fbSopenharmony_ci HILOG_DEBUG(); 789885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 790885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 791885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 792885b47fbSopenharmony_ci HILOG_DEBUG(); 793885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 794885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 795885b47fbSopenharmony_ci if (!accountData) { 796885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 797885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 798885b47fbSopenharmony_ci return; 799885b47fbSopenharmony_ci } 800885b47fbSopenharmony_ci state = accountData->GetConfig()->GetAnimationOffState(); 801885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 802885b47fbSopenharmony_ci }, "TASK_GET_ANIMATIONOFF_STATE"); 803885b47fbSopenharmony_ci 804885b47fbSopenharmony_ci return syncFuture.get(); 805885b47fbSopenharmony_ci} 806885b47fbSopenharmony_ci 807885b47fbSopenharmony_ciRetError AccessibilitySettings::GetAudioMonoState(bool &state) 808885b47fbSopenharmony_ci{ 809885b47fbSopenharmony_ci HILOG_DEBUG(); 810885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 811885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 812885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 813885b47fbSopenharmony_ci HILOG_DEBUG(); 814885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 815885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 816885b47fbSopenharmony_ci if (!accountData) { 817885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 818885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 819885b47fbSopenharmony_ci return; 820885b47fbSopenharmony_ci } 821885b47fbSopenharmony_ci state = accountData->GetConfig()->GetAudioMonoState(); 822885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 823885b47fbSopenharmony_ci }, "TASK_GET_AUDIOMONO_STATE"); 824885b47fbSopenharmony_ci 825885b47fbSopenharmony_ci return syncFuture.get(); 826885b47fbSopenharmony_ci} 827885b47fbSopenharmony_ci 828885b47fbSopenharmony_ciRetError AccessibilitySettings::GetDaltonizationColorFilter(uint32_t &type) 829885b47fbSopenharmony_ci{ 830885b47fbSopenharmony_ci HILOG_DEBUG(); 831885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 832885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 833885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &type]() { 834885b47fbSopenharmony_ci HILOG_DEBUG(); 835885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 836885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 837885b47fbSopenharmony_ci if (!accountData) { 838885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 839885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 840885b47fbSopenharmony_ci return; 841885b47fbSopenharmony_ci } 842885b47fbSopenharmony_ci type = accountData->GetConfig()->GetDaltonizationColorFilter(); 843885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 844885b47fbSopenharmony_ci }, "TASK_GET_DALTONIZATION_COLORFILTER"); 845885b47fbSopenharmony_ci 846885b47fbSopenharmony_ci return syncFuture.get(); 847885b47fbSopenharmony_ci} 848885b47fbSopenharmony_ci 849885b47fbSopenharmony_ciRetError AccessibilitySettings::GetContentTimeout(uint32_t &timer) 850885b47fbSopenharmony_ci{ 851885b47fbSopenharmony_ci HILOG_DEBUG(); 852885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 853885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 854885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &timer]() { 855885b47fbSopenharmony_ci HILOG_DEBUG(); 856885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 857885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 858885b47fbSopenharmony_ci if (!accountData) { 859885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 860885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 861885b47fbSopenharmony_ci return; 862885b47fbSopenharmony_ci } 863885b47fbSopenharmony_ci timer = accountData->GetConfig()->GetContentTimeout(); 864885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 865885b47fbSopenharmony_ci }, "TASK_GET_CONTENT_TIMEOUT"); 866885b47fbSopenharmony_ci 867885b47fbSopenharmony_ci return syncFuture.get(); 868885b47fbSopenharmony_ci} 869885b47fbSopenharmony_ci 870885b47fbSopenharmony_ciRetError AccessibilitySettings::GetBrightnessDiscount(float &brightness) 871885b47fbSopenharmony_ci{ 872885b47fbSopenharmony_ci HILOG_DEBUG(); 873885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 874885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 875885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &brightness]() { 876885b47fbSopenharmony_ci HILOG_DEBUG(); 877885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 878885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 879885b47fbSopenharmony_ci if (!accountData) { 880885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 881885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 882885b47fbSopenharmony_ci return; 883885b47fbSopenharmony_ci } 884885b47fbSopenharmony_ci brightness = accountData->GetConfig()->GetBrightnessDiscount(); 885885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 886885b47fbSopenharmony_ci }, "TASK_GET_BRIGHTNESS_DISCOUNT"); 887885b47fbSopenharmony_ci 888885b47fbSopenharmony_ci return syncFuture.get(); 889885b47fbSopenharmony_ci} 890885b47fbSopenharmony_ci 891885b47fbSopenharmony_ciRetError AccessibilitySettings::GetAudioBalance(float &balance) 892885b47fbSopenharmony_ci{ 893885b47fbSopenharmony_ci HILOG_DEBUG(); 894885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 895885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 896885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &balance]() { 897885b47fbSopenharmony_ci HILOG_DEBUG(); 898885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 899885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 900885b47fbSopenharmony_ci if (!accountData) { 901885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 902885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 903885b47fbSopenharmony_ci return; 904885b47fbSopenharmony_ci } 905885b47fbSopenharmony_ci balance = accountData->GetConfig()->GetAudioBalance(); 906885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 907885b47fbSopenharmony_ci }, "TASK_GET_AUDIO_BALANCE"); 908885b47fbSopenharmony_ci 909885b47fbSopenharmony_ci return syncFuture.get(); 910885b47fbSopenharmony_ci} 911885b47fbSopenharmony_ci 912885b47fbSopenharmony_ciRetError AccessibilitySettings::GetClickResponseTime(uint32_t &time) 913885b47fbSopenharmony_ci{ 914885b47fbSopenharmony_ci HILOG_DEBUG(); 915885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 916885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 917885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &time]() { 918885b47fbSopenharmony_ci HILOG_DEBUG(); 919885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 920885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 921885b47fbSopenharmony_ci if (!accountData) { 922885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 923885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 924885b47fbSopenharmony_ci return; 925885b47fbSopenharmony_ci } 926885b47fbSopenharmony_ci time = accountData->GetConfig()->GetClickResponseTime(); 927885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 928885b47fbSopenharmony_ci }, "TASK_GET_CLICK_RESPONSE_TIME"); 929885b47fbSopenharmony_ci 930885b47fbSopenharmony_ci return syncFuture.get(); 931885b47fbSopenharmony_ci} 932885b47fbSopenharmony_ci 933885b47fbSopenharmony_ciRetError AccessibilitySettings::GetIgnoreRepeatClickState(bool &state) 934885b47fbSopenharmony_ci{ 935885b47fbSopenharmony_ci HILOG_DEBUG(); 936885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 937885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 938885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 939885b47fbSopenharmony_ci HILOG_DEBUG(); 940885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 941885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 942885b47fbSopenharmony_ci if (!accountData) { 943885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 944885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 945885b47fbSopenharmony_ci return; 946885b47fbSopenharmony_ci } 947885b47fbSopenharmony_ci state = accountData->GetConfig()->GetIgnoreRepeatClickState(); 948885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 949885b47fbSopenharmony_ci }, "TASK_GET_IGNORE_REPEAT_CLICK_STATE"); 950885b47fbSopenharmony_ci 951885b47fbSopenharmony_ci return syncFuture.get(); 952885b47fbSopenharmony_ci} 953885b47fbSopenharmony_ci 954885b47fbSopenharmony_ciRetError AccessibilitySettings::GetIgnoreRepeatClickTime(uint32_t &time) 955885b47fbSopenharmony_ci{ 956885b47fbSopenharmony_ci HILOG_DEBUG(); 957885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 958885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 959885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &time]() { 960885b47fbSopenharmony_ci HILOG_DEBUG(); 961885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 962885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 963885b47fbSopenharmony_ci if (!accountData) { 964885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 965885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 966885b47fbSopenharmony_ci return; 967885b47fbSopenharmony_ci } 968885b47fbSopenharmony_ci time = accountData->GetConfig()->GetIgnoreRepeatClickTime(); 969885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 970885b47fbSopenharmony_ci }, "TASK_GET_IGNORE_REPEAT_CLICK_TIME"); 971885b47fbSopenharmony_ci 972885b47fbSopenharmony_ci return syncFuture.get(); 973885b47fbSopenharmony_ci} 974885b47fbSopenharmony_ci 975885b47fbSopenharmony_civoid AccessibilitySettings::UpdateConfigState() 976885b47fbSopenharmony_ci{ 977885b47fbSopenharmony_ci handler_->PostTask([this]() { 978885b47fbSopenharmony_ci HILOG_INFO("UpdateConfigState."); 979885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 980885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 981885b47fbSopenharmony_ci if (!accountData) { 982885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 983885b47fbSopenharmony_ci return; 984885b47fbSopenharmony_ci } 985885b47fbSopenharmony_ci 986885b47fbSopenharmony_ci uint32_t state = accountData->GetConfig()->GetConfigState(); 987885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 988885b47fbSopenharmony_ci if (callback) { 989885b47fbSopenharmony_ci callback->OnConfigStateChanged(state); 990885b47fbSopenharmony_ci } 991885b47fbSopenharmony_ci } 992885b47fbSopenharmony_ci }, "UpdateConfigState"); 993885b47fbSopenharmony_ci} 994885b47fbSopenharmony_ci 995885b47fbSopenharmony_civoid AccessibilitySettings::UpdateAudioBalance() 996885b47fbSopenharmony_ci{ 997885b47fbSopenharmony_ci handler_->PostTask([this]() { 998885b47fbSopenharmony_ci HILOG_INFO("UpdateAudioBalance."); 999885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1000885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1001885b47fbSopenharmony_ci if (!accountData) { 1002885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1003885b47fbSopenharmony_ci return; 1004885b47fbSopenharmony_ci } 1005885b47fbSopenharmony_ci 1006885b47fbSopenharmony_ci float audioBalance = accountData->GetConfig()->GetAudioBalance(); 1007885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1008885b47fbSopenharmony_ci if (callback) { 1009885b47fbSopenharmony_ci callback->OnAudioBalanceChanged(audioBalance); 1010885b47fbSopenharmony_ci } 1011885b47fbSopenharmony_ci } 1012885b47fbSopenharmony_ci }, "UpdateAudioBalance"); 1013885b47fbSopenharmony_ci} 1014885b47fbSopenharmony_ci 1015885b47fbSopenharmony_civoid AccessibilitySettings::UpdateBrightnessDiscount() 1016885b47fbSopenharmony_ci{ 1017885b47fbSopenharmony_ci handler_->PostTask([this]() { 1018885b47fbSopenharmony_ci HILOG_INFO("UpdateBrightnessDiscount."); 1019885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1020885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1021885b47fbSopenharmony_ci if (!accountData) { 1022885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1023885b47fbSopenharmony_ci return; 1024885b47fbSopenharmony_ci } 1025885b47fbSopenharmony_ci 1026885b47fbSopenharmony_ci float brightnessDiscount = accountData->GetConfig()->GetBrightnessDiscount(); 1027885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1028885b47fbSopenharmony_ci if (callback) { 1029885b47fbSopenharmony_ci callback->OnBrightnessDiscountChanged(brightnessDiscount); 1030885b47fbSopenharmony_ci } 1031885b47fbSopenharmony_ci } 1032885b47fbSopenharmony_ci }, "UpdateBrightnessDiscount"); 1033885b47fbSopenharmony_ci} 1034885b47fbSopenharmony_ci 1035885b47fbSopenharmony_civoid AccessibilitySettings::UpdateContentTimeout() 1036885b47fbSopenharmony_ci{ 1037885b47fbSopenharmony_ci handler_->PostTask([this]() { 1038885b47fbSopenharmony_ci HILOG_INFO("UpdateContentTimeout."); 1039885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1040885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1041885b47fbSopenharmony_ci if (!accountData) { 1042885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1043885b47fbSopenharmony_ci return; 1044885b47fbSopenharmony_ci } 1045885b47fbSopenharmony_ci 1046885b47fbSopenharmony_ci uint32_t contentTimeout = accountData->GetConfig()->GetContentTimeout(); 1047885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1048885b47fbSopenharmony_ci if (callback) { 1049885b47fbSopenharmony_ci callback->OnContentTimeoutChanged(contentTimeout); 1050885b47fbSopenharmony_ci } 1051885b47fbSopenharmony_ci } 1052885b47fbSopenharmony_ci }, "UpdateContentTimeout"); 1053885b47fbSopenharmony_ci} 1054885b47fbSopenharmony_ci 1055885b47fbSopenharmony_civoid AccessibilitySettings::UpdateDaltonizationColorFilter() 1056885b47fbSopenharmony_ci{ 1057885b47fbSopenharmony_ci handler_->PostTask([this]() { 1058885b47fbSopenharmony_ci HILOG_INFO("UpdateDaltonizationColorFilter."); 1059885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1060885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1061885b47fbSopenharmony_ci if (!accountData) { 1062885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1063885b47fbSopenharmony_ci return; 1064885b47fbSopenharmony_ci } 1065885b47fbSopenharmony_ci 1066885b47fbSopenharmony_ci uint32_t daltonizationColorFilter = accountData->GetConfig()->GetDaltonizationColorFilter(); 1067885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1068885b47fbSopenharmony_ci if (callback) { 1069885b47fbSopenharmony_ci callback->OnDaltonizationColorFilterChanged(daltonizationColorFilter); 1070885b47fbSopenharmony_ci } 1071885b47fbSopenharmony_ci } 1072885b47fbSopenharmony_ci }, "UpdateDaltonizationColorFilter"); 1073885b47fbSopenharmony_ci} 1074885b47fbSopenharmony_ci 1075885b47fbSopenharmony_civoid AccessibilitySettings::UpdateMouseAutoClick() 1076885b47fbSopenharmony_ci{ 1077885b47fbSopenharmony_ci handler_->PostTask([this]() { 1078885b47fbSopenharmony_ci HILOG_INFO("UpdateMouseAutoClick."); 1079885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1080885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1081885b47fbSopenharmony_ci if (!accountData) { 1082885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1083885b47fbSopenharmony_ci return; 1084885b47fbSopenharmony_ci } 1085885b47fbSopenharmony_ci 1086885b47fbSopenharmony_ci int32_t mouseAutoClick = accountData->GetConfig()->GetMouseAutoClick(); 1087885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1088885b47fbSopenharmony_ci if (callback) { 1089885b47fbSopenharmony_ci callback->OnMouseAutoClickChanged(mouseAutoClick); 1090885b47fbSopenharmony_ci } 1091885b47fbSopenharmony_ci } 1092885b47fbSopenharmony_ci }, "UpdateMouseAutoClick"); 1093885b47fbSopenharmony_ci} 1094885b47fbSopenharmony_ci 1095885b47fbSopenharmony_civoid AccessibilitySettings::UpdateShortkeyTarget() 1096885b47fbSopenharmony_ci{ 1097885b47fbSopenharmony_ci handler_->PostTask([this]() { 1098885b47fbSopenharmony_ci HILOG_INFO("UpdateShortkeyTarget."); 1099885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1100885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1101885b47fbSopenharmony_ci if (!accountData) { 1102885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1103885b47fbSopenharmony_ci return; 1104885b47fbSopenharmony_ci } 1105885b47fbSopenharmony_ci 1106885b47fbSopenharmony_ci std::string shortkeyTarget = accountData->GetConfig()->GetShortkeyTarget(); 1107885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1108885b47fbSopenharmony_ci if (callback) { 1109885b47fbSopenharmony_ci callback->OnShortkeyTargetChanged(shortkeyTarget); 1110885b47fbSopenharmony_ci } 1111885b47fbSopenharmony_ci } 1112885b47fbSopenharmony_ci }, "UpdateShortkeyTarget"); 1113885b47fbSopenharmony_ci} 1114885b47fbSopenharmony_ci 1115885b47fbSopenharmony_civoid AccessibilitySettings::UpdateShortkeyMultiTarget() 1116885b47fbSopenharmony_ci{ 1117885b47fbSopenharmony_ci handler_->PostTask([this]() { 1118885b47fbSopenharmony_ci HILOG_INFO("UpdateShortkeyMultiTarget."); 1119885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1120885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1121885b47fbSopenharmony_ci if (!accountData) { 1122885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1123885b47fbSopenharmony_ci return; 1124885b47fbSopenharmony_ci } 1125885b47fbSopenharmony_ci 1126885b47fbSopenharmony_ci std::vector<std::string> shortkeyMultiTarget = accountData->GetConfig()->GetShortkeyMultiTarget(); 1127885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1128885b47fbSopenharmony_ci if (callback) { 1129885b47fbSopenharmony_ci callback->OnShortkeyMultiTargetChanged(shortkeyMultiTarget); 1130885b47fbSopenharmony_ci } 1131885b47fbSopenharmony_ci } 1132885b47fbSopenharmony_ci }, "UpdateShortkeyMultiTarget"); 1133885b47fbSopenharmony_ci} 1134885b47fbSopenharmony_ci 1135885b47fbSopenharmony_civoid AccessibilitySettings::UpdateClickResponseTime() 1136885b47fbSopenharmony_ci{ 1137885b47fbSopenharmony_ci handler_->PostTask([this]() { 1138885b47fbSopenharmony_ci HILOG_INFO("UpdateClickResponseTime."); 1139885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1140885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1141885b47fbSopenharmony_ci if (!accountData) { 1142885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1143885b47fbSopenharmony_ci return; 1144885b47fbSopenharmony_ci } 1145885b47fbSopenharmony_ci 1146885b47fbSopenharmony_ci uint32_t time = accountData->GetConfig()->GetClickResponseTime(); 1147885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1148885b47fbSopenharmony_ci if (callback) { 1149885b47fbSopenharmony_ci callback->OnClickResponseTimeChanged(time); 1150885b47fbSopenharmony_ci } 1151885b47fbSopenharmony_ci } 1152885b47fbSopenharmony_ci }, "UpdateClickResponseTime"); 1153885b47fbSopenharmony_ci} 1154885b47fbSopenharmony_ci 1155885b47fbSopenharmony_civoid AccessibilitySettings::UpdateIgnoreRepeatClickTime() 1156885b47fbSopenharmony_ci{ 1157885b47fbSopenharmony_ci handler_->PostTask([this]() { 1158885b47fbSopenharmony_ci HILOG_INFO("UpdateIgnoreRepeatClickTime."); 1159885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1160885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1161885b47fbSopenharmony_ci if (!accountData) { 1162885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1163885b47fbSopenharmony_ci return; 1164885b47fbSopenharmony_ci } 1165885b47fbSopenharmony_ci 1166885b47fbSopenharmony_ci uint32_t time = accountData->GetConfig()->GetIgnoreRepeatClickTime(); 1167885b47fbSopenharmony_ci for (auto &callback : accountData->GetConfigCallbacks()) { 1168885b47fbSopenharmony_ci if (callback) { 1169885b47fbSopenharmony_ci callback->OnIgnoreRepeatClickTimeChanged(time); 1170885b47fbSopenharmony_ci } 1171885b47fbSopenharmony_ci } 1172885b47fbSopenharmony_ci }, "UpdateIgnoreRepeatClickTime"); 1173885b47fbSopenharmony_ci} 1174885b47fbSopenharmony_ci 1175885b47fbSopenharmony_ciRetError AccessibilitySettings::GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) 1176885b47fbSopenharmony_ci{ 1177885b47fbSopenharmony_ci HILOG_DEBUG(); 1178885b47fbSopenharmony_ci if (!handler_) { 1179885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 1180885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 1181885b47fbSopenharmony_ci } 1182885b47fbSopenharmony_ci 1183885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 1184885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 1185885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &caption]() { 1186885b47fbSopenharmony_ci HILOG_DEBUG(); 1187885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1188885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1189885b47fbSopenharmony_ci if (!accountData) { 1190885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 1191885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 1192885b47fbSopenharmony_ci return; 1193885b47fbSopenharmony_ci } 1194885b47fbSopenharmony_ci caption = accountData->GetConfig()->GetCaptionProperty(); 1195885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 1196885b47fbSopenharmony_ci }, "TASK_GET_CAPTION_PROPERTY"); 1197885b47fbSopenharmony_ci return syncFuture.get(); 1198885b47fbSopenharmony_ci} 1199885b47fbSopenharmony_ci 1200885b47fbSopenharmony_ciRetError AccessibilitySettings::SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) 1201885b47fbSopenharmony_ci{ 1202885b47fbSopenharmony_ci HILOG_DEBUG(); 1203885b47fbSopenharmony_ci if (!handler_) { 1204885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 1205885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 1206885b47fbSopenharmony_ci } 1207885b47fbSopenharmony_ci 1208885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 1209885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 1210885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &caption]() { 1211885b47fbSopenharmony_ci HILOG_DEBUG(); 1212885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1213885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1214885b47fbSopenharmony_ci if (!accountData) { 1215885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 1216885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 1217885b47fbSopenharmony_ci return; 1218885b47fbSopenharmony_ci } 1219885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetCaptionProperty(caption); 1220885b47fbSopenharmony_ci syncPromise.set_value(ret); 1221885b47fbSopenharmony_ci UpdateCaptionProperty(); 1222885b47fbSopenharmony_ci }, "TASK_SET_CAPTION_PROPERTY"); 1223885b47fbSopenharmony_ci return syncFuture.get(); 1224885b47fbSopenharmony_ci} 1225885b47fbSopenharmony_ci 1226885b47fbSopenharmony_ciRetError AccessibilitySettings::SetCaptionState(const bool state) 1227885b47fbSopenharmony_ci{ 1228885b47fbSopenharmony_ci HILOG_DEBUG(); 1229885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1230885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1231885b47fbSopenharmony_ci if (!accountData) { 1232885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr."); 1233885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 1234885b47fbSopenharmony_ci } 1235885b47fbSopenharmony_ci RetError ret = accountData->GetConfig()->SetCaptionState(state); 1236885b47fbSopenharmony_ci UpdateConfigState(); 1237885b47fbSopenharmony_ci return ret; 1238885b47fbSopenharmony_ci} 1239885b47fbSopenharmony_ci 1240885b47fbSopenharmony_ciRetError AccessibilitySettings::GetCaptionState(bool &state) 1241885b47fbSopenharmony_ci{ 1242885b47fbSopenharmony_ci HILOG_DEBUG(); 1243885b47fbSopenharmony_ci if (!handler_) { 1244885b47fbSopenharmony_ci HILOG_ERROR("handler_ is nullptr."); 1245885b47fbSopenharmony_ci return RET_ERR_NULLPTR; 1246885b47fbSopenharmony_ci } 1247885b47fbSopenharmony_ci 1248885b47fbSopenharmony_ci ffrt::promise<RetError> syncPromise; 1249885b47fbSopenharmony_ci ffrt::future syncFuture = syncPromise.get_future(); 1250885b47fbSopenharmony_ci handler_->PostTask([this, &syncPromise, &state]() { 1251885b47fbSopenharmony_ci HILOG_DEBUG(); 1252885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1253885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1254885b47fbSopenharmony_ci if (!accountData) { 1255885b47fbSopenharmony_ci HILOG_ERROR("accountData is nullptr"); 1256885b47fbSopenharmony_ci syncPromise.set_value(RET_ERR_NULLPTR); 1257885b47fbSopenharmony_ci return; 1258885b47fbSopenharmony_ci } 1259885b47fbSopenharmony_ci state = accountData->GetConfig()->GetCaptionState(); 1260885b47fbSopenharmony_ci syncPromise.set_value(RET_OK); 1261885b47fbSopenharmony_ci }, "TASK_GET_CAPTION_STATE"); 1262885b47fbSopenharmony_ci return syncFuture.get(); 1263885b47fbSopenharmony_ci} 1264885b47fbSopenharmony_ci 1265885b47fbSopenharmony_civoid AccessibilitySettings::UpdateCaptionProperty() 1266885b47fbSopenharmony_ci{ 1267885b47fbSopenharmony_ci handler_->PostTask([this]() { 1268885b47fbSopenharmony_ci HILOG_DEBUG("UpdateCaptionProperty."); 1269885b47fbSopenharmony_ci sptr<AccessibilityAccountData> accountData = 1270885b47fbSopenharmony_ci Singleton<AccessibleAbilityManagerService>::GetInstance().GetCurrentAccountData(); 1271885b47fbSopenharmony_ci if (!accountData) { 1272885b47fbSopenharmony_ci HILOG_ERROR("Account data is null"); 1273885b47fbSopenharmony_ci return; 1274885b47fbSopenharmony_ci } 1275885b47fbSopenharmony_ci 1276885b47fbSopenharmony_ci AccessibilityConfig::CaptionProperty caption = accountData->GetConfig()->GetCaptionProperty(); 1277885b47fbSopenharmony_ci for (auto &callback : accountData->GetCaptionPropertyCallbacks()) { 1278885b47fbSopenharmony_ci if (callback) { 1279885b47fbSopenharmony_ci callback->OnPropertyChanged(caption); 1280885b47fbSopenharmony_ci } 1281885b47fbSopenharmony_ci } 1282885b47fbSopenharmony_ci }, "UpdateCaptionProperty"); 1283885b47fbSopenharmony_ci} 1284885b47fbSopenharmony_ci 1285885b47fbSopenharmony_civoid AccessibilitySettings::UpdateAllSetting() 1286885b47fbSopenharmony_ci{ 1287885b47fbSopenharmony_ci HILOG_DEBUG(); 1288885b47fbSopenharmony_ci if (!handler_) { 1289885b47fbSopenharmony_ci HILOG_ERROR("UpdateAllSetting: handler is nullptr!"); 1290885b47fbSopenharmony_ci return; 1291885b47fbSopenharmony_ci } 1292885b47fbSopenharmony_ci handler_->PostTask([this]() { 1293885b47fbSopenharmony_ci UpdateConfigState(); 1294885b47fbSopenharmony_ci UpdateShortkeyTarget(); 1295885b47fbSopenharmony_ci UpdateShortkeyMultiTarget(); 1296885b47fbSopenharmony_ci UpdateMouseAutoClick(); 1297885b47fbSopenharmony_ci UpdateDaltonizationColorFilter(); 1298885b47fbSopenharmony_ci UpdateContentTimeout(); 1299885b47fbSopenharmony_ci UpdateBrightnessDiscount(); 1300885b47fbSopenharmony_ci UpdateAudioBalance(); 1301885b47fbSopenharmony_ci UpdateClickResponseTime(); 1302885b47fbSopenharmony_ci UpdateIgnoreRepeatClickTime(); 1303885b47fbSopenharmony_ci }, "UPDATE_ALL_SETTING"); 1304885b47fbSopenharmony_ci} 1305885b47fbSopenharmony_ci} // namespace Accessibility 1306885b47fbSopenharmony_ci} // namespace OHOS