• 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_caption_observer_stub.h"
17 #include "accessibility_caption_parcel.h"
18 #include "hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace Accessibility {
AccessibleAbilityManagerCaptionObserverStub()22 AccessibleAbilityManagerCaptionObserverStub::AccessibleAbilityManagerCaptionObserverStub()
23 {
24     HILOG_DEBUG();
25 }
26 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int AccessibleAbilityManagerCaptionObserverStub::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 = AccessibleAbilityManagerCaptionObserverStub::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 ==
39         static_cast<uint32_t>(IAccessibleAbilityManagerCaptionObserver::Message::ON_PROPERTY_CHANGED)) {
40         return HandleOnCaptionPropertyChanged(data, reply);
41     }
42     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
43 }
44 
HandleOnCaptionPropertyChanged(MessageParcel & data,MessageParcel & reply)45 ErrCode AccessibleAbilityManagerCaptionObserverStub::HandleOnCaptionPropertyChanged(MessageParcel &data,
46     MessageParcel &reply)
47 {
48     HILOG_DEBUG();
49     sptr<CaptionPropertyParcel> property = data.ReadStrongParcelable<CaptionPropertyParcel>();
50     if (!property) {
51         HILOG_ERROR("ReadStrongParcelable<CaptionProperty> failed");
52         return ERR_TRANSACTION_FAILED;
53     }
54     OnPropertyChanged(*property);
55 
56     return NO_ERROR;
57 }
58 } // namespace Accessibility
59 } // namespace OHOS