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
16 #include "accessible_ability_manager_config_observer_stub.h"
17 #include "accessibility_ipc_interface_code.h"
18 #include "hilog_wrapper.h"
19
20 namespace OHOS {
21 namespace Accessibility {
AccessibleAbilityManagerConfigObserverStub()22 AccessibleAbilityManagerConfigObserverStub::AccessibleAbilityManagerConfigObserverStub()
23 {
24 HILOG_DEBUG();
25 }
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int AccessibleAbilityManagerConfigObserverStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
28 MessageParcel &reply, MessageOption &option)
29 {
30 HILOG_DEBUG("cmd = %{public}d, flags = %{public}d", code, option.GetFlags());
31 std::u16string descriptor = AccessibleAbilityManagerConfigObserverStub::GetDescriptor();
32 std::u16string remoteDescriptor = data.ReadInterfaceToken();
33 if (descriptor != remoteDescriptor) {
34 HILOG_INFO("local descriptor is not equal to remote");
35 return ERR_INVALID_STATE;
36 }
37
38 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_CONFIG_STATE_CHANGED)) {
39 return HandleOnConfigStateChanged(data, reply);
40 }
41 if (code == static_cast<uint32_t>(
42 AccessibilityInterfaceCode::ON_DALTONIZATION_COLOR_FILTER_CHANGED)) {
43 return HandleOnDaltonizationColorFilterChanged(data, reply);
44 }
45 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_CONTENT_TIMEOUT_CHANGED)) {
46 return HandleOnContentTimeoutChanged(data, reply);
47 }
48 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_MOUSE_AUTOCLICK_CHANGED)) {
49 return HandleOnMouseAutoClickChanged(data, reply);
50 }
51 if (code ==
52 static_cast<uint32_t>(AccessibilityInterfaceCode::ON_BRIGHTNESS_DISCOUNT_CHANGED)) {
53 return HandleOnBrightnessDiscountChanged(data, reply);
54 }
55 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_AUDIO_BALANCE_CHANGED)) {
56 return HandleOnAudioBalanceChanged(data, reply);
57 }
58 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_SHORTKEY_TARGET_CHANGED)) {
59 return HandleOnShortkeyTargetChanged(data, reply);
60 }
61 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_SHORTKEY_MULTI_TARGET_CHANGED)) {
62 return HandleOnShortkeyMultiTargetChanged(data, reply);
63 }
64 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_CLICK_RESPONSE_TIME)) {
65 return HandleOnClickResponseTimeChanged(data, reply);
66 }
67 if (code == static_cast<uint32_t>(AccessibilityInterfaceCode::ON_IGNORE_REPEAT_CLICK_TIME)) {
68 return HandleOnIgnoreRepeatClickTimeChanged(data, reply);
69 }
70 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
71 }
72
HandleOnConfigStateChanged(MessageParcel & data,MessageParcel & reply)73 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnConfigStateChanged(MessageParcel &data,
74 MessageParcel &reply)
75 {
76 HILOG_DEBUG();
77 uint32_t stateType = data.ReadUint32();
78 OnConfigStateChanged(stateType);
79
80 return NO_ERROR;
81 }
82
HandleOnAudioBalanceChanged(MessageParcel & data,MessageParcel & reply)83 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnAudioBalanceChanged(
84 MessageParcel& data, MessageParcel& reply)
85 {
86 HILOG_DEBUG();
87 float audioBalance = data.ReadFloat();
88 OnAudioBalanceChanged(audioBalance);
89
90 return NO_ERROR;
91 }
HandleOnBrightnessDiscountChanged(MessageParcel & data,MessageParcel & reply)92 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnBrightnessDiscountChanged(
93 MessageParcel& data, MessageParcel& reply)
94 {
95 HILOG_DEBUG();
96 float brightnessDiscount = data.ReadFloat();
97 OnBrightnessDiscountChanged(brightnessDiscount);
98
99 return NO_ERROR;
100 }
101
HandleOnContentTimeoutChanged(MessageParcel & data,MessageParcel & reply)102 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnContentTimeoutChanged(
103 MessageParcel& data, MessageParcel& reply)
104 {
105 HILOG_DEBUG();
106 uint32_t contentTimeout = data.ReadUint32();
107 OnContentTimeoutChanged(contentTimeout);
108
109 return NO_ERROR;
110 }
111
HandleOnDaltonizationColorFilterChanged(MessageParcel & data,MessageParcel & reply)112 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnDaltonizationColorFilterChanged(
113 MessageParcel& data, MessageParcel& reply)
114 {
115 HILOG_DEBUG();
116 uint32_t filterType = data.ReadUint32();
117 OnDaltonizationColorFilterChanged(filterType);
118
119 return NO_ERROR;
120 }
121
HandleOnMouseAutoClickChanged(MessageParcel & data,MessageParcel & reply)122 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnMouseAutoClickChanged(
123 MessageParcel& data, MessageParcel& reply)
124 {
125 HILOG_DEBUG();
126 int32_t mouseAutoClick = data.ReadInt32();
127 OnMouseAutoClickChanged(mouseAutoClick);
128
129 return NO_ERROR;
130 }
131
HandleOnShortkeyTargetChanged(MessageParcel & data,MessageParcel & reply)132 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnShortkeyTargetChanged(
133 MessageParcel& data, MessageParcel& reply)
134 {
135 HILOG_DEBUG();
136 std::string shortkeyTarget = data.ReadString();
137 OnShortkeyTargetChanged(shortkeyTarget);
138
139 return NO_ERROR;
140 }
141
HandleOnShortkeyMultiTargetChanged(MessageParcel & data,MessageParcel & reply)142 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnShortkeyMultiTargetChanged(
143 MessageParcel& data, MessageParcel& reply)
144 {
145 HILOG_DEBUG();
146 std::vector<std::string> shortkeyMultiTarget;
147 if (!data.ReadStringVector(&shortkeyMultiTarget)) {
148 return ERR_TRANSACTION_FAILED;
149 }
150 OnShortkeyMultiTargetChanged(shortkeyMultiTarget);
151
152 return NO_ERROR;
153 }
154
HandleOnClickResponseTimeChanged(MessageParcel & data,MessageParcel & reply)155 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnClickResponseTimeChanged(
156 MessageParcel& data, MessageParcel& reply)
157 {
158 HILOG_DEBUG();
159 uint32_t time = data.ReadUint32();
160 OnClickResponseTimeChanged(time);
161
162 return NO_ERROR;
163 }
164
HandleOnIgnoreRepeatClickTimeChanged(MessageParcel & data,MessageParcel & reply)165 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnIgnoreRepeatClickTimeChanged(
166 MessageParcel& data, MessageParcel& reply)
167 {
168 HILOG_DEBUG();
169 uint32_t time = data.ReadUint32();
170 OnIgnoreRepeatClickTimeChanged(time);
171
172 return NO_ERROR;
173 }
174 } // namespace Accessibility
175 } // namespace OHOS