• 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 "hilog_wrapper.h"
18 
19 namespace OHOS {
20 namespace Accessibility {
AccessibleAbilityManagerConfigObserverStub()21 AccessibleAbilityManagerConfigObserverStub::AccessibleAbilityManagerConfigObserverStub()
22 {
23     HILOG_DEBUG();
24 }
25 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)26 int AccessibleAbilityManagerConfigObserverStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
27     MessageParcel &reply, MessageOption &option)
28 {
29     HILOG_DEBUG("cmd = %{public}d, flags = %{public}d", code, option.GetFlags());
30     std::u16string descriptor = AccessibleAbilityManagerConfigObserverStub::GetDescriptor();
31     std::u16string remoteDescriptor = data.ReadInterfaceToken();
32     if (descriptor != remoteDescriptor) {
33         HILOG_INFO("local descriptor is not equal to remote");
34         return ERR_INVALID_STATE;
35     }
36 
37     if (code == static_cast<uint32_t>(IAccessibleAbilityManagerConfigObserver::Message::ON_CONFIG_STATE_CHANGED)) {
38         return HandleOnConfigStateChanged(data, reply);
39     }
40     if (code == static_cast<uint32_t>(
41                     IAccessibleAbilityManagerConfigObserver::Message::ON_DALTONIZATION_COLOR_FILTER_CHANGED)) {
42         return HandleOnDaltonizationColorFilterChanged(data, reply);
43     }
44     if (code == static_cast<uint32_t>(IAccessibleAbilityManagerConfigObserver::Message::ON_CONTENT_TIMEOUT_CHANGED)) {
45         return HandleOnContentTimeoutChanged(data, reply);
46     }
47     if (code == static_cast<uint32_t>(IAccessibleAbilityManagerConfigObserver::Message::ON_MOUSE_AUTOCLICK_CHANGED)) {
48         return HandleOnMouseAutoClickChanged(data, reply);
49     }
50     if (code ==
51         static_cast<uint32_t>(IAccessibleAbilityManagerConfigObserver::Message::ON_BRIGHTNESS_DISCOUNT_CHANGED)) {
52         return HandleOnBrightnessDiscountChanged(data, reply);
53     }
54     if (code == static_cast<uint32_t>(IAccessibleAbilityManagerConfigObserver::Message::ON_AUDIO_BALANCE_CHANGED)) {
55         return HandleOnAudioBalanceChanged(data, reply);
56     }
57     if (code == static_cast<uint32_t>(IAccessibleAbilityManagerConfigObserver::Message::ON_SHORTKEY_TARGET_CHANGED)) {
58         return HandleOnShortkeyTargetChanged(data, reply);
59     }
60     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
61 }
62 
HandleOnConfigStateChanged(MessageParcel & data,MessageParcel & reply)63 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnConfigStateChanged(MessageParcel &data,
64     MessageParcel &reply)
65 {
66     HILOG_DEBUG();
67     uint32_t stateType = data.ReadUint32();
68     OnConfigStateChanged(stateType);
69 
70     return NO_ERROR;
71 }
72 
HandleOnAudioBalanceChanged(MessageParcel & data,MessageParcel & reply)73 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnAudioBalanceChanged(
74     MessageParcel& data, MessageParcel& reply)
75 {
76     HILOG_DEBUG();
77     float audioBalance = data.ReadFloat();
78     OnAudioBalanceChanged(audioBalance);
79 
80     return NO_ERROR;
81 }
HandleOnBrightnessDiscountChanged(MessageParcel & data,MessageParcel & reply)82 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnBrightnessDiscountChanged(
83     MessageParcel& data, MessageParcel& reply)
84 {
85     HILOG_DEBUG();
86     float brightnessDiscount = data.ReadFloat();
87     OnBrightnessDiscountChanged(brightnessDiscount);
88 
89     return NO_ERROR;
90 }
91 
HandleOnContentTimeoutChanged(MessageParcel & data,MessageParcel & reply)92 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnContentTimeoutChanged(
93     MessageParcel& data, MessageParcel& reply)
94 {
95     HILOG_DEBUG();
96     uint32_t contentTimeout = data.ReadUint32();
97     OnContentTimeoutChanged(contentTimeout);
98 
99     return NO_ERROR;
100 }
101 
HandleOnDaltonizationColorFilterChanged(MessageParcel & data,MessageParcel & reply)102 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnDaltonizationColorFilterChanged(
103     MessageParcel& data, MessageParcel& reply)
104 {
105     HILOG_DEBUG();
106     uint32_t filterType = data.ReadUint32();
107     OnDaltonizationColorFilterChanged(filterType);
108 
109     return NO_ERROR;
110 }
111 
HandleOnMouseAutoClickChanged(MessageParcel & data,MessageParcel & reply)112 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnMouseAutoClickChanged(
113     MessageParcel& data, MessageParcel& reply)
114 {
115     HILOG_DEBUG();
116     int32_t mouseAutoClick = data.ReadInt32();
117     OnMouseAutoClickChanged(mouseAutoClick);
118 
119     return NO_ERROR;
120 }
121 
HandleOnShortkeyTargetChanged(MessageParcel & data,MessageParcel & reply)122 ErrCode AccessibleAbilityManagerConfigObserverStub::HandleOnShortkeyTargetChanged(
123     MessageParcel& data, MessageParcel& reply)
124 {
125     HILOG_DEBUG();
126     std::string shortkeyTarget = data.ReadString();
127     OnShortkeyTargetChanged(shortkeyTarget);
128 
129     return NO_ERROR;
130 }
131 } // namespace Accessibility
132 } // namespace OHOS