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 "ipc_client_proxy.h"
17
18 #include "dm_constants.h"
19 #include "dm_log.h"
20 namespace OHOS::DistributedHardware { class IpcReq; }
21 namespace OHOS::DistributedHardware { class IpcRsp; }
22
23 namespace OHOS {
24 namespace DistributedHardware {
Init(const std::string & pkgName)25 int32_t IpcClientProxy::Init(const std::string &pkgName)
26 {
27 if (ipcClientManager_ == nullptr) {
28 return ERR_DM_POINT_NULL;
29 }
30 return ipcClientManager_->Init(pkgName);
31 }
32
UnInit(const std::string & pkgName)33 int32_t IpcClientProxy::UnInit(const std::string &pkgName)
34 {
35 if (ipcClientManager_ == nullptr) {
36 return ERR_DM_POINT_NULL;
37 }
38 return ipcClientManager_->UnInit(pkgName);
39 }
40
SendRequest(int32_t cmdCode,std::shared_ptr<IpcReq> req,std::shared_ptr<IpcRsp> rsp)41 int32_t IpcClientProxy::SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
42 {
43 if (cmdCode < 0 || cmdCode >= IPC_MSG_BUTT|| ipcClientManager_ == nullptr || req == nullptr || rsp == nullptr) {
44 LOGE("req,rsp or ipc client is null");
45 return ERR_DM_POINT_NULL;
46 }
47 return ipcClientManager_->SendRequest(cmdCode, req, rsp);
48 }
49
OnDmServiceDied()50 int32_t IpcClientProxy::OnDmServiceDied()
51 {
52 if (ipcClientManager_ == nullptr) {
53 LOGE("IpcClientProxy::ipcClientManager_ is null");
54 return ERR_DM_POINT_NULL;
55 }
56 return ipcClientManager_->OnDmServiceDied();
57 }
58 } // namespace DistributedHardware
59 } // namespace OHOS
60