!1539 更改辅助功能快捷键规格

Merge pull request !1539 from 小发发/accessibility_241115
This commit is contained in:
openharmony_ci 2024-11-18 02:17:05 +00:00 committed by Gitee
commit fb28c92db2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 73 additions and 37 deletions

View File

@ -1847,14 +1847,14 @@ HWTEST_F(AccessibilitySettingsConfigTest, Unittest_SetShortkeyMultiTargetInPkgRe
/**
* @tc.number: ManagerServiceStub_Test_075
* @tc.name: SetStartFromAtoHosState
* @tc.name: SetStartToHosState
* @tc.desc: Test function SetScreenMagnificationState GetScreenMagnificationState
*/
HWTEST_F(AccessibilitySettingsConfigTest, ManagerServiceStub_Test_075, TestSize.Level1)
{
GTEST_LOG_(INFO) << "ManagerServiceStub_Test_075 start";
bool state = true;
int32_t ret = settingConfig_->SetStartFromAtoHosState(state);
int32_t ret = settingConfig_->SetStartToHosState(state);
EXPECT_EQ(ret, RET_ERR_NULLPTR);
GTEST_LOG_(INFO) << "ManagerServiceStub_Test_075 end";
}

View File

@ -59,7 +59,7 @@ public:
RetError SetClickResponseTime(const uint32_t time);
RetError SetIgnoreRepeatClickState(const bool state);
RetError SetIgnoreRepeatClickTime(const uint32_t time);
RetError SetStartFromAtoHosState(const bool state);
RetError SetStartToHosState(const bool state);
bool GetEnabledState() const;
bool GetTouchGuideState() const;
@ -94,7 +94,8 @@ public:
RetError AddEnabledAccessibilityService(const std::string &serviceName);
RetError RemoveEnabledAccessibilityService(const std::string &serviceName);
uint32_t GetConfigState();
bool GetStartFromAtoHosState();
bool GetStartToHosState();
void SetDefaultShortcutKeyService();
void InitSetting();
void CloneShortkeyService(bool isScreenReaderEnabled);
void OnDataClone();

View File

@ -570,8 +570,9 @@ void AccessibilitySettings::UpdateSettingsInAtoHos()
accountData->EnableAbility(SCREEN_READER_BUNDLE_ABILITY_NAME, capabilities);
}
accountData->GetConfig()->CloneShortkeyService(atoHosValue.isScreenReaderEnabled);
accountData->GetConfig()->SetDefaultShortcutKeyService();
accountData->GetConfig()->SetStartFromAtoHosState(false);
accountData->GetConfig()->SetStartToHosState(false);
}
RetError AccessibilitySettings::GetScreenMagnificationState(bool &state)

View File

