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 "accessibility_enable_ability_lists_observer_proxy.h"
17 #include "hilog_wrapper.h"
18
19 namespace OHOS {
20 namespace Accessibility {
AccessibilityEnableAbilityListsObserverProxy(const sptr<IRemoteObject> & impl)21 AccessibilityEnableAbilityListsObserverProxy::AccessibilityEnableAbilityListsObserverProxy(
22 const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibilityEnableAbilityListsObserver>(impl)
23 {}
24
~AccessibilityEnableAbilityListsObserverProxy()25 AccessibilityEnableAbilityListsObserverProxy::~AccessibilityEnableAbilityListsObserverProxy()
26 {}
27
WriteInterfaceToken(MessageParcel & data)28 bool AccessibilityEnableAbilityListsObserverProxy::WriteInterfaceToken(MessageParcel &data)
29 {
30 HILOG_DEBUG();
31 if (!data.WriteInterfaceToken(AccessibilityEnableAbilityListsObserverProxy::GetDescriptor())) {
32 HILOG_ERROR("write interface token failed");
33 return false;
34 }
35 return true;
36 }
37
OnAccessibilityEnableAbilityListsChanged()38 void AccessibilityEnableAbilityListsObserverProxy::OnAccessibilityEnableAbilityListsChanged()
39 {
40 HILOG_DEBUG();
41
42 MessageParcel data;
43 MessageParcel reply;
44 MessageOption option(MessageOption::TF_ASYNC);
45
46 if (!WriteInterfaceToken(data)) {
47 HILOG_ERROR("write interface token failed");
48 return;
49 }
50
51 sptr<IRemoteObject> remote = Remote();
52 if (!remote) {
53 HILOG_ERROR("fail to send transact cmd due to remote object");
54 return;
55 }
56
57 int32_t result = remote->SendRequest(static_cast<uint32_t>(
58 IAccessibilityEnableAbilityListsObserver::Message::ON_ACCESSIBILITY_ENABLE_ABILITY_LISTS_CHANGED),
59 data, reply, option);
60 if (result != NO_ERROR) {
61 HILOG_ERROR("OnAccessibilityEnableAbilityListsChanged fail, error: %{public}d", result);
62 }
63 }
64 } // namespace Accessibility
65 } // namespace OHOS