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_state_observer_stub.h"
17 #include "accessibility_ipc_interface_code.h"
18 #include "hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace Accessibility {
AccessibleAbilityManagerStateObserverStub()22 AccessibleAbilityManagerStateObserverStub::AccessibleAbilityManagerStateObserverStub()
23 {
24     HILOG_DEBUG();
25 }
26 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int AccessibleAbilityManagerStateObserverStub::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 = AccessibleAbilityManagerStateObserverStub::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_STATE_CHANGED)) {
39         return HandleOnStateChanged(data, reply);
40     }
41     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
42 }
43 
HandleOnStateChanged(MessageParcel & data,MessageParcel & reply)44 ErrCode AccessibleAbilityManagerStateObserverStub::HandleOnStateChanged(MessageParcel &data,
45     MessageParcel &reply)
46 {
47     HILOG_DEBUG();
48     uint32_t stateType = data.ReadUint32();
49     OnStateChanged(stateType);
50 
51     return NO_ERROR;
52 }
53 } // namespace Accessibility
54 } // namespace OHOS