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 SetStartToHosState(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 GetStartToHosState(); 98 void SetDefaultShortcutKeyService(); 99 void InitSetting(); 100 void CloneShortkeyService(bool isScreenReaderEnabled); 101 void OnDataClone(); 102 void CloneAudioState(); 103 void InitShortKeyConfig(); 104 uint32_t GetShortKeyService(std::vector<std::string> &services); GetDbHandle()105 std::shared_ptr<AccessibilityDatashareHelper> GetDbHandle() 106 { 107 return datashare_; 108 } 109 110 void Init(); 111 void ClearData(); 112 private: 113 void InitCaption(); 114 void InitCapability(); 115 RetError SetConfigState(const std::string& key, bool value); 116 117 int32_t accountId_; 118 bool enabled_ = false; 119 bool eventTouchGuideState_ = false; 120 bool gesturesSimulation_ = false; 121 bool filteringKeyEvents_ = false; 122 bool isScreenMagnificationState_ = false; 123 uint32_t screenMagnificationType_ = 0; 124 bool isCaptionState_ = false; 125 AccessibilityConfig::CaptionProperty captionProperty_; 126 bool isMouseKeyState_ = false; 127 bool isShortKeyState_ = false; 128 int32_t mouseAutoClick_ = -1; 129 std::string shortkeyTarget_ = ""; 130 bool highContrastTextState_ = false; 131 bool invertColorState_ = false; 132 bool animationOffState_ = false; 133 bool audioMonoState_ = false; 134 bool daltonizationState_ = false; 135 uint32_t daltonizationColorFilter_ = 0; 136 uint32_t contentTimeout_ = 0; 137 float brightnessDiscount_ = 0.0; 138 float audioBalance_ = 0.0; 139 uint32_t clickResponseTime_ = 0; 140 bool ignoreRepeatClickState_ = false; 141 uint32_t ignoreRepeatClickTime_ = 0; 142 bool isShortKeyEnabledOnLockScreen_ = false; 143 int32_t shortKeyTimeout_ = 3; 144 145 std::vector<std::string> shortkeyMultiTarget_ {}; 146 std::vector<std::string> enabledAccessibilityServices_ {}; // bundleName/abilityName 147 148 std::shared_ptr<AccessibilityDatashareHelper> datashare_ = nullptr; 149 std::shared_ptr<AccessibilityDatashareHelper> systemDatashare_ = nullptr; 150 ffrt::mutex interfaceMutex_; 151 }; 152 } // namespace Accessibility 153 } // namespace OHOS 154 #endif // ACCESSIBILITY_SETTINGS_CONFIG_H