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 "preferences_helper.h" 25 26 namespace OHOS { 27 namespace Accessibility { 28 enum STATE : int32_t { 29 ACCESSIBILITY, 30 TOUCHGUIDE, 31 GESTURE, 32 KEYEVENT, 33 CAPTION, 34 SCREENMAGNIFIER, 35 SHORTKEY, 36 MOUSEKEY, 37 HIGHCONTRASTTEXT, 38 INVERTCOLORSTATE, 39 ANIMATIONOFF, 40 AUDIOMONO 41 }; 42 43 class AccessibilitySettingsConfig final { 44 public: 45 explicit AccessibilitySettingsConfig(int id); 46 ~AccessibilitySettingsConfig() = default; 47 48 bool SetEnabled(const bool state); 49 bool SetTouchGuideState(const bool state); 50 bool SetGestureState(const bool state); 51 bool SetKeyEventObserverState(const bool state); 52 RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption); 53 RetError SetCaptionState(const bool state); 54 RetError SetScreenMagnificationState(const bool state); 55 RetError SetShortKeyState(const bool state); 56 RetError SetMouseKeyState(const bool state); 57 RetError SetMouseAutoClick(const int32_t time); 58 RetError SetShortkeyTarget(const std::string &name); 59 RetError SetHighContrastTextState(const bool state); 60 RetError SetInvertColorState(const bool state); 61 RetError SetAnimationOffState(const bool state); 62 RetError SetAudioMonoState(const bool state); 63 RetError SetDaltonizationColorFilter(const uint32_t filter); 64 RetError SetContentTimeout(const uint32_t time); 65 RetError SetBrightnessDiscount(const float discount); 66 RetError SetAudioBalance(const float balance); 67 68 bool GetEnabledState() const; 69 bool GetTouchGuideState() const; 70 bool GetGestureState() const; 71 bool GetKeyEventObserverState() const; 72 bool GetCaptionState() const; 73 bool GetScreenMagnificationState() const; 74 bool GetShortKeyState() const; 75 bool GetMouseKeyState() const; 76 int32_t GetMouseAutoClick() const; 77 const std::string &GetShortkeyTarget() const; 78 bool GetHighContrastTextState() const; 79 bool GetInvertColorState() const; 80 bool GetAnimationOffState() const; 81 bool GetAudioMonoState() 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 88 void UpdateEnabledAbilities(const std::vector<std::string> &vecvalue); 89 const std::vector<std::string> &GetEnabledAbilityInfos(); 90 uint32_t GetConfigState(); 91 92 void Init(); 93 void ClearData(); 94 private: 95 void InitCaption(); 96 void InitSetting(); 97 void InitCapability(); 98 void InitEnabledList(); 99 bool SetStatePref(int32_t type); 100 std::string StateChange(bool state); 101 void StringToVector(const std::string &stringIn, std::vector<std::string> &vectorResult); 102 void VectorToString(const std::vector<std::string> &vectorVal, std::string &stringOut); 103 104 int32_t accountId_; 105 bool enabled_ = false; 106 bool eventTouchGuideState_ = false; 107 bool gesturesSimulation_ = false; 108 bool filteringKeyEvents_ = false; 109 bool isScreenMagnificationState_ = false; 110 bool isCaptionState_ = false; 111 AccessibilityConfig::CaptionProperty captionProperty_; 112 bool isMouseKeyState_ = false; 113 bool isShortKeyState_ = false; 114 int32_t mouseAutoClick_ = -1; 115 std::string shortkeyTarget_ = ""; 116 bool highContrastTextState_ = false; 117 bool invertColorState_ = false; 118 bool animationOffState_ = false; 119 bool audioMonoState_ = false; 120 uint32_t daltonizationColorFilter_ = 0; 121 uint32_t contentTimeout_ = 0; 122 float brightnessDiscount_ = 0.0; 123 float audioBalance_ = 0.0; 124 125 std::vector<std::string> enabledAbilityInfos_; // bundleName/abilityName/capabilities 126 127 std::shared_ptr<NativePreferences::Preferences> pref_ = nullptr; 128 }; 129 } // namespace Accessibility 130 } // namespace OHOS 131 #endif // ACCESSIBILITY_SETTINGS_CONFIG_H