mirror of
https://github.com/openharmony/accessibility.git
synced 2026-08-24 22:11:28 -04:00
af42013fba
Signed-off-by: xiahaiqin <xiahaiqin1@huawei.com> Change-Id: I360e298fb9d6490d1ebc638f271df56dc503aaa6
72 lines
2.2 KiB
C++
72 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "accessible_ability_manager_state_observer_proxy.h"
|
|
#include "hilog_wrapper.h"
|
|
|
|
namespace OHOS {
|
|
namespace Accessibility {
|
|
AccessibleAbilityManagerStateObserverProxy::AccessibleAbilityManagerStateObserverProxy(
|
|
const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibleAbilityManagerStateObserver>(impl)
|
|
{}
|
|
|
|
AccessibleAbilityManagerStateObserverProxy::~AccessibleAbilityManagerStateObserverProxy()
|
|
{}
|
|
|
|
bool AccessibleAbilityManagerStateObserverProxy::WriteInterfaceToken(MessageParcel &data)
|
|
{
|
|
HILOG_DEBUG();
|
|
if (!data.WriteInterfaceToken(AccessibleAbilityManagerStateObserverProxy::GetDescriptor())) {
|
|
HILOG_ERROR("write interface token failed");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void AccessibleAbilityManagerStateObserverProxy::OnStateChanged(const uint32_t stateType)
|
|
{
|
|
HILOG_DEBUG();
|
|
|
|
int error = NO_ERROR;
|
|
MessageParcel data;
|
|
MessageParcel reply;
|
|
MessageOption option(MessageOption::TF_ASYNC);
|
|
|
|
if (!WriteInterfaceToken(data)) {
|
|
HILOG_ERROR("fail, connection write Token");
|
|
return;
|
|
}
|
|
|
|
if (!data.WriteUint32(stateType)) {
|
|
HILOG_ERROR("fail, connection write stateType error");
|
|
return;
|
|
}
|
|
|
|
sptr<IRemoteObject> remote = Remote();
|
|
if (!remote) {
|
|
HILOG_ERROR("fail to send transact cmd due to remote object");
|
|
return;
|
|
}
|
|
|
|
error = remote->SendRequest(
|
|
static_cast<uint32_t>(IAccessibleAbilityManagerStateObserver::Message::ON_STATE_CHANGED),
|
|
data, reply, option);
|
|
if (error != NO_ERROR) {
|
|
HILOG_ERROR("OnStateChanged fail, error: %{public}d", error);
|
|
return;
|
|
}
|
|
}
|
|
} // namespace Accessibility
|
|
} // namespace OHOS
|