description

Signed-off-by: 小发发 <lianghui35@huawei.com>
This commit is contained in:
小发发 2024-11-13 16:13:40 +08:00
parent f7ee3ea16d
commit 7cae7b5be7
5 changed files with 44 additions and 47 deletions

View File

@ -50,8 +50,7 @@ struct ConfigValueAtoHosUpdate {
int ignoreRepeatClickTime = 0;
int displayDaltonizer = 0;
bool shortcutEnabled = false;
int shortcutEnabledOnLockScreen = 0;
int shortcutOnLockScreen = 0;
bool shortcutEnabledOnLockScreen = false;
int shortcutTimeout = 0;
bool screenMagnificationState = false;
};

View File

@ -95,6 +95,7 @@ public:
RetError RemoveEnabledAccessibilityService(const std::string &serviceName);
uint32_t GetConfigState();
bool GetStartFromAtoHosState();
void InitSetting();
void CloneShortkeyService(bool isScreenReaderEnabled);
void OnDataClone();
void CloneAudioState();
@ -109,7 +110,6 @@ public:
void ClearData();
private:
void InitCaption();
void InitSetting();
void InitCapability();
RetError SetConfigState(const std::string& key, bool value);

View File

@ -38,7 +38,6 @@ namespace {
constexpr int DEFAULT_ACCOUNT_ID = 100;
constexpr int SHORT_KEY_TIMEOUT_AFTER_USE = 1000; // ms
constexpr int SHORT_KEY_TIMEOUT_BEFORE_USE = 3000; // ms
constexpr int INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE = 2;
const std::string HIGH_TEXT_CONTRAST_ENABLED = "high_text_contrast_enabled";
const std::string ACCESSIBILITY_DISPLAY_INVERSION_ENABLED = "accessibility_display_inversion_enabled";
const std::string ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED = "accessibility_display_daltonizer_enabled";
@ -54,11 +53,11 @@ namespace {
const std::string ENABLED_ACCESSIBILITY_SERVICES = "enabled_accessibility_services";
const std::string ACCESSIBILITY_SHORTCUT_ENABLED = "accessibility_shortcut_enabled";
const std::string ACCESSIBILITY_SHORTCUT_ENABLED_ON_LOCK_SCREEN = "accessibility_shortcut_enabled_on_lock_screen";
const std::string ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN = "accessibility_shortcut_on_lock_screen";
const std::string ACCESSIBILITY_SHORTCUT_TIMEOUT = "accessibility_shortcut_timeout";
const std::string SCREEN_MAGNIFICATION_KEY = "accessibility_display_magnification_enabled";
const std::string ACCESSIBILITY_CLONE_FLAG = "accessibility_config_clone";
const std::string ACCESSIBILITY_TOUCH_GUIDE_ENABLED = "enableTouchGuideMode";
const std::string ACCESSIBILITY_PRIVACY_CLONE_OR_UPGRADE = "accessibility_privacy_clone_or_upgrade";
} // namespace
AccessibilityAccountData::AccessibilityAccountData(int32_t accountId)
@ -584,12 +583,9 @@ void AccessibilityAccountData::GetConfigValueAtoHos(ConfigValueAtoHosUpdate &val
value.invertColor = config_->GetDbHandle()->GetBoolValue(ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, false);
value.daltonizationState = config_->GetDbHandle()->GetBoolValue(ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, false);
value.displayDaltonizer = config_->GetDbHandle()->GetIntValue(ACCESSIBILITY_DISPLAY_DALTONIZER, 0);
value.shortcutEnabled = config_->GetDbHandle()->GetBoolValue(ACCESSIBILITY_SHORTCUT_ENABLED, false);
value.shortcutEnabledOnLockScreen = config_->GetDbHandle()->GetIntValue(
ACCESSIBILITY_SHORTCUT_ENABLED_ON_LOCK_SCREEN, INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE);
value.shortcutOnLockScreen = config_->GetDbHandle()->GetIntValue(
ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE);
config_->GetDbHandle()->PutIntValue(ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE);
value.shortcutEnabled = config_->GetDbHandle()->GetBoolValue(ACCESSIBILITY_SHORTCUT_ENABLED, true);
value.shortcutEnabledOnLockScreen = config_->GetDbHandle()->GetBoolValue(
ACCESSIBILITY_SHORTCUT_ENABLED_ON_LOCK_SCREEN, true);
value.shortcutTimeout = config_->GetDbHandle()->GetIntValue(ACCESSIBILITY_SHORTCUT_TIMEOUT,
SHORT_KEY_TIMEOUT_BEFORE_USE);
value.clickResponseTime = config_->GetDbHandle()->GetIntValue(CLICK_RESPONSE_TIME, 0);
@ -608,6 +604,7 @@ void AccessibilityAccountData::GetConfigValueAtoHos(ConfigValueAtoHosUpdate &val
HILOG_ERROR("service is nullptr");
return;
}
service->PutBoolValue(ACCESSIBILITY_PRIVACY_CLONE_OR_UPGRADE, true);
service->GetBoolValue(ACCESSIBILITY_SCREENREADER_ENABLED, value.isScreenReaderEnabled);
service->DeleteInstance();
}
@ -695,6 +692,8 @@ void AccessibilityAccountData::Init()
if (!config_) {
config_ = std::make_shared<AccessibilitySettingsConfig>(id_);
config_->Init();
} else {
config_->InitSetting();
}
ErrCode rtn = AccountSA::OsAccountManager::GetOsAccountType(id_, accountType_);
if (rtn != ERR_OK) {

View File

@ -34,7 +34,6 @@ namespace {
const std::string SCREEN_READER_BUNDLE_ABILITY_NAME = "com.huawei.hmos.screenreader/AccessibilityExtAbility";
const int32_t SHORT_KEY_TIMEOUT_BEFORE_USE = 3000; // ms
const int32_t SHORT_KEY_TIMEOUT_AFTER_USE = 1000; // ms
const int32_t INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE = 2;
}
void AccessibilitySettings::RegisterSettingsHandler(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
@ -512,21 +511,9 @@ void AccessibilitySettings::UpdateSettingsInAtoHosStatePart(ConfigValueAtoHosUpd
}
if (atoHosValue.shortcutEnabled) {
accountData->GetConfig()->SetShortKeyState(atoHosValue.shortcutEnabled);
}
bool shortKeyOnLockScreenAutoOn = false;
if (atoHosValue.shortcutTimeout == 1) {
accountData->GetConfig()->SetShortKeyTimeout(SHORT_KEY_TIMEOUT_AFTER_USE);
if (atoHosValue.shortcutOnLockScreen == INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE) {
shortKeyOnLockScreenAutoOn = true;
accountData->GetConfig()->SetShortKeyOnLockScreenState(true);
}
} else if (atoHosValue.shortcutTimeout == 0) {
accountData->GetConfig()->SetShortKeyTimeout(SHORT_KEY_TIMEOUT_BEFORE_USE);
}
if (atoHosValue.shortcutOnLockScreen != INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE) {
accountData->GetConfig()->SetShortKeyOnLockScreenState(atoHosValue.shortcutOnLockScreen == 1);
} else if (!shortKeyOnLockScreenAutoOn) {
accountData->GetConfig()->SetShortKeyOnLockScreenState(atoHosValue.shortcutEnabledOnLockScreen == 1);
accountData->GetConfig()->SetShortKeyOnLockScreenState(true);
} else {
accountData->GetConfig()->SetShortKeyOnLockScreenState(false);
}
if (atoHosValue.screenMagnificationState) {
accountData->GetConfig()->SetScreenMagnificationState(atoHosValue.screenMagnificationState);
@ -571,6 +558,11 @@ void AccessibilitySettings::UpdateSettingsInAtoHos()
accountData->GetConfig()->SetDaltonizationColorFilter(static_cast<uint32_t>(atoHosValue.displayDaltonizer));
UpdateDaltonizationColorFilter();
}
if (atoHosValue.shortcutTimeout == 1) {
accountData->GetConfig()->SetShortKeyTimeout(SHORT_KEY_TIMEOUT_AFTER_USE);
} else if (atoHosValue.shortcutTimeout == 0) {
accountData->GetConfig()->SetShortKeyTimeout(SHORT_KEY_TIMEOUT_BEFORE_USE);
}
if (atoHosValue.isScreenReaderEnabled) {
uint32_t capabilities = CAPABILITY_GESTURE | CAPABILITY_KEY_EVENT_OBSERVER | CAPABILITY_RETRIEVE |

View File

@ -26,6 +26,7 @@ namespace {
const int32_t DEFAULT_SCALE = 100;
const int32_t SHORT_KEY_TIMEOUT_AFTER_USE = 1000; // ms
const int32_t SHORT_KEY_TIMEOUT_BEFORE_USE = 3000; // ms
const int32_t DEFAULT_ACCOUNT_ID = 100;
const std::string ACCESSIBILITY = "accessibility";
const std::string TOUCH_GUIDE_STATE = "touch_guide_state";
const std::string GESTURE_KEY = "gesture_state";
@ -55,8 +56,7 @@ namespace {
const std::string WINDOW_COLOR = "accessibility_window_color";
const std::string FONT_SCALE = "accessibility_font_scale";
const std::string ENABLED_ACCESSIBILITY_SERVICES = "enabled_accessibility_services";
const std::string SHORTCUT_ENABLED_ON_LOCK_SCREEN = "accessibility_shortcut_enabled_on_lock_screen"; // HMOS key
const std::string SHORTCUT_ON_LOCK_SCREEN = "accessibility_shortcut_on_lock_screen"; // AOS key
const std::string SHORTCUT_ENABLED_ON_LOCK_SCREEN = "accessibility_shortcut_enabled_on_lock_screen";
const std::string SHORTCUT_TIMEOUT = "accessibility_shortcut_timeout";
const std::string ACCESSIBILITY_CLONE_FLAG = "accessibility_config_clone";
const std::string SCREENREADER_TAG = "screenreader";
@ -66,6 +66,7 @@ namespace {
const std::string HIGH_CONTRAST_TEXT_HMOS_TAG = "HIGH_CONTRAST_TEXT";
const std::string SCREEN_READER_BUNDLE_ABILITY_NAME = "com.huawei.hmos.screenreader/AccessibilityExtAbility";
const std::string ACCESSIBILITY_SCREENREADER_ENABLED = "accessibility_screenreader_enabled";
const std::string ACCESSIBILITY_PRIVACY_CLONE_OR_UPGRADE = "accessibility_privacy_clone_or_upgrade";
constexpr int DOUBLE_CLICK_RESPONSE_TIME_MEDIUM = 300;
constexpr int DOUBLE_IGNORE_REPEAT_CLICK_TIME_SHORTEST = 100;
constexpr int DOUBLE_IGNORE_REPEAT_CLICK_TIME_SHORT = 400;
@ -78,7 +79,6 @@ namespace {
constexpr int INVALID_MASTER_MONO_VALUE = -1;
constexpr int AUDIO_BALANCE_STEP = 5;
constexpr float INVALID_MASTER_BALANCE_VALUE = 2.0;
constexpr int INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE = 2;
constexpr float EPS = 1e-6;
} // namespace
AccessibilitySettingsConfig::AccessibilitySettingsConfig(int32_t id)
@ -824,32 +824,32 @@ void AccessibilitySettingsConfig::InitCaption()
void AccessibilitySettingsConfig::InitShortKeyConfig()
{
isShortKeyState_ = datashare_->GetBoolValue(SHORTCUT_ENABLED, true);
int isShortKeyEnabledOnLockScreen = datashare_->GetIntValue(SHORTCUT_ENABLED_ON_LOCK_SCREEN,
INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE);
int isShortKeyOnLockScreen = datashare_->GetIntValue(SHORTCUT_ON_LOCK_SCREEN,
INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE);
bool isShortKeyEnabledOnLockScreen = datashare_->GetBoolValue(SHORTCUT_ENABLED_ON_LOCK_SCREEN, true);
shortKeyTimeout_ = static_cast<int32_t>(datashare_->GetIntValue(SHORTCUT_TIMEOUT, SHORT_KEY_TIMEOUT_BEFORE_USE));
bool shortKeyOnLockScreenAutoOn = false;
// for AOS to HMOS
if (shortKeyTimeout_ == 1) {
SetShortKeyTimeout(SHORT_KEY_TIMEOUT_AFTER_USE);
if (isShortKeyOnLockScreen == INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE) {
shortKeyOnLockScreenAutoOn = true;
SetShortKeyOnLockScreenState(true);
}
} else if (shortKeyTimeout_ == 0) {
SetShortKeyTimeout(SHORT_KEY_TIMEOUT_BEFORE_USE);
}
if (isShortKeyOnLockScreen != INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE) {
SetShortKeyOnLockScreenState(isShortKeyOnLockScreen == 1);
} else if (!shortKeyOnLockScreenAutoOn) {
SetShortKeyOnLockScreenState(isShortKeyEnabledOnLockScreen == 1);
// Initialization of the private space after cloning or upgrade
std::shared_ptr<AccessibilitySettingProvider> service =
AccessibilitySettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID);
if (service == nullptr) {
HILOG_ERROR("service is nullptr");
return;
}
auto ret = datashare_->PutIntValue(SHORTCUT_ON_LOCK_SCREEN, INVALID_SHORTCUT_ON_LOCK_SCREEN_STATE);
if (ret != RET_OK) {
HILOG_ERROR("reset shortcut on lock screen failed");
bool cloneOrUpgradeFlag = false;
service->GetBoolValue(ACCESSIBILITY_PRIVACY_CLONE_OR_UPGRADE, false);
if (cloneOrUpgradeFlag && (accountId_ != DEFAULT_ACCOUNT_ID)) {
if (isShortKeyState_) {
SetShortKeyOnLockScreenState(true);
} else {
SetShortKeyOnLockScreenState(false);
}
service->PutBoolValue(ACCESSIBILITY_PRIVACY_CLONE_OR_UPGRADE, false);
}
}
@ -1032,6 +1032,12 @@ void AccessibilitySettingsConfig::OnDataClone()
HILOG_INFO();
InitSetting();
if (shortKeyTimeout_ == 1) {
SetShortKeyTimeout(SHORT_KEY_TIMEOUT_AFTER_USE);
} else if (shortKeyTimeout_ == 0) {
SetShortKeyTimeout(SHORT_KEY_TIMEOUT_BEFORE_USE);
}
std::shared_ptr<AccessibilitySettingProvider> service =
AccessibilitySettingProvider::GetInstance(POWER_MANAGER_SERVICE_ID);
if (service == nullptr) {
@ -1045,6 +1051,7 @@ void AccessibilitySettingsConfig::OnDataClone()
ErrCode ret = service->PutBoolValue(ACCESSIBILITY_SCREENREADER_ENABLED, true, true);
HILOG_INFO("set screenReader state, ret = %{public}d", ret);
}
service->PutBoolValue(ACCESSIBILITY_PRIVACY_CLONE_OR_UPGRADE, true);
service->PutBoolValue(ACCESSIBILITY_CLONE_FLAG, false);
}
} // namespace Accessibility