• 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 
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     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
62 }
63 
HandleOnConfigStateChanged(MessageParcel & data,MessageParcel & reply)64 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnConfigStateChanged(MessageParcel &data,
65     MessageParcel &reply)
66 {
67     HILOG_DEBUG();
68     uint32_t stateType = data.ReadUint32();
69     OnConfigStateChanged(stateType);
70 
71     return NO_ERROR;
72 }
73 
HandleOnAudioBalanceChanged(MessageParcel & data,MessageParcel & reply)74 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnAudioBalanceChanged(
75     MessageParcel& data, MessageParcel& reply)
76 {
77     HILOG_DEBUG();
78     float audioBalance = data.ReadFloat();
79     OnAudioBalanceChanged(audioBalance);
80 
81     return NO_ERROR;
82 }
HandleOnBrightnessDiscountChanged(MessageParcel & data,MessageParcel & reply)83 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnBrightnessDiscountChanged(
84     MessageParcel& data, MessageParcel& reply)
85 {
86     HILOG_DEBUG();
87     float brightnessDiscount = data.ReadFloat();
88     OnBrightnessDiscountChanged(brightnessDiscount);
89 
90     return NO_ERROR;
91 }
92 
HandleOnContentTimeoutChanged(MessageParcel & data,MessageParcel & reply)93 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnContentTimeoutChanged(
94     MessageParcel& data, MessageParcel& reply)
95 {
96     HILOG_DEBUG();
97     uint32_t contentTimeout = data.ReadUint32();
98     OnContentTimeoutChanged(contentTimeout);
99 
100     return NO_ERROR;
101 }
102 
HandleOnDaltonizationColorFilterChanged(MessageParcel & data,MessageParcel & reply)103 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnDaltonizationColorFilterChanged(
104     MessageParcel& data, MessageParcel& reply)
105 {
106     HILOG_DEBUG();
107     uint32_t filterType = data.ReadUint32();
108     OnDaltonizationColorFilterChanged(filterType);
109 
110     return NO_ERROR;
111 }
112 
HandleOnMouseAutoClickChanged(MessageParcel & data,MessageParcel & reply)113 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnMouseAutoClickChanged(
114     MessageParcel& data, MessageParcel& reply)
115 {
116     HILOG_DEBUG();
117     int32_t mouseAutoClick = data.ReadInt32();
118     OnMouseAutoClickChanged(mouseAutoClick);
119 
120     return NO_ERROR;
121 }
122 
HandleOnShortkeyTargetChanged(MessageParcel & data,MessageParcel & reply)123 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnShortkeyTargetChanged(
124     MessageParcel& data, MessageParcel& reply)
125 {
126     HILOG_DEBUG();
127     std::string shortkeyTarget = data.ReadString();
128     OnShortkeyTargetChanged(shortkeyTarget);
129 
130     return NO_ERROR;
131 }
132 } // namespace Accessibility
133 } // namespace OHOS