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 "daudio_ipc_callback_proxy.h"
17
18 #include "daudio_errorcode.h"
19
20 #undef DH_LOG_TAG
21 #define DH_LOG_TAG "DAudioIpcCallbackProxy"
22
23 namespace OHOS {
24 namespace DistributedHardware {
OnNotifyRegResult(const std::string & devId,const std::string & dhId,const std::string & reqId,int32_t status,const std::string & resultData)25 int32_t DAudioIpcCallbackProxy::OnNotifyRegResult(const std::string &devId, const std::string &dhId,
26 const std::string &reqId, int32_t status, const std::string &resultData)
27 {
28 MessageParcel data;
29 MessageParcel reply;
30 MessageOption option;
31 if (!data.WriteInterfaceToken(GetDescriptor())) {
32 return ERR_DH_AUDIO_SA_WRITE_INTERFACE_TOKEN_FAILED;
33 }
34
35 if (!data.WriteString(devId) || !data.WriteString(dhId) || !data.WriteString(reqId) || !data.WriteInt32(status) ||
36 !data.WriteString(resultData)) {
37 return ERR_DH_AUDIO_SA_WRITE_PARAM_FAIED;
38 }
39
40 Remote()->SendRequest(NOTIFY_REGRESULT, data, reply, option);
41 int32_t ret = reply.ReadInt32();
42 return ret;
43 }
44
OnNotifyUnregResult(const std::string & devId,const std::string & dhId,const std::string & reqId,int32_t status,const std::string & resultData)45 int32_t DAudioIpcCallbackProxy::OnNotifyUnregResult(const std::string &devId, const std::string &dhId,
46 const std::string &reqId, int32_t status, const std::string &resultData)
47 {
48 MessageParcel data;
49 MessageParcel reply;
50 MessageOption option;
51
52 if (!data.WriteInterfaceToken(GetDescriptor())) {
53 return ERR_DH_AUDIO_SA_WRITE_INTERFACE_TOKEN_FAILED;
54 }
55
56 if (!data.WriteString(devId) || !data.WriteString(dhId) || !data.WriteString(reqId) || !data.WriteInt32(status) ||
57 !data.WriteString(resultData)) {
58 return ERR_DH_AUDIO_SA_WRITE_PARAM_FAIED;
59 }
60
61 Remote()->SendRequest(NOTIFY_UNREGRESULT, data, reply, option);
62 int32_t ret = reply.ReadInt32();
63 return ret;
64 }
65 } // namespace DistributedHardware
66 } // namespace OHOS