• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "dump_broker_stub.h"
16 #include <message_parcel.h>
17 #include "dump_errors.h"
18 #include "hilog_wrapper.h"
19 namespace OHOS {
20 namespace HiviewDFX {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)21 int DumpBrokerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
22 {
23     std::u16string descripter = DumpBrokerStub::GetDescriptor();
24     std::u16string remoteDescripter = data.ReadInterfaceToken();
25     if (descripter != remoteDescripter) {
26         return ERROR_GET_DUMPER_SERVICE;
27     }
28     int ret = ERR_OK;
29     switch (code) {
30         case static_cast<int>(IDumpBroker::DUMP_REQUEST_FILEFD): {
31             DUMPER_HILOGD(MODULE_ZIDL, "debug|RequestFileFdStub");
32             ret = RequestFileFdStub(data, reply);
33             break;
34         }
35         default: {
36             ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
37             break;
38         }
39     }
40     return ret;
41 }
42 
RequestFileFdStub(MessageParcel & data,MessageParcel & reply)43 int32_t DumpBrokerStub::RequestFileFdStub(MessageParcel& data, MessageParcel& reply)
44 {
45     int32_t ret = ERR_OK;
46     std::vector<std::u16string> args;
47     if (!data.ReadString16Vector(&args)) {
48         return ERROR_READ_PARCEL;
49     }
50     int outfd = data.ReadFileDescriptor();
51     int32_t res = Request(args, outfd);
52     if (!reply.WriteInt32(res)) {
53         return ERROR_WRITE_PARCEL;
54     }
55     return ret;
56 }
57 } // namespace HiviewDFX
58 } // namespace OHOS
59