• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 "ipc_server_listener.h"
17 
18 #include "device_manager_ipc_interface_code.h"
19 #include "dm_error_type.h"
20 #include "dm_log.h"
21 #include "ipc_server_stub.h"
22 
23 namespace OHOS {
24 namespace DistributedHardware {
SendRequest(int32_t cmdCode,std::shared_ptr<IpcReq> req,std::shared_ptr<IpcRsp> rsp)25 int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
26 {
27     if (rsp == nullptr || req == nullptr) {
28         return ERR_DM_INPUT_PARA_INVALID;
29     }
30     if (cmdCode < 0 || cmdCode >= IPC_MSG_BUTT) {
31         LOGE("IpcServerListener::SendRequest cmdCode param invalid!");
32         return ERR_DM_UNSUPPORTED_IPC_COMMAND;
33     }
34     ProcessInfo processInfo = req->GetProcessInfo();
35     if (processInfo.pkgName.empty()) {
36         LOGE("Invalid parameter, pkgName is empty.");
37         return ERR_DM_INPUT_PARA_INVALID;
38     }
39     sptr<IpcRemoteBroker> listener = IpcServerStub::GetInstance().GetDmListener(processInfo);
40     if (listener == nullptr) {
41         LOGI("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str());
42         return ERR_DM_POINT_NULL;
43     }
44     return listener->SendCmd(cmdCode, req, rsp);
45 }
46 
GetAllProcessInfo()47 std::vector<ProcessInfo> IpcServerListener::GetAllProcessInfo()
48 {
49     return IpcServerStub::GetInstance().GetAllProcessInfo();
50 }
51 
GetSystemSA()52 std::set<std::string> IpcServerListener::GetSystemSA()
53 {
54     return IpcServerStub::GetInstance().GetSystemSA();
55 }
56 } // namespace DistributedHardware
57 } // namespace OHOS
58