1 /*
2 * Copyright (c) 2021 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/daemon_stub.h"
17 #include "utils_log.h"
18
19 namespace OHOS {
20 namespace Storage {
21 namespace DistributedFile {
DaemonStub()22 DaemonStub::DaemonStub()
23 {
24 opToInterfaceMap_[DFS_DAEMON_CMD_ECHO] = &DaemonStub::EchoServerDemoInner;
25 }
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int32_t DaemonStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
28 {
29 if (data.ReadInterfaceToken() != GetDescriptor()) {
30 return DFS_DAEMON_DESCRIPTOR_IS_EMPTY;
31 }
32 auto interfaceIndex = opToInterfaceMap_.find(code);
33 if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) {
34 LOGE("Cannot response request %d: unknown tranction", code);
35 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
36 }
37 return (this->*(interfaceIndex->second))(data, reply);
38 }
39
EchoServerDemoInner(MessageParcel & data,MessageParcel & reply)40 int32_t DaemonStub::EchoServerDemoInner(MessageParcel &data, MessageParcel &reply)
41 {
42 LOGI("hello, world");
43 return ERR_NONE;
44 }
45 } // namespace DistributedFile
46 } // namespace Storage
47 } // namespace OHOS
48