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