• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_cpu_stub.h"
16 #include <message_parcel.h>
17 #include "dump_cpu_data.h"
18 #include "dump_errors.h"
19 #include "hidumper_cpu_service_ipc_interface_code.h"
20 #include "hilog_wrapper.h"
21 namespace OHOS {
22 namespace HiviewDFX {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)23 int DumpBrokerCpuStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
24 {
25     std::u16string descripter = DumpBrokerCpuStub::GetDescriptor();
26     std::u16string remoteDescripter = data.ReadInterfaceToken();
27     if (descripter != remoteDescripter) {
28         return ERROR_GET_DUMPER_SERVICE;
29     }
30     int ret = ERR_OK;
31     switch (code) {
32         case static_cast<int>(HidumperCpuServiceInterfaceCode::DUMP_REQUEST_CPUINFO): {
33             std::shared_ptr<DumpCpuData> dumpCpuData(data.ReadParcelable<DumpCpuData>());
34             if (dumpCpuData == nullptr) {
35                 DUMPER_HILOGE(MODULE_CPU_ZIDL, "error|DumpBrokerCpuStub error");
36                 return ERROR_READ_PARCEL;
37             }
38             int32_t res = Request(*dumpCpuData);
39             DumpCpuData dump = *dumpCpuData;
40             if (!reply.WriteParcelable(&dump)) {
41                 return ERROR_WRITE_PARCEL;
42             }
43             if (!reply.WriteInt32(res)) {
44                 return ERROR_WRITE_PARCEL;
45             }
46             break;
47         }
48         default: {
49             ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
50             break;
51         }
52     }
53     return ret;
54 }
55 } // namespace HiviewDFX
56 } // namespace OHOS
57