description

Signed-off-by: 小发发 <lianghui35@huawei.com>
This commit is contained in:
小发发 2024-11-15 16:50:06 +08:00
parent 641ff87923
commit 33bbbc6bc9
7 changed files with 62 additions and 32 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;
@ -95,6 +95,7 @@ public:
RetError RemoveEnabledAccessibilityService(const std::string &serviceName);
uint32_t GetConfigState();
bool GetStartFromAtoHosState();
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)
@ -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

@ -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;
@ -419,7 +419,7 @@ 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;

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;
@ -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;