@ -18,6 +18,7 @@
#include "system_ability_definition.h"
#include "utils.h"
#include "accessibility_setting_provider.h"
#include "accessible_ability_manager_service.h"
namespace OHOS {
namespace Accessibility {
@ -202,14 +203,14 @@ RetError AccessibilitySettingsConfig::SetShortKeyTimeout(const int32_t time)
return ret;
}
RetError AccessibilitySettingsConfig::SetStartFromAtoHosState(const bool state)
RetError AccessibilitySettingsConfig::SetStartToHosState(const bool state)
{
HILOG_DEBUG("state = [%{public}s]", state ? "True" : "False");
if (!datashare_) {
HILOG_ERROR("helper is nullptr");
return RET_ERR_NULLPTR;
}
return datashare_->PutBoolValue("AccessibilityStartFromAtoHos", state);
return datashare_->PutBoolValue("AccessibilityStartToHos", state);
}
RetError AccessibilitySettingsConfig::SetMouseKeyState(const bool state)
@ -722,7 +723,7 @@ RetError AccessibilitySettingsConfig::RemoveEnabledAccessibilityService(const st
return datashare_->PutStringValue(ENABLED_ACCESSIBILITY_SERVICES, stringOut);
}
bool AccessibilitySettingsConfig::GetStartFromAtoHosState()
bool AccessibilitySettingsConfig::GetStartToHosState()
{
HILOG_DEBUG();
if (!datashare_) {
@ -730,7 +731,7 @@ bool AccessibilitySettingsConfig::GetStartFromAtoHosState()
}
bool value = true;
value = datashare_->GetBoolValue("AccessibilityStartFromAtoHos", true);
value = datashare_->GetBoolValue("AccessibilityStartToHos", true);
return value;
}
@ -833,6 +834,20 @@ void AccessibilitySettingsConfig::InitShortKeyConfig()
SetShortKeyTimeout(SHORT_KEY_TIMEOUT_BEFORE_USE);
}
shortkeyTarget_ = datashare_->GetStringValue("ShortkeyTarget", "none");
std::string tmpString = datashare_->GetStringValue(SHORTCUT_SERVICE, SCREEN_READER_BUNDLE_ABILITY_NAME);
shortkeyMultiTarget_ = {};
Utils::StringToVector(tmpString, shortkeyMultiTarget_);
bool isScreenReaderEnabledOriginal =
(std::find(enabledAccessibilityServices_.begin(), enabledAccessibilityServices_.end(),
SCREEN_READER_BUNDLE_ABILITY_NAME) != enabledAccessibilityServices_.end());
tmpString = datashare_->GetStringValue(ENABLED_ACCESSIBILITY_SERVICES, "");
enabledAccessibilityServices_ = {};
Utils::StringToVector(tmpString, enabledAccessibilityServices_);
CloneShortkeyService(isScreenReaderEnabledOriginal);
// Initialization of the private space after cloning or upgrade
std::shared_ptr<AccessibilitySettingProvider> service = AccessibilitySettingProvider::GetInstance(
POWER_MANAGER_SERVICE_ID);
@ -848,6 +863,7 @@ void AccessibilitySettingsConfig::InitShortKeyConfig()
} else {
SetShortKeyOnLockScreenState(false);
}
SetDefaultShortcutKeyService();
service->PutBoolValue(ACCESSIBILITY_PRIVACY_CLONE_OR_UPGRADE, false);
}
}
@ -869,21 +885,6 @@ void AccessibilitySettingsConfig::InitSetting()
daltonizationState_ = datashare_->GetBoolValue(DALTONIZATION_STATE, false);
audioMonoState_ = datashare_->GetBoolValue(AUDIO_MONO_KEY, false);
ignoreRepeatClickState_ = datashare_->GetBoolValue(IGNORE_REPEAT_CLICK_SWITCH, false);
shortkeyTarget_ = datashare_->GetStringValue("ShortkeyTarget", "none");
std::string tmpString = datashare_->GetStringValue(SHORTCUT_SERVICE, SCREEN_READER_BUNDLE_ABILITY_NAME);
shortkeyMultiTarget_ = {};
Utils::StringToVector(tmpString, shortkeyMultiTarget_);
bool isScreenReaderEnabledOriginal =
(std::find(enabledAccessibilityServices_.begin(), enabledAccessibilityServices_.end(),
SCREEN_READER_BUNDLE_ABILITY_NAME) != enabledAccessibilityServices_.end());
tmpString = datashare_->GetStringValue(ENABLED_ACCESSIBILITY_SERVICES, "");
enabledAccessibilityServices_ = {};
Utils::StringToVector(tmpString, enabledAccessibilityServices_);
CloneShortkeyService(isScreenReaderEnabledOriginal);
mouseAutoClick_ = static_cast<int32_t>(datashare_->GetIntValue("MouseAutoClick", -1));
daltonizationColorFilter_ = static_cast<uint32_t>(datashare_->GetIntValue(DALTONIZATION_COLOR_FILTER_KEY, 0));
SetDaltonizationColorFilter(daltonizationColorFilter_);
@ -1026,10 +1027,27 @@ void AccessibilitySettingsConfig::CloneShortkeyService(bool isScreenReaderEnable
SetEnabledAccessibilityServices(enabledShortkeyService);
}
void AccessibilitySettingsConfig::SetDefaultShortcutKeyService()
{
HILOG_DEBUG();
if (GetShortkeyMultiTarget().empty()) {
HILOG_INFO("set default shortcut key service.");
std::vector<std::string> defaultService;
defaultService.push_back(SCREEN_READER_BUNDLE_ABILITY_NAME);
SetShortkeyMultiTarget(defaultService);
}
}
void AccessibilitySettingsConfig::OnDataClone()
{
HILOG_INFO();
bool isShortkeyEnabled = GetShortKeyState();
bool isShortkeyEnabledOnLockScreen = GetShortKeyOnLockScreenState();
InitSetting();
SetDefaultShortcutKeyService();
if (isShortKeyState_) {
SetShortKeyOnLockScreenState(true);
@ -1037,6 +1055,16 @@ void AccessibilitySettingsConfig::OnDataClone()
SetShortKeyOnLockScreenState(false);
}
if (isShortkeyEnabled != GetShortKeyState()) {
SetShortKeyState(isShortkeyEnabled);
SetShortKeyState(!isShortkeyEnabled);
}
if (isShortkeyEnabledOnLockScreen != GetShortKeyOnLockScreenState()) {
SetShortKeyOnLockScreenState(isShortkeyEnabledOnLockScreen);
SetShortKeyOnLockScreenState(!isShortkeyEnabledOnLockScreen);
}
Singleton<AccessibleAbilityManagerService>::GetInstance().UpdateShortKeyRegister();
std::shared_ptr<AccessibilitySettingProvider> service =
AccessibilitySettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID);
if (service == nullptr) {

View File

@ -2107,7 +2107,7 @@ void AccessibleAbilityManagerService::UpdateSettingsInAtoHos()
return;
}
if (!accountData->GetConfig()->GetStartFromAtoHosState() || currentAccountId_ != DEFAULT_ACCOUNT_ID) {
if (!accountData->GetConfig()->GetStartToHosState() || currentAccountId_ != DEFAULT_ACCOUNT_ID) {
HILOG_INFO("Not first start from a to hos.");
return;
}

View File

@ -191,7 +191,7 @@ RetError AccessibilitySettingsConfig::SetBrightnessDiscount(const float discount
return RET_OK;
}
RetError SetStartFromAtoHosState(const bool state)
RetError SetStartToHosState(const bool state)
{
HILOG_DEBUG("start.");
(void)state;
@ -375,7 +375,7 @@ uint32_t AccessibilitySettingsConfig::GetConfigState()
return state;
}
bool AccessibilitySettingsConfig::GetStartFromAtoHosState()
bool AccessibilitySettingsConfig::GetStartToHosState()
{
return true;
}
@ -419,12 +419,18 @@ RetError AccessibilitySettingsConfig::SetIgnoreRepeatClickTime(const uint32_t ti
return RET_OK;
}
RetError AccessibilitySettingsConfig::SetStartFromAtoHosState(const bool state)
RetError AccessibilitySettingsConfig::SetStartToHosState(const bool state)
{
HILOG_DEBUG("start.");
return RET_OK;
}
void AccessibilitySettingsConfig::SetDefaultShortcutKeyService()
{
HILOG_DEBUG("start.");
return;
}
RetError AccessibilitySettingsConfig::SetClickResponseTime(const uint32_t time)
{
HILOG_DEBUG("start.");

View File

@ -902,18 +902,18 @@ HWTEST_F(AccessibilitySettingsConfigTest, Unittest_SetShortkeyMultiTargetInPkgRe
}
/**
* @tc.number: AccessibilitySettingsConfig_Unittest_SetStartFromAtoHosState_001
* @tc.name: SetStartFromAtoHosState
* @tc.number: AccessibilitySettingsConfig_Unittest_SetStartToHosState_001
* @tc.name: SetStartToHosState
* @tc.desc: Test function SetScreenMagnificationState GetScreenMagnificationState
*/
HWTEST_F(AccessibilitySettingsConfigTest,
AccessibilitySettingsConfig_Unittest_SetStartFromAtoHosState_001, TestSize.Level1)
AccessibilitySettingsConfig_Unittest_SetStartToHosState_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AccessibilitySettingsConfig_Unittest_SetStartFromAtoHosState_001 start";
GTEST_LOG_(INFO) << "AccessibilitySettingsConfig_Unittest_SetStartToHosState_001 start";
bool state = true;
int32_t ret = settingConfig_->SetStartFromAtoHosState(state);
int32_t ret = settingConfig_->SetStartToHosState(state);
EXPECT_EQ(ret, RET_ERR_NULLPTR);
GTEST_LOG_(INFO) << "AccessibilitySettingsConfig_Unittest_SetStartFromAtoHosState_001 end";
GTEST_LOG_(INFO) << "AccessibilitySettingsConfig_Unittest_SetStartToHosState_001 end";
}
/**

View File

@ -191,7 +191,7 @@ RetError MockAccessibilitySettingsConfig::SetBrightnessDiscount(const float disc
return RET_OK;
}
RetError SetStartFromAtoHosState(const bool state)
RetError SetStartToHosState(const bool state)
{
HILOG_DEBUG("start.");
(void)state;
@ -375,7 +375,7 @@ uint32_t MockAccessibilitySettingsConfig::GetConfigState()
return state;
}
bool MockAccessibilitySettingsConfig::GetStartFromAtoHosState()
bool MockAccessibilitySettingsConfig::GetStartToHosState()
{
return true;
}
@ -419,7 +419,7 @@ RetError MockAccessibilitySettingsConfig::SetIgnoreRepeatClickTime(const uint32_
return RET_OK;
}
RetError MockAccessibilitySettingsConfig::SetStartFromAtoHosState(const bool state)
RetError MockAccessibilitySettingsConfig::SetStartToHosState(const bool state)
{
HILOG_DEBUG("start.");
return RET_OK;