• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_update_callback_stub.h"
17 #include "intell_voice_log.h"
18 
19 #define LOG_TAG "IntellVoiceUpdateCallbackStub"
20 
21 using namespace OHOS::HDI::IntelligentVoice::Engine::V1_0;
22 
23 namespace OHOS {
24 namespace IntellVoice {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)25 int IntellVoiceUpdateCallbackStub::OnRemoteRequest(
26     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
27 {
28     INTELL_VOICE_LOG_INFO("OnRemoteRequest update");
29     if (data.ReadInterfaceToken() != IIntelligentVoiceUpdateCallback::GetDescriptor()) {
30         INTELL_VOICE_LOG_ERROR("ReadInterfaceToken failed");
31         return -1;
32     }
33     IIntelligentVoiceUpdateCallback::Code msgCode = static_cast<IIntelligentVoiceUpdateCallback::Code>(code);
34     switch (msgCode) {
35         case ON_INTELL_VOICE_UPDATE_EVENT: {
36             OnUpdateCompleteCallback(data);
37             reply.WriteInt32(0);
38             break;
39         }
40         default: {
41             INTELL_VOICE_LOG_WARN("invalid msgCode:%{public}d", msgCode);
42             reply.WriteInt32(-1);
43             break;
44         }
45     }
46     return 0;
47 }
48 
OnUpdateCompleteCallback(MessageParcel & data)49 void IntellVoiceUpdateCallbackStub::OnUpdateCompleteCallback(MessageParcel &data)
50 {
51     OnUpdateComplete(data.ReadInt32());
52 }
53 }
54 }