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 "executor/api_dumper.h"
17 #include <sstream>
18 #include "parameter.h"
19
20 namespace OHOS {
21 namespace HiviewDFX {
APIDumper()22 APIDumper::APIDumper()
23 {
24 }
25
~APIDumper()26 APIDumper::~APIDumper()
27 {
28 }
29
PreExecute(const std::shared_ptr<DumperParameter> & parameter,StringMatrix dumpDatas)30 DumpStatus APIDumper::PreExecute(const std::shared_ptr<DumperParameter>& parameter,
31 StringMatrix dumpDatas)
32 {
33 if (dumpDatas.get()) {
34 result_ = dumpDatas;
35 return DumpStatus::DUMP_OK;
36 }
37 return DumpStatus::DUMP_FAIL;
38 }
39
Execute()40 DumpStatus APIDumper::Execute()
41 {
42 AddApiRetIntoResult(GetDisplayVersion(), "BuildId");
43 AddApiRetIntoResult(GetOsReleaseType(), "RleaseType");
44 AddApiRetIntoResult(GetVersionId(), "OsVersion");
45 AddApiRetIntoResult(GetDeviceType(), "DeviceType");
46 AddApiRetIntoResult(GetManufacture(), "Manufacture");
47 AddApiRetIntoResult(GetBrand(), "Brand");
48 AddApiRetIntoResult(GetMarketName(), "MarketName");
49 AddApiRetIntoResult(GetProductSeries(), "ProductSeries");
50 AddApiRetIntoResult(GetProductModel(), "ProductModel");
51 AddApiRetIntoResult(GetSoftwareModel(), "SoftwareModel");
52 AddApiRetIntoResult(GetHardwareModel(), "HardwareModel");
53 AddApiRetIntoResult(GetHardwareProfile(), "HardwareProfile");
54 AddApiRetIntoResult(GetBootloaderVersion(), "BootLoaderVersion");
55 AddApiRetIntoResult(GetAbiList(), "ABIList");
56 AddApiRetIntoResult(GetSecurityPatchTag(), "SecurityPatch");
57 AddApiRetIntoResult(GetIncrementalVersion(), "IncrementalVersion");
58 AddApiRetIntoResult(GetOSFullName(), "OSFullName");
59 AddApiRetIntoResult(GetSdkApiVersion(), "SDKAPIVersion");
60 AddApiRetIntoResult(GetFirstApiVersion(), "FirstAPIVersion");
61 AddApiRetIntoResult(GetBuildRootHash(), "BuildHash");
62 AddApiRetIntoResult(GetBuildType(), "BuildType");
63 AddApiRetIntoResult(GetBuildUser(), "BuildUser");
64 AddApiRetIntoResult(GetBuildHost(), "BuildHost");
65 AddApiRetIntoResult(GetBuildTime(), "BuildTime");
66 return DumpStatus::DUMP_OK;
67 }
68
AddApiRetIntoResult(const char * content,const std::string & title)69 void APIDumper::AddApiRetIntoResult(const char* content, const std::string& title)
70 {
71 if (content) {
72 std::ostringstream s;
73 s << title <<": "<< content;
74 std::vector<std::string> line_vector;
75 line_vector.push_back(s.str());
76 result_->push_back(line_vector);
77 }
78 }
79
AddApiRetIntoResult(int content,const std::string & title)80 void APIDumper::AddApiRetIntoResult(int content, const std::string& title)
81 {
82 std::ostringstream s;
83 s << title <<": "<< content;
84 std::vector<std::string> line_vector;
85 line_vector.push_back(s.str());
86 result_->push_back(line_vector);
87 }
88
AfterExecute()89 DumpStatus APIDumper::AfterExecute()
90 {
91 return DumpStatus::DUMP_OK;
92 }
93 } // namespace HiviewDFX
94 } // namespace OHOS
95