1 /* 2 * Copyright (c) 2023 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 "intell_voice_engine_callback_proxy.h" 17 #include "intell_voice_log.h" 18 19 #define LOG_TAG "IntellVoiceEngineCallbackProxy" 20 21 using namespace OHOS::HDI::IntelligentVoice::Engine::V1_0; 22 23 namespace OHOS { 24 namespace IntellVoiceEngine { OnIntellVoiceEngineEvent(const IntellVoiceEngineCallBackEvent & event)25void IntellVoiceEngineCallbackProxy::OnIntellVoiceEngineEvent(const IntellVoiceEngineCallBackEvent &event) 26 { 27 MessageParcel data; 28 MessageParcel reply; 29 MessageOption option; 30 INTELL_VOICE_LOG_INFO("enter"); 31 32 if (!data.WriteInterfaceToken(IIntelligentVoiceEngineCallback::GetDescriptor())) { 33 INTELL_VOICE_LOG_ERROR("WriteInterfaceToken failed"); 34 return; 35 } 36 37 if (!data.WriteInt32(static_cast<int32_t>(event.msgId))) { 38 INTELL_VOICE_LOG_ERROR("write msgid failed"); 39 return; 40 } 41 42 if (!data.WriteInt32(static_cast<int32_t>(event.result))) { 43 INTELL_VOICE_LOG_ERROR("write result failed"); 44 return; 45 } 46 47 if (!data.WriteString(event.info)) { 48 INTELL_VOICE_LOG_ERROR("write info failed"); 49 return; 50 } 51 52 int32_t error = Remote()->SendRequest(IIntelligentVoiceEngineCallback::Code::ON_INTELL_VOICE_ENGINE_EVENT, 53 data, reply, option); 54 if (error != 0) { 55 INTELL_VOICE_LOG_ERROR("send request error: %{public}d", error); 56 return; 57 } 58 reply.ReadInt32(); 59 } 60 } 61 }