1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef ACCESSIBILITY_SETTINGS_CONFIG_H 16 #define ACCESSIBILITY_SETTINGS_CONFIG_H 17 18 #include <map> 19 #include <set> 20 #include <string> 21 #include <vector> 22 23 #include "accessibility_caption.h" 24 #include "accessibility_datashare_helper.h" 25 26 namespace OHOS { 27 namespace Accessibility { 28 29 class AccessibilitySettingsConfig final { 30 public: 31 explicit AccessibilitySettingsConfig(int id); 32 ~AccessibilitySettingsConfig() = default; 33 34 RetError SetEnabled(const bool state); 35 RetError SetTouchGuideState(const bool state); 36 RetError SetGestureState(const bool state); 37 RetError SetKeyEventObserverState(const bool state); 38 RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption); 39 RetError SetCaptionState(const bool state); 40 RetError SetScreenMagnificationState(const bool state); 41 RetError SetScreenMagnificationType(const uint32_t type); 42 RetError SetShortKeyState(const bool state); 43 RetError SetShortKeyOnLockScreenState(const bool state); 44 RetError SetShortKeyTimeout(const int32_t time); 45 RetError SetMouseKeyState(const bool state); 46 RetError SetMouseAutoClick(const int32_t time); 47 RetError SetShortkeyTarget(const std::string &name); 48 RetError SetShortkeyMultiTarget(const std::vector<std::string> &name); 49 RetError SetShortkeyMultiTargetInPkgRemove(const std::string &name); 50 RetError SetHighContrastTextState(const bool state); 51 RetError SetInvertColorState(const bool state); 52 RetError SetAnimationOffState(const bool state); 53 RetError SetAudioMonoState(const bool state); 54 RetError SetDaltonizationState(const bool state); 55 RetError SetDaltonizationColorFilter(const uint32_t filter); 56 RetError SetContentTimeout(const uint32_t time); 57 RetError SetBrightnessDiscount(const float discount); 58 RetError SetAudioBalance(const float balance); 59 RetError SetClickResponseTime(const uint32_t time); 60 RetError SetIgnoreRepeatClickState(const bool state); 61 RetError SetIgnoreRepeatClickTime(const uint32_t time); 62 RetError SetStartFromAtoHosState(const bool state); 63 64 bool GetEnabledState() const; 65 bool GetTouchGuideState() const; 66 bool GetGestureState() const; 67 bool GetKeyEventObserverState() const; 68 bool GetCaptionState() const; 69 bool GetScreenMagnificationState() const; 70 bool GetShortKeyState() const; 71 bool GetShortKeyOnLockScreenState() const; 72 int32_t GetShortKeyTimeout() const; 73 bool GetMouseKeyState() const; 74 int32_t GetMouseAutoClick() const; 75 const std::string &GetShortkeyTarget() const; 76 const std::vector<std::string> GetShortkeyMultiTarget(); 77 bool GetHighContrastTextState() const; 78 bool GetInvertColorState() const; 79 bool GetAnimationOffState() const; 80 bool GetAudioMonoState() const; 81 bool GetDaltonizationState() const; 82 uint32_t GetDaltonizationColorFilter() const; 83 uint32_t GetContentTimeout() const; 84 float GetBrightnessDiscount() const; 85 float GetAudioBalance() const; 86 const AccessibilityConfig::CaptionProperty &GetCaptionProperty() const; 87 uint32_t GetClickResponseTime() const; 88 bool GetIgnoreRepeatClickState() const; 89 uint32_t GetIgnoreRepeatClickTime() const; 90 uint32_t GetScreenMagnificationType() const; 91 92 RetError SetEnabledAccessibilityServices(const std::vector<std::string> &services); 93 const std::vector<std::string> GetEnabledAccessibilityServices(); 94 RetError AddEnabledAccessibilityService(const std::string &serviceName); 95 RetError RemoveEnabledAccessibilityService(const std::string &serviceName); 96 uint32_t GetConfigState(); 97 bool GetStartFromAtoHosState(); 98 void CloneShortkeyService(bool isScreenReaderEnabled); 99 void OnDataClone(); 100 void CloneAudioState(); 101 void InitShortKeyConfig(); 102 uint32_t GetShortKeyService(std::vector<std::string> &services); GetDbHandle()103 std::shared_ptr<AccessibilityDatashareHelper> GetDbHandle() 104 { 105 return datashare_; 106 } 107 108 void Init(); 109 void ClearData(); 110 private: 111 void InitCaption(); 112 void InitSetting(); 113 void InitCapability(); 114 RetError SetConfigState(const std::string& key, bool value); 115 116 int32_t accountId_; 117 bool enabled_ = false; 118 bool eventTouchGuideState_ = false; 119 bool gesturesSimulation_ = false; 120 bool filteringKeyEvents_ = false; 121 bool isScreenMagnificationState_ = false; 122 uint32_t screenMagnificationType_ = 0; 123 bool isCaptionState_ = false; 124 AccessibilityConfig::CaptionProperty captionProperty_; 125 bool isMouseKeyState_ = false; 126 bool isShortKeyState_ = false; 127 int32_t mouseAutoClick_ = -1; 128 std::string shortkeyTarget_ = ""; 129 bool highContrastTextState_ = false; 130 bool invertColorState_ = false; 131 bool animationOffState_ = false; 132 bool audioMonoState_ = false; 133 bool daltonizationState_ = false; 134 uint32_t daltonizationColorFilter_ = 0; 135 uint32_t contentTimeout_ = 0; 136 float brightnessDiscount_ = 0.0; 137 float audioBalance_ = 0.0; 138 uint32_t clickResponseTime_ = 0; 139 bool ignoreRepeatClickState_ = false; 140 uint32_t ignoreRepeatClickTime_ = 0; 141 bool isShortKeyEnabledOnLockScreen_ = false; 142 int32_t shortKeyTimeout_ = 3; 143 144 std::vector<std::string> shortkeyMultiTarget_ {}; 145 std::vector<std::string> enabledAccessibilityServices_ {}; // bundleName/abilityName 146 147 std::shared_ptr<AccessibilityDatashareHelper> datashare_ = nullptr; 148 std::shared_ptr<AccessibilityDatashareHelper> systemDatashare_ = nullptr; 149 ffrt::mutex interfaceMutex_; 150 }; 151 } // namespace Accessibility 152 } // namespace OHOS 153 #endif // ACCESSIBILITY_SETTINGS_CONFIG_H