• 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_service_state_proxy.h"
17 #include "hilog_wrapper.h"
18 #include "ipc_types.h"
19 #include "iremote_object.h"
20 
21 namespace OHOS {
22 namespace Accessibility {
AccessibleAbilityManagerServiceStateProxy(const sptr<IRemoteObject> & impl)23 AccessibleAbilityManagerServiceStateProxy::AccessibleAbilityManagerServiceStateProxy(
24     const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibleAbilityManagerServiceState>(impl)
25 {}
26 
~AccessibleAbilityManagerServiceStateProxy()27 AccessibleAbilityManagerServiceStateProxy::~AccessibleAbilityManagerServiceStateProxy()
28 {}
29 
WriteInterfaceToken(MessageParcel & data)30 bool AccessibleAbilityManagerServiceStateProxy::WriteInterfaceToken(MessageParcel &data)
31 {
32     HILOG_DEBUG("start");
33     if (!data.WriteInterfaceToken(AccessibleAbilityManagerServiceStateProxy::GetDescriptor())) {
34         HILOG_ERROR("write interface token failed");
35         return false;
36     }
37     return true;
38 }
39 
OnStateChanged(const uint32_t stateType)40 void AccessibleAbilityManagerServiceStateProxy::OnStateChanged(const uint32_t stateType)
41 {
42     HILOG_DEBUG("start");
43 
44     int error = NO_ERROR;
45     MessageParcel data;
46     MessageParcel reply;
47     MessageOption option;
48 
49     if (!WriteInterfaceToken(data)) {
50         HILOG_ERROR("fail, connection write Token");
51         return;
52     }
53 
54     if (!data.WriteUint32(stateType)) {
55         HILOG_ERROR("fail, connection write stateType error");
56         return;
57     }
58 
59     error = Remote()->SendRequest(
60         static_cast<uint32_t>(IAccessibleAbilityManagerServiceState::Message::ON_STATE_CHANGED),
61         data, reply, option);
62     if (error != NO_ERROR) {
63         HILOG_ERROR("OnStateChanged fail, error: %{public}d", error);
64         return;
65     }
66 }
67 } // namespace Accessibility
68 } // namespace OHOS