• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     DALTONIZATIONSTATE,
39     INVERTCOLORSTATE,
40     ANIMATIONOFF,
41     AUDIOMONO,
42     IGNOREREPEATCLICKSTATE
43 };
44 
45 class AccessibilitySettingsConfig final {
46 public:
47     explicit AccessibilitySettingsConfig(int id);
48     ~AccessibilitySettingsConfig() = default;
49 
50     bool SetEnabled(const bool state);
51     bool SetTouchGuideState(const bool state);
52     bool SetGestureState(const bool state);
53     bool SetKeyEventObserverState(const bool state);
54     RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption);
55     RetError SetCaptionState(const bool state);
56     RetError SetScreenMagnificationState(const bool state);
57     RetError SetShortKeyState(const bool state);
58     RetError SetMouseKeyState(const bool state);
59     RetError SetMouseAutoClick(const int32_t time);
60     RetError SetShortkeyTarget(const std::string &name);
61     RetError SetShortkeyMultiTarget(const std::vector<std::string> &name);
62     RetError SetShortkeyMultiTargetInPkgRemove(const std::string &name);
63     RetError SetHighContrastTextState(const bool state);
64     RetError SetInvertColorState(const bool state);
65     RetError SetAnimationOffState(const bool state);
66     RetError SetAudioMonoState(const bool state);
67     RetError SetDaltonizationState(const bool state);
68     RetError SetDaltonizationColorFilter(const uint32_t filter);
69     RetError SetContentTimeout(const uint32_t time);
70     RetError SetBrightnessDiscount(const float discount);
71     RetError SetAudioBalance(const float balance);
72     RetError SetClickResponseTime(const uint32_t time);
73     RetError SetIgnoreRepeatClickState(const bool state);
74     RetError SetIgnoreRepeatClickTime(const uint32_t time);
75     RetError SetStartFromAtoHosState(const bool state);
76 
77     bool GetEnabledState() const;
78     bool GetTouchGuideState() const;
79     bool GetGestureState() const;
80     bool GetKeyEventObserverState() const;
81     bool GetCaptionState() const;
82     bool GetScreenMagnificationState() const;
83     bool GetShortKeyState() const;
84     bool GetMouseKeyState() const;
85     int32_t GetMouseAutoClick() const;
86     const std::string &GetShortkeyTarget() const;
87     const std::vector<std::string> &GetShortkeyMultiTarget() const;
88     bool GetHighContrastTextState() const;
89     bool GetInvertColorState() const;
90     bool GetAnimationOffState() const;
91     bool GetAudioMonoState() const;
92     bool GetDaltonizationState() const;
93     uint32_t GetDaltonizationColorFilter() const;
94     uint32_t GetContentTimeout() const;
95     float GetBrightnessDiscount() const;
96     float GetAudioBalance() const;
97     const AccessibilityConfig::CaptionProperty &GetCaptionProperty() const;
98     uint32_t GetClickResponseTime() const;
99     bool GetIgnoreRepeatClickState() const;
100     uint32_t GetIgnoreRepeatClickTime() const;
101 
102     void UpdateEnabledAbilities(const std::vector<std::string> &vecvalue);
103     const std::vector<std::string> &GetEnabledAbilityInfos();
104     uint32_t GetConfigState();
105     bool GetStartFromAtoHosState();
106 
107     void Init();
108     void ClearData();
109 private:
110     void InitCaption();
111     void InitSetting();
112     void InitCapability();
113     void InitEnabledList();
114     bool SetStatePref(int32_t type);
115     std::string StateChange(bool state);
116     void StringToVector(const std::string &stringIn, std::vector<std::string> &vectorResult);
117     void VectorToString(const std::vector<std::string> &vectorVal, std::string &stringOut);
118     bool SetStatePrefExec(int32_t type);
119 
120     int32_t accountId_;
121     bool enabled_ = false;
122     bool eventTouchGuideState_ = false;
123     bool gesturesSimulation_ = false;
124     bool filteringKeyEvents_ = false;
125     bool isScreenMagnificationState_ = false;
126     bool isCaptionState_ = false;
127     AccessibilityConfig::CaptionProperty captionProperty_;
128     bool isMouseKeyState_ = false;
129     bool isShortKeyState_ = false;
130     int32_t mouseAutoClick_ = -1;
131     std::string shortkeyTarget_ = "";
132     bool highContrastTextState_ = false;
133     bool invertColorState_ = false;
134     bool animationOffState_ = false;
135     bool audioMonoState_ = false;
136     bool daltonizationState_ = false;
137     uint32_t daltonizationColorFilter_ = 0;
138     uint32_t contentTimeout_ = 0;
139     float brightnessDiscount_ = 0.0;
140     float audioBalance_ = 0.0;
141     uint32_t clickResponseTime_ = 0;
142     bool ignoreRepeatClickState_ = false;
143     uint32_t ignoreRepeatClickTime_ = 0;
144 
145     std::vector<std::string> shortkeyMultiTarget_ {};
146     std::vector<std::string> enabledAbilityInfos_; // bundleName/abilityName/capabilities
147 
148     std::shared_ptr<NativePreferences::Preferences> pref_ = nullptr;
149 };
150 } // namespace Accessibility
151 } // namespace OHOS
152 #endif // ACCESSIBILITY_SETTINGS_CONFIG_H